fix r+enter, add ,;

This commit is contained in:
nightwing 2013-03-01 14:37:09 +04:00
commit 2eabebccaa
2 changed files with 53 additions and 16 deletions

View file

@ -90,6 +90,8 @@ var actions = exports.actions = {
param: true,
fn: function(editor, range, count, param) {
if (param && param.length) {
if (param.length > 1)
param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
repeat(function() { editor.insert(param); }, count || 1);
editor.navigateLeft();
}
@ -286,26 +288,20 @@ var actions = exports.actions = {
var val = ":";
if (count > 1)
val = ".,.+" + count + val;
if (editor.cmdLine) {
editor.cmdLine.setValue(val, 1);
editor.cmdLine.focus();
}
if (editor.showCommandLine)
editor.showCommandLine(val);
}
},
"/": {
fn: function(editor, range, count, param) {
if (editor.cmdLine) {
editor.cmdLine.setValue("/", 1);
editor.cmdLine.focus();
}
if (editor.showCommandLine)
editor.showCommandLine("/");
}
},
"?": {
fn: function(editor, range, count, param) {
if (editor.cmdLine) {
editor.cmdLine.setValue("?", 1);
editor.cmdLine.focus();
}
if (editor.showCommandLine)
editor.showCommandLine("?");
}
},
".": {

View file

@ -138,6 +138,8 @@ function find(editor, needle, dir) {
var Range = require("../../../range").Range;
var LAST_SEARCH_MOTION = {};
module.exports = {
"w": new Motion(function(editor) {
var str = new StringStream(editor);
@ -381,7 +383,9 @@ module.exports = {
"f": new Motion({
param: true,
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
getPos: function(editor, range, count, param, isSel, isRepeat) {
if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "f", param: param};
var cursor = editor.getCursorPosition();
var column = util.getRightNthChar(editor, cursor, param, count || 1);
@ -394,7 +398,9 @@ module.exports = {
"F": new Motion({
param: true,
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
getPos: function(editor, range, count, param, isSel, isRepeat) {
if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "F", param: param};
var cursor = editor.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
@ -407,10 +413,15 @@ module.exports = {
"t": new Motion({
param: true,
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
getPos: function(editor, range, count, param, isSel, isRepeat) {
if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "t", param: param};
var cursor = editor.getCursorPosition();
var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (isRepeat && column == 0 && !(count > 1))
var column = util.getRightNthChar(editor, cursor, param, 2);
if (typeof column === "number") {
cursor.column += column + (isSel ? 1 : 0);
return cursor;
@ -420,16 +431,46 @@ module.exports = {
"T": new Motion({
param: true,
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
getPos: function(editor, range, count, param, isSel, isRepeat) {
if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "T", param: param};
var cursor = editor.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
if (isRepeat && column == 0 && !(count > 1))
var column = util.getLeftNthChar(editor, cursor, param, 2);
if (typeof column === "number") {
cursor.column -= column;
return cursor;
}
}
}),
";": new Motion({
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
var ch = LAST_SEARCH_MOTION.ch;
if (!ch)
return;
return module.exports[ch].getPos(
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
);
}
}),
",": new Motion({
handlesCount: true,
getPos: function(editor, range, count, param, isSel) {
var ch = LAST_SEARCH_MOTION.ch;
if (!ch)
return;
var up = ch.toUpperCase();
ch = ch === up ? ch.toLowerCase() : up;
return module.exports[ch].getPos(
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
);
}
}),
"^": {
nav: function(editor) {