kopia lustrzana https://github.com/c9/core
Merge pull request +15283 from c9/ide-emacs
add more tab commands to emacs modepull/125/merge
commit
da79f8547c
|
@ -406,8 +406,8 @@ exports.emacsKeys = {
|
|||
"Return|C-m": {command: "insertstring", args: "\n"}, // "newline"
|
||||
"C-o": "splitline",
|
||||
|
||||
"M-d|C-Delete": {command: "killWord", args: "right"},
|
||||
"C-Backspace|M-Backspace|M-Delete": {command: "killWord", args: "left"},
|
||||
"M-d|C-Delete|Esc d": {command: "killWord", args: "right"},
|
||||
"C-Backspace|M-Backspace|M-Delete|Esc Backspace": {command: "killWord", args: "left"},
|
||||
"C-k": "killLine",
|
||||
|
||||
"C-y|S-Delete": "yank",
|
||||
|
|
|
@ -6,7 +6,22 @@ exports.aceKeyboardHandler = require("ace/keyboard/emacs").handler;
|
|||
|
||||
var keys = [{
|
||||
bindKey: "C-x C-f",
|
||||
name: "newfile"
|
||||
}, {
|
||||
bindKey: "C-x d",
|
||||
name: "navigate"
|
||||
}, {
|
||||
bindKey: "C-x Left",
|
||||
name: "nexttab",
|
||||
exec: function() {
|
||||
exports.tabbehavior.nexttab(1, true);
|
||||
}
|
||||
}, {
|
||||
bindKey: "C-x Right",
|
||||
name: "previoustab",
|
||||
exec: function() {
|
||||
exports.tabbehavior.nexttab(-1, true);
|
||||
}
|
||||
}, {
|
||||
bindKey: "C-x C-s",
|
||||
name: "save"
|
||||
|
@ -16,16 +31,20 @@ var keys = [{
|
|||
}, {
|
||||
bindKey: "C-x C-w",
|
||||
name: "saveas"
|
||||
}, {
|
||||
bindKey: "C-x k",
|
||||
name: "closetab"
|
||||
}];
|
||||
keys.forEach(function(item) {
|
||||
exports.aceKeyboardHandler.bindKey(item.bindKey, {
|
||||
name: item.name,
|
||||
exec: ideCommand
|
||||
exec: item.exec || item.ideCommand
|
||||
});
|
||||
});
|
||||
|
||||
// todo find a way to integrate ide commands with vim and emacs modes
|
||||
exports.execIdeCommand = null;
|
||||
exports.tabbehavior = null;
|
||||
function ideCommand() {
|
||||
exports.execIdeCommand(this.name);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
main.consumes = [
|
||||
"Plugin", "ui", "ace", "menus", "settings", "vim.cli", "tabManager",
|
||||
"commands", "c9", "tree", "dialog.error"
|
||||
"commands", "c9", "tree", "dialog.error", "tabbehavior"
|
||||
];
|
||||
main.provides = ["keymaps"];
|
||||
return main;
|
||||
|
@ -18,6 +18,7 @@ define(function(require, exports, module) {
|
|||
var c9 = imports.c9;
|
||||
var tree = imports.tree; // TODO: find a way to make dependency on tree optional
|
||||
var showError = imports["dialog.error"].show;
|
||||
var tabbehavior = imports.tabbehavior;
|
||||
|
||||
/***** Initialization *****/
|
||||
|
||||
|
@ -138,6 +139,8 @@ define(function(require, exports, module) {
|
|||
var kb = path ? require(path) : {};
|
||||
if ("execIdeCommand" in kb)
|
||||
kb.execIdeCommand = commands.exec;
|
||||
if ("tabbehavior" in kb)
|
||||
kb.tabbehavior = tabbehavior;
|
||||
|
||||
if (kb.ideCommands) {
|
||||
kb.ideCommands.forEach(function(x) {
|
||||
|
|
|
@ -32,8 +32,6 @@ define(function(require, exports, module) {
|
|||
var mnuContext, mnuEditors, mnuTabs;
|
||||
var menuItems = [], menuClosedItems = [];
|
||||
|
||||
var accessedTab = 0;
|
||||
|
||||
var paneList = [];
|
||||
var accessedPane = 0;
|
||||
|
||||
|
@ -432,7 +430,7 @@ define(function(require, exports, module) {
|
|||
|
||||
menus.addItemByPath("View/Layout/Split 1:2", new ui.item({
|
||||
command: "threeright"
|
||||
}), 400, mnuContext, plugin);
|
||||
}), 400, mnuContext, plugin);
|
||||
|
||||
menus.addItemByPath("View/Layout/Split 2:1", new ui.item({
|
||||
command: "threeleft"
|
||||
|
@ -618,11 +616,9 @@ define(function(require, exports, module) {
|
|||
cycleKeyPressed = false;
|
||||
|
||||
if (dirtyNextTab) {
|
||||
accessedTab = 0;
|
||||
|
||||
var tab = tabs.focussedTab;
|
||||
var accessList = tab.pane.meta.accessList;
|
||||
if (accessList[accessedTab] != tab) {
|
||||
if (accessList[0] != tab) {
|
||||
accessList.remove(tab);
|
||||
accessList.unshift(tab);
|
||||
accessList.changed = true;
|
||||
|
@ -643,7 +639,7 @@ define(function(require, exports, module) {
|
|||
settings.save();
|
||||
}
|
||||
|
||||
dirtyNextTab = false;
|
||||
dirtyNextPane = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -825,40 +821,36 @@ define(function(require, exports, module) {
|
|||
closeallbutme(tab, pages.slice(0, currIdx));
|
||||
}
|
||||
|
||||
function nexttab() {
|
||||
function nexttab(dir, keepOrder) {
|
||||
if (tabs.getTabs().length === 1)
|
||||
return;
|
||||
|
||||
var tab = tabs.focussedTab;
|
||||
var accessList = tab.pane.meta.accessList;
|
||||
|
||||
if (++accessedTab >= accessList.length)
|
||||
accessedTab = 0;
|
||||
|
||||
var next = accessList[accessedTab];
|
||||
var index = accessList.indexOf(tab);
|
||||
index += dir || 1;
|
||||
|
||||
if (index >= accessList.length)
|
||||
index = 0;
|
||||
else if (index < 0)
|
||||
index = accessList.length - 1;
|
||||
|
||||
var next = accessList[index];
|
||||
if (typeof next != "object" || !next.pane.visible)
|
||||
return nexttab();
|
||||
tabs.focusTab(next, null, true);
|
||||
|
||||
dirtyNextTab = true;
|
||||
return nexttab(dir, keepOrder);
|
||||
if (keepOrder && cycleKeyPressed == false) {
|
||||
cycleKeyPressed = true;
|
||||
tabs.focusTab(next, null, true);
|
||||
cycleKeyPressed = false;
|
||||
} else {
|
||||
tabs.focusTab(next, null, true);
|
||||
}
|
||||
dirtyNextTab = !keepOrder;
|
||||
}
|
||||
|
||||
function previoustab() {
|
||||
if (tabs.getTabs().length === 1)
|
||||
return;
|
||||
|
||||
var tab = tabs.focussedTab;
|
||||
var accessList = tab.pane.meta.accessList;
|
||||
|
||||
if (--accessedTab < 0)
|
||||
accessedTab = accessList.length - 1;
|
||||
|
||||
var next = accessList[accessedTab];
|
||||
if (typeof next != "object" || !next.pane.visible)
|
||||
return previoustab();
|
||||
tabs.focusTab(next, null, true);
|
||||
|
||||
dirtyNextTab = true;
|
||||
function previoustab(dir, keepOrder) {
|
||||
nexttab(dir || -1, keepOrder)
|
||||
}
|
||||
|
||||
function nextpane() {
|
||||
|
|
Ładowanie…
Reference in New Issue