[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) {
|
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
|
||||||
var toExecute;
|
var toExecute;
|
||||||
|
var success = false;
|
||||||
|
var commands = this.$editor.commands;
|
||||||
|
|
||||||
for (var i = this.$handlers.length; i--;) {
|
for (var i = this.$handlers.length; i--;) {
|
||||||
toExecute = this.$handlers[i].handleKeyboard(
|
toExecute = this.$handlers[i].handleKeyboard(
|
||||||
this.$data, hashId, keyString, keyCode, e
|
this.$data, hashId, keyString, keyCode, e
|
||||||
);
|
);
|
||||||
if (toExecute && toExecute.command)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!toExecute || !toExecute.command)
|
if (!toExecute || !toExecute.command)
|
||||||
return false;
|
continue;
|
||||||
|
|
||||||
var success = false;
|
|
||||||
var commands = this.$editor.commands;
|
|
||||||
|
|
||||||
// allow keyboardHandler to consume keys
|
// allow keyboardHandler to consume keys
|
||||||
if (toExecute.command != "null")
|
if (toExecute.command == "null") {
|
||||||
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
|
|
||||||
else
|
|
||||||
success = toExecute.passEvent != true;
|
success = toExecute.passEvent != true;
|
||||||
|
} else {
|
||||||
|
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
|
||||||
|
}
|
||||||
// do not stop input events to not break repeating
|
// do not stop input events to not break repeating
|
||||||
if (success && e && hashId != -1)
|
if (success && e && hashId != -1)
|
||||||
event.stopEvent(e);
|
event.stopEvent(e);
|
||||||
|
if (success)
|
||||||
|
break;
|
||||||
|
}
|
||||||
return success;
|
return success;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,9 @@ exports.handler = {
|
||||||
return startCommands[key];
|
return startCommands[key];
|
||||||
return {
|
return {
|
||||||
command: {
|
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.
|
} // if no modifier || shift: wait for input.
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,7 @@ var inputBuffer = exports.inputBuffer = {
|
||||||
lastInsertCommands: [],
|
lastInsertCommands: [],
|
||||||
|
|
||||||
push: function(editor, ch, keyId) {
|
push: function(editor, ch, keyId) {
|
||||||
|
var isKeyHandled = true;
|
||||||
this.idle = false;
|
this.idle = false;
|
||||||
var wObj = this.waitingForParam;
|
var wObj = this.waitingForParam;
|
||||||
if (wObj) {
|
if (wObj) {
|
||||||
|
|
@ -369,6 +370,7 @@ var inputBuffer = exports.inputBuffer = {
|
||||||
this.exec(editor, { operator: this.operator }, ch);
|
this.exec(editor, { operator: this.operator }, ch);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
isKeyHandled = ch.length == 1;
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,9 +381,10 @@ var inputBuffer = exports.inputBuffer = {
|
||||||
} else if (this.status) {
|
} else if (this.status) {
|
||||||
this.status = "";
|
this.status = "";
|
||||||
} else {
|
} else {
|
||||||
return;
|
return isKeyHandled;
|
||||||
}
|
}
|
||||||
editor._emit("changeStatus");
|
editor._emit("changeStatus");
|
||||||
|
return isKeyHandled;
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForParam: function(cmd) {
|
waitForParam: function(cmd) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue