fix ctrl-tab keybinding on firefox
This commit is contained in:
parent
846f712969
commit
4d2afc9d1c
3 changed files with 51 additions and 4 deletions
|
|
@ -137,9 +137,19 @@ env.editor.commands.addCommands([{
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "focusCommandLine",
|
name: "focusCommandLine",
|
||||||
bindKey: "shift-esc",
|
bindKey: "shift-esc|ctrl-`",
|
||||||
exec: function(editor, needle) { editor.cmdLine.focus(); },
|
exec: function(editor, needle) { editor.cmdLine.focus(); },
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
}, {
|
||||||
|
name: "nextFile",
|
||||||
|
bindKey: "Ctrl-tab",
|
||||||
|
exec: function(editor) { doclist.cycleOpen(editor, 1); },
|
||||||
|
readOnly: true
|
||||||
|
}, {
|
||||||
|
name: "previousFile",
|
||||||
|
bindKey: "Ctrl-shift-tab",
|
||||||
|
exec: function(editor) { doclist.cycleOpen(editor, -1); },
|
||||||
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "execute",
|
name: "execute",
|
||||||
bindKey: "ctrl+enter",
|
bindKey: "ctrl+enter",
|
||||||
|
|
@ -244,10 +254,37 @@ bindDropdown("mode", function(value) {
|
||||||
env.editor.session.modeName = value;
|
env.editor.session.modeName = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
doclist.history = doclist.docs.map(function(doc) {
|
||||||
|
return doc.name;
|
||||||
|
});
|
||||||
|
doclist.history.index = 0;
|
||||||
|
doclist.cycleOpen = function(editor, dir) {
|
||||||
|
var h = this.history
|
||||||
|
h.index += dir;
|
||||||
|
if (h.index >= h.length)
|
||||||
|
h.index = 0;
|
||||||
|
else if (h.index <= 0)
|
||||||
|
h.index = h.length - 1;
|
||||||
|
var s = h[h.index];
|
||||||
|
docEl.value = s;
|
||||||
|
docEl.onchange();
|
||||||
|
h.index
|
||||||
|
}
|
||||||
|
doclist.addToHistory = function(name) {
|
||||||
|
var h = this.history
|
||||||
|
var i = h.indexOf(name);
|
||||||
|
if (i != h.index) {
|
||||||
|
if (i != -1)
|
||||||
|
h.splice(i, 1);
|
||||||
|
h.index = h.push(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bindDropdown("doc", function(name) {
|
bindDropdown("doc", function(name) {
|
||||||
doclist.loadDoc(name, function(session) {
|
doclist.loadDoc(name, function(session) {
|
||||||
if (!session)
|
if (!session)
|
||||||
return;
|
return;
|
||||||
|
doclist.addToHistory(session.name);
|
||||||
session = env.split.setSession(session);
|
session = env.split.setSession(session);
|
||||||
whitespace.detectIndentation(session);
|
whitespace.detectIndentation(session);
|
||||||
updateUIEditorOptions();
|
updateUIEditorOptions();
|
||||||
|
|
@ -255,6 +292,7 @@ bindDropdown("doc", function(name) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function updateUIEditorOptions() {
|
function updateUIEditorOptions() {
|
||||||
var editor = env.editor;
|
var editor = env.editor;
|
||||||
var session = editor.session;
|
var session = editor.session;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ function initDoc(file, path, doc) {
|
||||||
session.setUndoManager(new UndoManager());
|
session.setUndoManager(new UndoManager());
|
||||||
doc.session = session;
|
doc.session = session;
|
||||||
doc.path = path;
|
doc.path = path;
|
||||||
|
session.name = doc.name;
|
||||||
if (doc.wrapped) {
|
if (doc.wrapped) {
|
||||||
session.setUseWrapMode(true);
|
session.setUseWrapMode(true);
|
||||||
session.setWrapLimitRange(80, 80);
|
session.setWrapLimitRange(80, 80);
|
||||||
|
|
|
||||||
|
|
@ -274,11 +274,19 @@ exports.addCommandKeyListener = function(el, callback) {
|
||||||
return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
|
return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var lastDown = null;
|
var lastDefaultPrevented = null;
|
||||||
|
|
||||||
addListener(el, "keydown", function(e) {
|
addListener(el, "keydown", function(e) {
|
||||||
lastDown = e.keyIdentifier || e.keyCode;
|
var result = normalizeCommandKeys(callback, e, e.keyCode);
|
||||||
return normalizeCommandKeys(callback, e, e.keyCode);
|
lastDefaultPrevented = e.defaultPrevented;
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
|
addListener(el, "keypress", function(e) {
|
||||||
|
if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
|
||||||
|
exports.stopEvent(e);
|
||||||
|
lastDefaultPrevented = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue