fix vim mode +cleanup
This commit is contained in:
parent
2a347a35c9
commit
25c9c553c6
1 changed files with 12 additions and 14 deletions
|
|
@ -45,22 +45,22 @@ var coreCommands = cmds.coreCommands;
|
||||||
var util = require("./vim/maps/util");
|
var util = require("./vim/maps/util");
|
||||||
|
|
||||||
var startCommands = {
|
var startCommands = {
|
||||||
'i': {
|
"i": {
|
||||||
command: coreCommands.start
|
command: coreCommands.start
|
||||||
},
|
},
|
||||||
'I': {
|
"I": {
|
||||||
command: coreCommands.startBeginning
|
command: coreCommands.startBeginning
|
||||||
},
|
},
|
||||||
'a': {
|
"a": {
|
||||||
command: coreCommands.append
|
command: coreCommands.append
|
||||||
},
|
},
|
||||||
'A': {
|
"A": {
|
||||||
command: coreCommands.appendEnd
|
command: coreCommands.appendEnd
|
||||||
},
|
},
|
||||||
'ctrl-f': {
|
"ctrl-f": {
|
||||||
command: "gotopagedown"
|
command: "gotopagedown"
|
||||||
},
|
},
|
||||||
'ctrl-b': {
|
"ctrl-b": {
|
||||||
command: "gotopageup"
|
command: "gotopageup"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -68,15 +68,13 @@ var startCommands = {
|
||||||
exports.handler = {
|
exports.handler = {
|
||||||
handleKeyboard: function(data, hashId, key, keyCode, e) {
|
handleKeyboard: function(data, hashId, key, keyCode, e) {
|
||||||
// ignore command keys (shift, ctrl etc.)
|
// ignore command keys (shift, ctrl etc.)
|
||||||
// Otherwise "shift-" is added to the buffer, and later on "shift-g"
|
|
||||||
// which results in "shift-shift-g" which doesn't make sense.
|
|
||||||
if (hashId != 0 && (key == "" || key == "\x00"))
|
if (hashId != 0 && (key == "" || key == "\x00"))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (hashId == 1)
|
if (hashId == 1)
|
||||||
key = 'ctrl-' + key;
|
key = "ctrl-" + key;
|
||||||
|
|
||||||
if (data.state == 'start') {
|
if (data.state == "start") {
|
||||||
if (hashId == -1 || hashId == 1) {
|
if (hashId == -1 || hashId == 1) {
|
||||||
if (cmds.inputBuffer.idle && startCommands[key])
|
if (cmds.inputBuffer.idle && startCommands[key])
|
||||||
return startCommands[key];
|
return startCommands[key];
|
||||||
|
|
@ -86,13 +84,13 @@ exports.handler = {
|
||||||
} };
|
} };
|
||||||
} // wait for input
|
} // wait for input
|
||||||
else if (key.length == 1 && (hashId == 0 || hashId == 4)) { //no modifier || shift
|
else if (key.length == 1 && (hashId == 0 || hashId == 4)) { //no modifier || shift
|
||||||
return {command: "null"};
|
return {command: "null", passEvent: true};
|
||||||
} else if (key == 'esc') {
|
} else if (key == "esc") {
|
||||||
return {command: coreCommands.stop};
|
return {command: coreCommands.stop};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (key == 'esc' || key == 'ctrl-[') {
|
if (key == "esc" || key == "ctrl-[") {
|
||||||
data.state = 'start';
|
data.state = "start";
|
||||||
return {command: coreCommands.stop};
|
return {command: coreCommands.stop};
|
||||||
} else if (key == "ctrl-w") {
|
} else if (key == "ctrl-w") {
|
||||||
return {command: "removewordleft"};
|
return {command: "removewordleft"};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue