Merge pull request #1439 from ajaxorg/vim/ctrl_c

vim ctrl-c acts as esc
This commit is contained in:
Lennart Kats 2013-05-20 08:04:47 -07:00
commit a461d49809
3 changed files with 20 additions and 13 deletions

View file

@ -103,12 +103,12 @@ var KeyBinding = function(editor) {
// allow keyboardHandler to consume keys
if (toExecute.command == "null") {
success = toExecute.passEvent != true;
success = 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)
if (success && e && hashId != -1 && toExecute.passEvent != true)
event.stopEvent(e);
if (success)
break;

View file

@ -85,11 +85,23 @@ exports.handler = {
// ignore command keys (shift, ctrl etc.)
if (hashId != 0 && (key == "" || key == "\x00"))
return null;
var editor = data.editor;
if (hashId == 1)
key = "ctrl-" + key;
if ((key == "esc" && hashId == 0) || key == "ctrl-[") {
if (key == "ctrl-c") {
if (!useragent.isMac && editor.getCopyText()) {
editor.once("copy", function() {
if (data.state == "start")
coreCommands.stop.exec(editor);
else
editor.selection.clearSelection();
});
return {command: "null", passEvent: true};
}
return {command: coreCommands.stop};
} else if ((key == "esc" && hashId == 0) || key == "ctrl-[") {
return {command: coreCommands.stop};
} else if (data.state == "start") {
if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
@ -100,13 +112,8 @@ exports.handler = {
if (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) {
if (cmds.inputBuffer.idle && startCommands[key])
return startCommands[key];
return {
command: {
exec: function(editor) {
return cmds.inputBuffer.push(editor, key);
}
}
};
cmds.inputBuffer.push(editor, key);
return {command: "null", passEvent: false};
} // if no modifier || shift: wait for input.
else if (key.length == 1 && (hashId == 0 || hashId == 4)) {
return {command: "null", passEvent: true};

View file

@ -534,7 +534,7 @@ var Editor = require("./editor").Editor;
} else if (!this.selection.isEmpty()) {
text = this.session.getTextRange(this.getSelectionRange());
}
this._signal("copy", text);
return text;
};