char is a reserved word
This commit is contained in:
parent
5310a38dc8
commit
b0fac77a37
3 changed files with 48 additions and 48 deletions
|
|
@ -304,76 +304,76 @@ var inputBuffer = exports.inputBuffer = {
|
||||||
|
|
||||||
lastInsertCommands: [],
|
lastInsertCommands: [],
|
||||||
|
|
||||||
push: function(editor, char, keyId) {
|
push: function(editor, ch, keyId) {
|
||||||
this.idle = false;
|
this.idle = false;
|
||||||
var wObj = this.waitingForParam;
|
var wObj = this.waitingForParam;
|
||||||
if (wObj) {
|
if (wObj) {
|
||||||
this.exec(editor, wObj, char);
|
this.exec(editor, wObj, ch);
|
||||||
}
|
}
|
||||||
// If input is a number (that doesn't start with 0)
|
// If input is a number (that doesn't start with 0)
|
||||||
else if (!(char === "0" && !this.currentCount.length) &&
|
else if (!(ch === "0" && !this.currentCount.length) &&
|
||||||
(char.match(/^\d+$/) && this.isAccepting(NUMBER))) {
|
(ch.match(/^\d+$/) && this.isAccepting(NUMBER))) {
|
||||||
// Assuming that char is always of type String, and not Number
|
// Assuming that ch is always of type String, and not Number
|
||||||
this.currentCount += char;
|
this.currentCount += ch;
|
||||||
this.currentCmd = NUMBER;
|
this.currentCmd = NUMBER;
|
||||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
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 = {
|
this.operator = {
|
||||||
char: char,
|
ch: ch,
|
||||||
count: this.getCount()
|
count: this.getCount()
|
||||||
};
|
};
|
||||||
this.currentCmd = OPERATOR;
|
this.currentCmd = OPERATOR;
|
||||||
this.accepting = [NUMBER, MOTION, ACTION];
|
this.accepting = [NUMBER, MOTION, ACTION];
|
||||||
this.exec(editor, { operator: this.operator });
|
this.exec(editor, { operator: this.operator });
|
||||||
}
|
}
|
||||||
else if (motions[char] && this.isAccepting(MOTION)) {
|
else if (motions[ch] && this.isAccepting(MOTION)) {
|
||||||
this.currentCmd = MOTION;
|
this.currentCmd = MOTION;
|
||||||
|
|
||||||
var ctx = {
|
var ctx = {
|
||||||
operator: this.operator,
|
operator: this.operator,
|
||||||
motion: {
|
motion: {
|
||||||
char: char,
|
ch: ch,
|
||||||
count: this.getCount()
|
count: this.getCount()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (motions[char].param)
|
if (motions[ch].param)
|
||||||
this.waitForParam(ctx);
|
this.waitForParam(ctx);
|
||||||
else
|
else
|
||||||
this.exec(editor, ctx);
|
this.exec(editor, ctx);
|
||||||
}
|
}
|
||||||
else if (alias[char] && this.isAccepting(MOTION)) {
|
else if (alias[ch] && this.isAccepting(MOTION)) {
|
||||||
alias[char].operator.count = this.getCount();
|
alias[ch].operator.count = this.getCount();
|
||||||
this.exec(editor, alias[char]);
|
this.exec(editor, alias[ch]);
|
||||||
}
|
}
|
||||||
else if (actions[char] && this.isAccepting(ACTION)) {
|
else if (actions[ch] && this.isAccepting(ACTION)) {
|
||||||
var actionObj = {
|
var actionObj = {
|
||||||
action: {
|
action: {
|
||||||
fn: actions[char].fn,
|
fn: actions[ch].fn,
|
||||||
count: this.getCount()
|
count: this.getCount()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (actions[char].param) {
|
if (actions[ch].param) {
|
||||||
this.waitForParam(actionObj);
|
this.waitForParam(actionObj);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.exec(editor, actionObj);
|
this.exec(editor, actionObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actions[char].acceptsMotion)
|
if (actions[ch].acceptsMotion)
|
||||||
this.idle = false;
|
this.idle = false;
|
||||||
}
|
}
|
||||||
else if (this.operator) {
|
else if (this.operator) {
|
||||||
this.exec(editor, { operator: this.operator }, char);
|
this.exec(editor, { operator: this.operator }, ch);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.waitingForParam || this.motion || this.operator) {
|
if (this.waitingForParam || this.motion || this.operator) {
|
||||||
this.status += char;
|
this.status += ch;
|
||||||
} else if (this.currentCount) {
|
} else if (this.currentCount) {
|
||||||
this.status = this.currentCount;
|
this.status = this.currentCount;
|
||||||
} else if (this.status) {
|
} else if (this.status) {
|
||||||
|
|
@ -410,18 +410,18 @@ var inputBuffer = exports.inputBuffer = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o && !editor.selection.isEmpty()) {
|
if (o && !editor.selection.isEmpty()) {
|
||||||
if (operators[o.char].selFn) {
|
if (operators[o.ch].selFn) {
|
||||||
operators[o.char].selFn(editor, editor.getSelectionRange(), o.count, param);
|
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is an operator, but no motion or action. We try to pass the
|
// 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).
|
// of this is the 'dd' operator).
|
||||||
else if (!m && !a && o && param) {
|
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();
|
this.reset();
|
||||||
}
|
}
|
||||||
else if (m) {
|
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;
|
var selectable = motionObj.sel;
|
||||||
|
|
||||||
if (!o) {
|
if (!o) {
|
||||||
|
|
@ -446,7 +446,7 @@ var inputBuffer = exports.inputBuffer = {
|
||||||
else if (selectable) {
|
else if (selectable) {
|
||||||
repeat(function() {
|
repeat(function() {
|
||||||
run(motionObj.sel);
|
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);
|
}, o.count || 1);
|
||||||
}
|
}
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
|
||||||
|
|
@ -34,57 +34,57 @@ define(function(require, exports, module) {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"x": {
|
"x": {
|
||||||
operator: {
|
operator: {
|
||||||
char: "d",
|
ch: "d",
|
||||||
count: 1
|
count: 1
|
||||||
},
|
},
|
||||||
motion: {
|
motion: {
|
||||||
char: "l",
|
ch: "l",
|
||||||
count: 1
|
count: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"X": {
|
"X": {
|
||||||
operator: {
|
operator: {
|
||||||
char: "d",
|
ch: "d",
|
||||||
count: 1
|
count: 1
|
||||||
},
|
},
|
||||||
motion: {
|
motion: {
|
||||||
char: "h",
|
ch: "h",
|
||||||
count: 1
|
count: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"D": {
|
"D": {
|
||||||
operator: {
|
operator: {
|
||||||
char: "d",
|
ch: "d",
|
||||||
count: 1
|
count: 1
|
||||||
},
|
},
|
||||||
motion: {
|
motion: {
|
||||||
char: "$",
|
ch: "$",
|
||||||
count: 1
|
count: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"C": {
|
"C": {
|
||||||
operator: {
|
operator: {
|
||||||
char: "c",
|
ch: "c",
|
||||||
count: 1
|
count: 1
|
||||||
},
|
},
|
||||||
motion: {
|
motion: {
|
||||||
char: "$",
|
ch: "$",
|
||||||
count: 1
|
count: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"s": {
|
"s": {
|
||||||
operator: {
|
operator: {
|
||||||
char: "c",
|
ch: "c",
|
||||||
count: 1
|
count: 1
|
||||||
},
|
},
|
||||||
motion: {
|
motion: {
|
||||||
char: "l",
|
ch: "l",
|
||||||
count: 1
|
count: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"S": {
|
"S": {
|
||||||
operator: {
|
operator: {
|
||||||
char: "c",
|
ch: "c",
|
||||||
count: 1
|
count: 1
|
||||||
},
|
},
|
||||||
param: "c"
|
param: "c"
|
||||||
|
|
|
||||||
|
|
@ -99,24 +99,24 @@ module.exports = {
|
||||||
this.onVisualLineMode = false;
|
this.onVisualLineMode = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getRightNthChar: function(editor, cursor, char, n) {
|
getRightNthChar: function(editor, cursor, ch, n) {
|
||||||
var line = editor.getSession().getLine(cursor.row);
|
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 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) {
|
toRealChar: function(ch) {
|
||||||
if (char.length === 1)
|
if (ch.length === 1)
|
||||||
return char;
|
return ch;
|
||||||
|
|
||||||
if (/^shift-./.test(char))
|
if (/^shift-./.test(ch))
|
||||||
return char[char.length - 1].toUpperCase();
|
return ch[ch.length - 1].toUpperCase();
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue