char is a reserved word

This commit is contained in:
nightwing 2012-10-01 17:33:19 +04:00
commit b0fac77a37
3 changed files with 48 additions and 48 deletions

View file

@ -304,76 +304,76 @@ var inputBuffer = exports.inputBuffer = {
lastInsertCommands: [],
push: function(editor, char, keyId) {
push: function(editor, ch, keyId) {
this.idle = false;
var wObj = this.waitingForParam;
if (wObj) {
this.exec(editor, wObj, char);
this.exec(editor, wObj, ch);
}
// If input is a number (that doesn't start with 0)
else if (!(char === "0" && !this.currentCount.length) &&
(char.match(/^\d+$/) && this.isAccepting(NUMBER))) {
// Assuming that char is always of type String, and not Number
this.currentCount += char;
else if (!(ch === "0" && !this.currentCount.length) &&
(ch.match(/^\d+$/) && this.isAccepting(NUMBER))) {
// Assuming that ch is always of type String, and not Number
this.currentCount += ch;
this.currentCmd = NUMBER;
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
}
else if (!this.operator && this.isAccepting(OPERATOR) && operators[char]) {
else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
this.operator = {
char: char,
ch: ch,
count: this.getCount()
};
this.currentCmd = OPERATOR;
this.accepting = [NUMBER, MOTION, ACTION];
this.exec(editor, { operator: this.operator });
}
else if (motions[char] && this.isAccepting(MOTION)) {
else if (motions[ch] && this.isAccepting(MOTION)) {
this.currentCmd = MOTION;
var ctx = {
operator: this.operator,
motion: {
char: char,
ch: ch,
count: this.getCount()
}
};
if (motions[char].param)
if (motions[ch].param)
this.waitForParam(ctx);
else
this.exec(editor, ctx);
}
else if (alias[char] && this.isAccepting(MOTION)) {
alias[char].operator.count = this.getCount();
this.exec(editor, alias[char]);
else if (alias[ch] && this.isAccepting(MOTION)) {
alias[ch].operator.count = this.getCount();
this.exec(editor, alias[ch]);
}
else if (actions[char] && this.isAccepting(ACTION)) {
else if (actions[ch] && this.isAccepting(ACTION)) {
var actionObj = {
action: {
fn: actions[char].fn,
fn: actions[ch].fn,
count: this.getCount()
}
};
if (actions[char].param) {
if (actions[ch].param) {
this.waitForParam(actionObj);
}
else {
this.exec(editor, actionObj);
}
if (actions[char].acceptsMotion)
if (actions[ch].acceptsMotion)
this.idle = false;
}
else if (this.operator) {
this.exec(editor, { operator: this.operator }, char);
this.exec(editor, { operator: this.operator }, ch);
}
else {
this.reset();
}
if (this.waitingForParam || this.motion || this.operator) {
this.status += char;
this.status += ch;
} else if (this.currentCount) {
this.status = this.currentCount;
} else if (this.status) {
@ -410,18 +410,18 @@ var inputBuffer = exports.inputBuffer = {
}
if (o && !editor.selection.isEmpty()) {
if (operators[o.char].selFn) {
operators[o.char].selFn(editor, editor.getSelectionRange(), o.count, param);
if (operators[o.ch].selFn) {
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
this.reset();
}
return;
}
// There is an operator, but no motion or action. We try to pass the
// current char to the operator to see if it responds to it (an example
// current ch to the operator to see if it responds to it (an example
// of this is the 'dd' operator).
else if (!m && !a && o && param) {
operators[o.char].fn(editor, null, o.count, param);
operators[o.ch].fn(editor, null, o.count, param);
this.reset();
}
else if (m) {
@ -434,7 +434,7 @@ var inputBuffer = exports.inputBuffer = {
}
};
var motionObj = motions[m.char];
var motionObj = motions[m.ch];
var selectable = motionObj.sel;
if (!o) {
@ -446,7 +446,7 @@ var inputBuffer = exports.inputBuffer = {
else if (selectable) {
repeat(function() {
run(motionObj.sel);
operators[o.char].fn(editor, editor.getSelectionRange(), o.count, param);
operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
}, o.count || 1);
}
this.reset();

View file

@ -34,57 +34,57 @@ define(function(require, exports, module) {
module.exports = {
"x": {
operator: {
char: "d",
ch: "d",
count: 1
},
motion: {
char: "l",
ch: "l",
count: 1
}
},
"X": {
operator: {
char: "d",
ch: "d",
count: 1
},
motion: {
char: "h",
ch: "h",
count: 1
}
},
"D": {
operator: {
char: "d",
ch: "d",
count: 1
},
motion: {
char: "$",
ch: "$",
count: 1
}
},
"C": {
operator: {
char: "c",
ch: "c",
count: 1
},
motion: {
char: "$",
ch: "$",
count: 1
}
},
"s": {
operator: {
char: "c",
ch: "c",
count: 1
},
motion: {
char: "l",
ch: "l",
count: 1
}
},
"S": {
operator: {
char: "c",
ch: "c",
count: 1
},
param: "c"

View file

@ -99,24 +99,24 @@ module.exports = {
this.onVisualLineMode = false;
}
},
getRightNthChar: function(editor, cursor, char, n) {
getRightNthChar: function(editor, cursor, ch, n) {
var line = editor.getSession().getLine(cursor.row);
var matches = line.substr(cursor.column + 1).split(char);
var matches = line.substr(cursor.column + 1).split(ch);
return n < matches.length ? matches.slice(0, n).join(char).length : null;
return n < matches.length ? matches.slice(0, n).join(ch).length : null;
},
getLeftNthChar: function(editor, cursor, char, n) {
getLeftNthChar: function(editor, cursor, ch, n) {
var line = editor.getSession().getLine(cursor.row);
var matches = line.substr(0, cursor.column).split(char);
var matches = line.substr(0, cursor.column).split(ch);
return n < matches.length ? matches.slice(-1 * n).join(char).length : null;
return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
},
toRealChar: function(char) {
if (char.length === 1)
return char;
toRealChar: function(ch) {
if (ch.length === 1)
return ch;
if (/^shift-./.test(char))
return char[char.length - 1].toUpperCase();
if (/^shift-./.test(ch))
return ch[ch.length - 1].toUpperCase();
else
return "";
},