Improve vim-mode to catch input better if in 'start' mode

This commit is contained in:
Julian Viereck 2010-12-22 22:43:11 +01:00
commit ffca65d15e
2 changed files with 19 additions and 10 deletions

View file

@ -165,10 +165,12 @@ KeyboardStateMapper.prototype = {
if (binding.then) { if (binding.then) {
data.state = binding.then; data.state = binding.then;
data.buffer = ""; data.buffer = "";
}
// If no command is set, then execute the "null" fake command.
if (result.command == null) { if (result.command == null) {
result.command = "null"; result.command = "null";
} }
}
return true; return true;
}); });

View file

@ -94,15 +94,22 @@ var vimStates = {
] ]
}, },
{ {
comment: "Let all combos of Command, Ctrl, Optional pass...", comment: "Catch some keyboard input to stop it here",
match: function(buffer, hashId, key, symbolicName) { match: function(buffer, hashId, key, symbolicName) {
return hashId != 0 && !(hashId & 4); // If no command keys are pressed, then catch the input.
if (hashId == 0) {
return true;
}
// If only the shift key is pressed and a character key, then
// catch that input as well.
else if ((hashId == 4) && key.length == 1) {
return true;
}
// Otherwise, we let the input got through.
else {
return false;
}
} }
},
{
comment: "...but stop all other input!",
key: ".*",
exec: "null"
} }
], ],
insertMode: [ insertMode: [