fix ^ in vim mode on swedish keyboard on mac

This commit is contained in:
nightwing 2013-06-30 23:45:47 +04:00
commit 4b8ab8eab9

View file

@ -80,6 +80,39 @@ exports.handler = {
data.lastEvent = "keypress";
}
},
// on mac, with some keyboard layouts (e.g swedish) ^ starts composition, we don't need it in normal mode
updateMacCompositionHandlers: function(editor, enable) {
var onCompositionUpdateOverride = function(text) {
if (util.currentMode !== "insert") {
var el = this.textInput.getElement();
el.blur();
el.focus();
el.value = text;
} else {
this.onCompositionUpdateOrig(text);
}
};
var onCompositionStartOverride = function(text) {
if (util.currentMode === "insert") {
this.onCompositionStartOrig(text);
}
}
if (enable) {
if (!editor.onCompositionUpdateOrig) {
editor.onCompositionUpdateOrig = editor.onCompositionUpdate;
editor.onCompositionUpdate = onCompositionUpdateOverride;
editor.onCompositionStartOrig = editor.onCompositionStart;
editor.onCompositionStart = onCompositionStartOverride;
}
} else {
if (editor.onCompositionUpdateOrig) {
editor.onCompositionUpdate = editor.onCompositionUpdateOrig;
editor.onCompositionUpdateOrig = null;
editor.onCompositionStart = editor.onCompositionStartOrig;
editor.onCompositionStartOrig = null;
}
}
},
handleKeyboard: function(data, hashId, key, keyCode, e) {
// ignore command keys (shift, ctrl etc.)
@ -132,12 +165,15 @@ exports.handler = {
if (util.currentMode !== "insert")
cmds.coreCommands.stop.exec(editor);
editor.$vimModeHandler = this;
this.updateMacCompositionHandlers(editor, true);
},
detach: function(editor) {
editor.removeListener("click", exports.onCursorMove);
util.noMode(editor);
util.currentMode = "normal";
this.updateMacCompositionHandlers(editor, false);
},
actions: cmds.actions,