vim ctrl-c

This commit is contained in:
nightwing 2013-05-18 01:38:05 +04:00
commit c0080911e5
3 changed files with 20 additions and 13 deletions

View file

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

View file

@ -86,10 +86,22 @@ exports.handler = {
if (hashId != 0 && (key == "" || key == "\x00")) if (hashId != 0 && (key == "" || key == "\x00"))
return null; return null;
var editor = data.editor;
if (hashId == 1) if (hashId == 1)
key = "ctrl-" + key; key = "ctrl-" + key;
if (key == "ctrl-c") {
if ((key == "esc" && hashId == 0) || key == "ctrl-[") { 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}; return {command: coreCommands.stop};
} else if (data.state == "start") { } else if (data.state == "start") {
if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { 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 (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) {
if (cmds.inputBuffer.idle && startCommands[key]) if (cmds.inputBuffer.idle && startCommands[key])
return startCommands[key]; return startCommands[key];
return { cmds.inputBuffer.push(editor, key);
command: { return {command: "null", passEvent: false};
exec: function(editor) {
return cmds.inputBuffer.push(editor, key);
}
}
};
} // if no modifier || shift: wait for input. } // if no modifier || shift: wait for input.
else if (key.length == 1 && (hashId == 0 || hashId == 4)) { else if (key.length == 1 && (hashId == 0 || hashId == 4)) {
return {command: "null", passEvent: true}; return {command: "null", passEvent: true};

View file

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