fix vim mode +cleanup

This commit is contained in:
nightwing 2012-05-01 15:43:54 +04:00
commit 25c9c553c6

View file

@ -45,22 +45,22 @@ var coreCommands = cmds.coreCommands;
var util = require("./vim/maps/util");
var startCommands = {
'i': {
"i": {
command: coreCommands.start
},
'I': {
"I": {
command: coreCommands.startBeginning
},
'a': {
"a": {
command: coreCommands.append
},
'A': {
"A": {
command: coreCommands.appendEnd
},
'ctrl-f': {
"ctrl-f": {
command: "gotopagedown"
},
'ctrl-b': {
"ctrl-b": {
command: "gotopageup"
},
};
@ -68,15 +68,13 @@ var startCommands = {
exports.handler = {
handleKeyboard: function(data, hashId, key, keyCode, e) {
// 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"))
return null;
if (hashId == 1)
key = 'ctrl-' + key;
key = "ctrl-" + key;
if (data.state == 'start') {
if (data.state == "start") {
if (hashId == -1 || hashId == 1) {
if (cmds.inputBuffer.idle && startCommands[key])
return startCommands[key];
@ -86,13 +84,13 @@ exports.handler = {
} };
} // wait for input
else if (key.length == 1 && (hashId == 0 || hashId == 4)) { //no modifier || shift
return {command: "null"};
} else if (key == 'esc') {
return {command: "null", passEvent: true};
} else if (key == "esc") {
return {command: coreCommands.stop};
}
} else {
if (key == 'esc' || key == 'ctrl-[') {
data.state = 'start';
if (key == "esc" || key == "ctrl-[") {
data.state = "start";
return {command: coreCommands.stop};
} else if (key == "ctrl-w") {
return {command: "removewordleft"};