Merge pull request +15283 from c9/ide-emacs

add more tab commands to emacs mode
pull/125/merge
Harutyun Amirjanyan 2017-05-03 15:00:18 +04:00 zatwierdzone przez GitHub
commit da79f8547c
4 zmienionych plików z 50 dodań i 36 usunięć

Wyświetl plik

@ -406,8 +406,8 @@ exports.emacsKeys = {
"Return|C-m": {command: "insertstring", args: "\n"}, // "newline" "Return|C-m": {command: "insertstring", args: "\n"}, // "newline"
"C-o": "splitline", "C-o": "splitline",
"M-d|C-Delete": {command: "killWord", args: "right"}, "M-d|C-Delete|Esc d": {command: "killWord", args: "right"},
"C-Backspace|M-Backspace|M-Delete": {command: "killWord", args: "left"}, "C-Backspace|M-Backspace|M-Delete|Esc Backspace": {command: "killWord", args: "left"},
"C-k": "killLine", "C-k": "killLine",
"C-y|S-Delete": "yank", "C-y|S-Delete": "yank",

Wyświetl plik

@ -6,7 +6,22 @@ exports.aceKeyboardHandler = require("ace/keyboard/emacs").handler;
var keys = [{ var keys = [{
bindKey: "C-x C-f", bindKey: "C-x C-f",
name: "newfile"
}, {
bindKey: "C-x d",
name: "navigate" 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", bindKey: "C-x C-s",
name: "save" name: "save"
@ -16,16 +31,20 @@ var keys = [{
}, { }, {
bindKey: "C-x C-w", bindKey: "C-x C-w",
name: "saveas" name: "saveas"
}, {
bindKey: "C-x k",
name: "closetab"
}]; }];
keys.forEach(function(item) { keys.forEach(function(item) {
exports.aceKeyboardHandler.bindKey(item.bindKey, { exports.aceKeyboardHandler.bindKey(item.bindKey, {
name: item.name, name: item.name,
exec: ideCommand exec: item.exec || item.ideCommand
}); });
}); });
// todo find a way to integrate ide commands with vim and emacs modes // todo find a way to integrate ide commands with vim and emacs modes
exports.execIdeCommand = null; exports.execIdeCommand = null;
exports.tabbehavior = null;
function ideCommand() { function ideCommand() {
exports.execIdeCommand(this.name); exports.execIdeCommand(this.name);
} }

Wyświetl plik

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
main.consumes = [ main.consumes = [
"Plugin", "ui", "ace", "menus", "settings", "vim.cli", "tabManager", "Plugin", "ui", "ace", "menus", "settings", "vim.cli", "tabManager",
"commands", "c9", "tree", "dialog.error" "commands", "c9", "tree", "dialog.error", "tabbehavior"
]; ];
main.provides = ["keymaps"]; main.provides = ["keymaps"];
return main; return main;
@ -18,6 +18,7 @@ define(function(require, exports, module) {
var c9 = imports.c9; var c9 = imports.c9;
var tree = imports.tree; // TODO: find a way to make dependency on tree optional var tree = imports.tree; // TODO: find a way to make dependency on tree optional
var showError = imports["dialog.error"].show; var showError = imports["dialog.error"].show;
var tabbehavior = imports.tabbehavior;
/***** Initialization *****/ /***** Initialization *****/
@ -138,6 +139,8 @@ define(function(require, exports, module) {
var kb = path ? require(path) : {}; var kb = path ? require(path) : {};
if ("execIdeCommand" in kb) if ("execIdeCommand" in kb)
kb.execIdeCommand = commands.exec; kb.execIdeCommand = commands.exec;
if ("tabbehavior" in kb)
kb.tabbehavior = tabbehavior;
if (kb.ideCommands) { if (kb.ideCommands) {
kb.ideCommands.forEach(function(x) { kb.ideCommands.forEach(function(x) {

Wyświetl plik

@ -32,8 +32,6 @@ define(function(require, exports, module) {
var mnuContext, mnuEditors, mnuTabs; var mnuContext, mnuEditors, mnuTabs;
var menuItems = [], menuClosedItems = []; var menuItems = [], menuClosedItems = [];
var accessedTab = 0;
var paneList = []; var paneList = [];
var accessedPane = 0; var accessedPane = 0;
@ -432,7 +430,7 @@ define(function(require, exports, module) {
menus.addItemByPath("View/Layout/Split 1:2", new ui.item({ menus.addItemByPath("View/Layout/Split 1:2", new ui.item({
command: "threeright" command: "threeright"
}), 400, mnuContext, plugin); }), 400, mnuContext, plugin);
menus.addItemByPath("View/Layout/Split 2:1", new ui.item({ menus.addItemByPath("View/Layout/Split 2:1", new ui.item({
command: "threeleft" command: "threeleft"
@ -618,11 +616,9 @@ define(function(require, exports, module) {
cycleKeyPressed = false; cycleKeyPressed = false;
if (dirtyNextTab) { if (dirtyNextTab) {
accessedTab = 0;
var tab = tabs.focussedTab; var tab = tabs.focussedTab;
var accessList = tab.pane.meta.accessList; var accessList = tab.pane.meta.accessList;
if (accessList[accessedTab] != tab) { if (accessList[0] != tab) {
accessList.remove(tab); accessList.remove(tab);
accessList.unshift(tab); accessList.unshift(tab);
accessList.changed = true; accessList.changed = true;
@ -643,7 +639,7 @@ define(function(require, exports, module) {
settings.save(); settings.save();
} }
dirtyNextTab = false; dirtyNextPane = false;
} }
} }
}); });
@ -825,40 +821,36 @@ define(function(require, exports, module) {
closeallbutme(tab, pages.slice(0, currIdx)); closeallbutme(tab, pages.slice(0, currIdx));
} }
function nexttab() { function nexttab(dir, keepOrder) {
if (tabs.getTabs().length === 1) if (tabs.getTabs().length === 1)
return; return;
var tab = tabs.focussedTab; var tab = tabs.focussedTab;
var accessList = tab.pane.meta.accessList; var accessList = tab.pane.meta.accessList;
if (++accessedTab >= accessList.length) var index = accessList.indexOf(tab);
accessedTab = 0; index += dir || 1;
var next = accessList[accessedTab]; 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) if (typeof next != "object" || !next.pane.visible)
return nexttab(); return nexttab(dir, keepOrder);
tabs.focusTab(next, null, true); if (keepOrder && cycleKeyPressed == false) {
cycleKeyPressed = true;
dirtyNextTab = true; tabs.focusTab(next, null, true);
cycleKeyPressed = false;
} else {
tabs.focusTab(next, null, true);
}
dirtyNextTab = !keepOrder;
} }
function previoustab() { function previoustab(dir, keepOrder) {
if (tabs.getTabs().length === 1) nexttab(dir || -1, keepOrder)
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 nextpane() { function nextpane() {