[vim] pass unhandled keys to the browser
This commit is contained in:
parent
938d6b658d
commit
59f5e7ffca
3 changed files with 23 additions and 20 deletions
|
|
@ -90,30 +90,28 @@ var KeyBinding = function(editor) {
|
|||
|
||||
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
|
||||
var toExecute;
|
||||
var success = false;
|
||||
var commands = this.$editor.commands;
|
||||
|
||||
for (var i = this.$handlers.length; i--;) {
|
||||
toExecute = this.$handlers[i].handleKeyboard(
|
||||
this.$data, hashId, keyString, keyCode, e
|
||||
);
|
||||
if (toExecute && toExecute.command)
|
||||
if (!toExecute || !toExecute.command)
|
||||
continue;
|
||||
|
||||
// allow keyboardHandler to consume keys
|
||||
if (toExecute.command == "null") {
|
||||
success = toExecute.passEvent != true;
|
||||
} else {
|
||||
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
|
||||
}
|
||||
// do not stop input events to not break repeating
|
||||
if (success && e && hashId != -1)
|
||||
event.stopEvent(e);
|
||||
if (success)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!toExecute || !toExecute.command)
|
||||
return false;
|
||||
|
||||
var success = false;
|
||||
var commands = this.$editor.commands;
|
||||
|
||||
// allow keyboardHandler to consume keys
|
||||
if (toExecute.command != "null")
|
||||
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
|
||||
else
|
||||
success = toExecute.passEvent != true;
|
||||
|
||||
// do not stop input events to not break repeating
|
||||
if (success && e && hashId != -1)
|
||||
event.stopEvent(e);
|
||||
|
||||
return success;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@ exports.handler = {
|
|||
return startCommands[key];
|
||||
return {
|
||||
command: {
|
||||
exec: function(editor) {cmds.inputBuffer.push(editor, key);}
|
||||
exec: function(editor) {
|
||||
return cmds.inputBuffer.push(editor, key);
|
||||
}
|
||||
}
|
||||
};
|
||||
} // if no modifier || shift: wait for input.
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
lastInsertCommands: [],
|
||||
|
||||
push: function(editor, ch, keyId) {
|
||||
var isKeyHandled = true;
|
||||
this.idle = false;
|
||||
var wObj = this.waitingForParam;
|
||||
if (wObj) {
|
||||
|
|
@ -369,6 +370,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
this.exec(editor, { operator: this.operator }, ch);
|
||||
}
|
||||
else {
|
||||
isKeyHandled = ch.length == 1;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
|
|
@ -379,9 +381,10 @@ var inputBuffer = exports.inputBuffer = {
|
|||
} else if (this.status) {
|
||||
this.status = "";
|
||||
} else {
|
||||
return;
|
||||
return isKeyHandled;
|
||||
}
|
||||
editor._emit("changeStatus");
|
||||
return isKeyHandled;
|
||||
},
|
||||
|
||||
waitForParam: function(cmd) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue