in lib/ace/keyboard/vim.js [6441:6510]
handleKeyboard: function(data, hashId, key, keyCode, e) {
var editor = data.editor;
var cm = editor.state.cm;
var vim = getVim(cm);
if (keyCode == -1) return;
// in non-insert mode we try to find the ascii key corresponding to the text in textarea
// this is needed because in languages that use latin alphabet we want to get the key that browser sends to the textarea
// and in non
if (!vim.insertMode) {
if (hashId == -1) {
if (key.charCodeAt(0) > 0xFF) {
if (data.inputKey) {
key = data.inputKey;
if (key && data.inputHash == 4)
key = key.toUpperCase();
}
}
data.inputChar = key;
}
else if (hashId == 4 || hashId == 0) {
if (data.inputKey == key && data.inputHash == hashId && data.inputChar) {
// on mac text input doesn't repeat
key = data.inputChar;
hashId = -1
}
else {
data.inputChar = null;
data.inputKey = key;
data.inputHash = hashId;
}
}
else {
data.inputChar = data.inputKey = null;
}
}
// ctrl-c is special it both exits mode and copies text
if (key == "c" && hashId == 1) { // key == "ctrl-c"
if (!useragent.isMac && editor.getCopyText()) {
editor.once("copy", function() {
editor.selection.clearSelection();
});
return {command: "null", passEvent: true};
}
}
if (key == "esc" && !vim.insertMode && !vim.visualMode && !cm.ace.inMultiSelectMode) {
var searchState = getSearchState(cm);
var overlay = searchState.getOverlay();
if (overlay) cm.removeOverlay(overlay);
}
if (hashId == -1 || hashId & 1 || hashId === 0 && key.length > 1) {
var insertMode = vim.insertMode;
var name = lookupKey(hashId, key, e || {});
if (vim.status == null)
vim.status = "";
var isHandled = multiSelectHandleKey(cm, name, 'user');
vim = getVim(cm); // may be changed by multiSelectHandleKey
if (isHandled && vim.status != null)
vim.status += name;
else if (vim.status == null)
vim.status = "";
cm._signal("changeStatus");
if (!isHandled && (hashId != -1 || insertMode))
return;
return {command: "null", passEvent: !isHandled};
}
},