fixes for keybindings
This commit is contained in:
parent
d9f0e0e2c4
commit
d5d5e81561
3 changed files with 24 additions and 24 deletions
|
|
@ -15,8 +15,8 @@ var Editor = function(renderer, doc) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
|
|
||||||
this.textInput = new TextInput(container, this);
|
this.textInput = new TextInput(container, this);
|
||||||
new KeyBinding(container, this);
|
this.keyBinding = new KeyBinding(container, this);
|
||||||
var self = this;
|
var self = this;
|
||||||
ace.addListener(container, "mousedown", function(e) {
|
ace.addListener(container, "mousedown", function(e) {
|
||||||
setTimeout(function() {self.focus();});
|
setTimeout(function() {self.focus();});
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ var KeyBinding = function(element, editor, config) {
|
||||||
ace.addKeyListener(element, function(e) {
|
ace.addKeyListener(element, function(e) {
|
||||||
var key = [];
|
var key = [];
|
||||||
if (e.ctrlKey) {
|
if (e.ctrlKey) {
|
||||||
key.push("Control");
|
key.push("Ctrl");
|
||||||
}
|
}
|
||||||
if (e.metaKey) {
|
if (e.metaKey) {
|
||||||
key.push("Meta");
|
key.push("Meta");
|
||||||
|
|
@ -38,7 +38,7 @@ var KeyBinding = function(element, editor, config) {
|
||||||
8 : "Backspace",
|
8 : "Backspace",
|
||||||
9 : "Tab",
|
9 : "Tab",
|
||||||
16 : "Shift",
|
16 : "Shift",
|
||||||
17 : "Control",
|
17 : "Ctrl",
|
||||||
18 : "Alt",
|
18 : "Alt",
|
||||||
33 : "PageUp",
|
33 : "PageUp",
|
||||||
34 : "PageDown",
|
34 : "PageDown",
|
||||||
|
|
@ -53,12 +53,29 @@ var KeyBinding = function(element, editor, config) {
|
||||||
91 : "Meta"
|
91 : "Meta"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function objectReverse(obj, keySplit) {
|
||||||
|
var i, j, l, key,
|
||||||
|
ret = {};
|
||||||
|
for (i in obj) {
|
||||||
|
key = obj[i];
|
||||||
|
if (keySplit && typeof key == "string") {
|
||||||
|
key = key.split(keySplit);
|
||||||
|
for (j = 0, l = key.length; j < l; ++j)
|
||||||
|
ret[key[j].replace(/Command/i, "Meta").replace(/Option/i, "Alt")] = i;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret[key.replace(/Command/i, "Meta").replace(/Option/i, "Alt")] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
this.setConfig = function(config) {
|
this.setConfig = function(config) {
|
||||||
this.config = config || ace.isMac
|
this.config = config || (ace.isMac
|
||||||
? default_mac
|
? default_mac
|
||||||
: default_win;
|
: default_win);
|
||||||
if (typeof this.config.reverse == "undefined")
|
if (typeof this.config.reverse == "undefined")
|
||||||
this.config.reverse = ace.objectReverse(this.config, "|");
|
this.config.reverse = objectReverse(this.config, "|");
|
||||||
};
|
};
|
||||||
|
|
||||||
this["selectall"] = function() {
|
this["selectall"] = function() {
|
||||||
|
|
|
||||||
|
|
@ -43,23 +43,6 @@ require.def("ace/lib/lang", function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lang.objectReverse = function(obj, keySplit) {
|
|
||||||
var i, j, l, key,
|
|
||||||
ret = {};
|
|
||||||
for (i in obj) {
|
|
||||||
key = obj[i];
|
|
||||||
if (keySplit && typeof key == "string") {
|
|
||||||
key = key.split(keySplit);
|
|
||||||
for (j = 0, l = key.length; j < l; ++j)
|
|
||||||
ret[key[j]] = i;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret[key] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.escapeRegExp = function(str) {
|
this.escapeRegExp = function(str) {
|
||||||
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
|
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue