Merge pull request +6416 from c9/missing-commands

add commands for focusing tree and toggling wordwrap
pull/39/head^2
Ruben Daniels 2015-03-03 07:13:32 -08:00
commit a53da8f95d
9 zmienionych plików z 88 dodań i 75 usunięć

Wyświetl plik

@ -69,18 +69,14 @@ exports.iSearchCommands = [{
bindKey: {win: "Ctrl-F", mac: "Command-F"}, bindKey: {win: "Ctrl-F", mac: "Command-F"},
exec: function(iSearch) { exec: function(iSearch) {
iSearch.cancelSearch(true); iSearch.cancelSearch(true);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "searchForward", name: "searchForward",
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"}, bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
exec: function(iSearch, options) { exec: function(iSearch, options) {
options.useCurrentOrPrevSearch = true; options.useCurrentOrPrevSearch = true;
iSearch.next(options); iSearch.next(options);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "searchBackward", name: "searchBackward",
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"}, bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
@ -88,42 +84,30 @@ exports.iSearchCommands = [{
options.useCurrentOrPrevSearch = true; options.useCurrentOrPrevSearch = true;
options.backwards = true; options.backwards = true;
iSearch.next(options); iSearch.next(options);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "extendSearchTerm", name: "extendSearchTerm",
exec: function(iSearch, string) { exec: function(iSearch, string) {
iSearch.addString(string); iSearch.addString(string);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "extendSearchTermSpace", name: "extendSearchTermSpace",
bindKey: "space", bindKey: "space",
exec: function(iSearch) { iSearch.addString(' '); }, exec: function(iSearch) { iSearch.addString(' '); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "shrinkSearchTerm", name: "shrinkSearchTerm",
bindKey: "backspace", bindKey: "backspace",
exec: function(iSearch) { exec: function(iSearch) {
iSearch.removeChar(); iSearch.removeChar();
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'confirmSearch', name: 'confirmSearch',
bindKey: 'return', bindKey: 'return',
exec: function(iSearch) { iSearch.deactivate(); }, exec: function(iSearch) { iSearch.deactivate(); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'cancelSearch', name: 'cancelSearch',
bindKey: 'esc|Ctrl-G', bindKey: 'esc|Ctrl-G',
exec: function(iSearch) { iSearch.deactivate(true); }, exec: function(iSearch) { iSearch.deactivate(true); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'occurisearch', name: 'occurisearch',
bindKey: 'Ctrl-O', bindKey: 'Ctrl-O',
@ -131,9 +115,7 @@ exports.iSearchCommands = [{
var options = oop.mixin({}, iSearch.$options); var options = oop.mixin({}, iSearch.$options);
iSearch.deactivate(); iSearch.deactivate();
occurStartCommand.exec(iSearch.$editor, options); occurStartCommand.exec(iSearch.$editor, options);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "yankNextWord", name: "yankNextWord",
bindKey: "Ctrl-w", bindKey: "Ctrl-w",
@ -142,9 +124,7 @@ exports.iSearchCommands = [{
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }), range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
string = ed.session.getTextRange(range); string = ed.session.getTextRange(range);
iSearch.addString(string); iSearch.addString(string);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "yankNextChar", name: "yankNextChar",
bindKey: "Ctrl-Alt-y", bindKey: "Ctrl-Alt-y",
@ -153,15 +133,11 @@ exports.iSearchCommands = [{
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }), range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
string = ed.session.getTextRange(range); string = ed.session.getTextRange(range);
iSearch.addString(string); iSearch.addString(string);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'recenterTopBottom', name: 'recenterTopBottom',
bindKey: 'Ctrl-l', bindKey: 'Ctrl-l',
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }, exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'selectAllMatches', name: 'selectAllMatches',
bindKey: 'Ctrl-space', bindKey: 'Ctrl-space',
@ -173,18 +149,19 @@ exports.iSearchCommands = [{
return ranges.concat(ea ? ea : []); }, []) : []; return ranges.concat(ea ? ea : []); }, []) : [];
iSearch.deactivate(false); iSearch.deactivate(false);
ranges.forEach(ed.selection.addRange.bind(ed.selection)); ranges.forEach(ed.selection.addRange.bind(ed.selection));
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'searchAsRegExp', name: 'searchAsRegExp',
bindKey: 'Alt-r', bindKey: 'Alt-r',
exec: function(iSearch) { exec: function(iSearch) {
iSearch.convertNeedleToRegExp(); iSearch.convertNeedleToRegExp();
}, }
readOnly: true, }].map(function(cmd) {
isIncrementalSearchCommand: true cmd.readOnly = true;
}]; cmd.isIncrementalSearchCommand = true;
cmd.scrollIntoView = "animate-cursor";
return cmd;
});
function IncrementalSearchKeyboardHandler(iSearch) { function IncrementalSearchKeyboardHandler(iSearch) {
this.$iSearch = iSearch; this.$iSearch = iSearch;
@ -192,7 +169,7 @@ function IncrementalSearchKeyboardHandler(iSearch) {
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
;(function() { (function() {
this.attach = function(editor) { this.attach = function(editor) {
var iSearch = this.$iSearch; var iSearch = this.$iSearch;
@ -201,15 +178,19 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (!e.command.isIncrementalSearchCommand) return undefined; if (!e.command.isIncrementalSearchCommand) return undefined;
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
return e.command.exec(iSearch, e.args || {}); var scrollTop = editor.session.getScrollTop();
var result = e.command.exec(iSearch, e.args || {});
editor.renderer.scrollCursorIntoView(null, 0.5);
editor.renderer.animateScrolling(scrollTop);
return result;
}); });
} };
this.detach = function(editor) { this.detach = function(editor) {
if (!this.$commandExecHandler) return; if (!this.$commandExecHandler) return;
editor.commands.removeEventListener('exec', this.$commandExecHandler); editor.commands.removeEventListener('exec', this.$commandExecHandler);
delete this.$commandExecHandler; delete this.$commandExecHandler;
} };
var handleKeyboard$super = this.handleKeyboard; var handleKeyboard$super = this.handleKeyboard;
this.handleKeyboard = function(data, hashId, key, keyCode) { this.handleKeyboard = function(data, hashId, key, keyCode) {
@ -222,7 +203,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (extendCmd) { return {command: extendCmd, args: key}; } if (extendCmd) { return {command: extendCmd, args: key}; }
} }
return {command: "null", passEvent: hashId == 0 || hashId == 4}; return {command: "null", passEvent: hashId == 0 || hashId == 4};
} };
}).call(IncrementalSearchKeyboardHandler.prototype); }).call(IncrementalSearchKeyboardHandler.prototype);

Wyświetl plik

@ -105,7 +105,7 @@ function objectToRegExp(obj) {
this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this)); this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
this.selectionFix(ed); this.selectionFix(ed);
this.statusMessage(true); this.statusMessage(true);
} };
this.deactivate = function(reset) { this.deactivate = function(reset) {
this.cancelSearch(reset); this.cancelSearch(reset);
@ -117,7 +117,7 @@ function objectToRegExp(obj) {
} }
ed.onPaste = this.$originalEditorOnPaste; ed.onPaste = this.$originalEditorOnPaste;
this.message(''); this.message('');
} };
this.selectionFix = function(editor) { this.selectionFix = function(editor) {
// Fix selection bug: When clicked inside the editor // Fix selection bug: When clicked inside the editor
@ -128,7 +128,7 @@ function objectToRegExp(obj) {
if (editor.selection.isEmpty() && !editor.session.$emacsMark) { if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
editor.clearSelection(); editor.clearSelection();
} }
} };
this.highlight = function(regexp) { this.highlight = function(regexp) {
var sess = this.$editor.session, var sess = this.$editor.session,
@ -136,7 +136,7 @@ function objectToRegExp(obj) {
new SearchHighlight(null, "ace_isearch-result", "text")); new SearchHighlight(null, "ace_isearch-result", "text"));
hl.setRegexp(regexp); hl.setRegexp(regexp);
sess._emit("changeBackMarker"); // force highlight layer redraw sess._emit("changeBackMarker"); // force highlight layer redraw
} };
this.cancelSearch = function(reset) { this.cancelSearch = function(reset) {
var e = this.$editor; var e = this.$editor;
@ -150,7 +150,7 @@ function objectToRegExp(obj) {
} }
this.highlight(null); this.highlight(null);
return Range.fromPoints(this.$currentPos, this.$currentPos); return Range.fromPoints(this.$currentPos, this.$currentPos);
} };
this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) { this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
if (!this.$editor) return null; if (!this.$editor) return null;
@ -163,7 +163,7 @@ function objectToRegExp(obj) {
if (options.needle.length === 0) { if (options.needle.length === 0) {
this.statusMessage(true); this.statusMessage(true);
return this.cancelSearch(true); return this.cancelSearch(true);
}; }
// try to find the next occurence and enable highlighting marker // try to find the next occurence and enable highlighting marker
options.start = this.$currentPos; options.start = this.$currentPos;
@ -176,13 +176,13 @@ function objectToRegExp(obj) {
this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end)); this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
if (moveToNext) this.$currentPos = found.end; if (moveToNext) this.$currentPos = found.end;
// highlight after cursor move, so selection works properly // highlight after cursor move, so selection works properly
this.highlight(options.re) this.highlight(options.re);
} }
this.statusMessage(found); this.statusMessage(found);
return found; return found;
} };
this.addString = function(s) { this.addString = function(s) {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
@ -192,7 +192,7 @@ function objectToRegExp(obj) {
reObj.expression += s; reObj.expression += s;
return objectToRegExp(reObj); return objectToRegExp(reObj);
}); });
} };
this.removeChar = function(c) { this.removeChar = function(c) {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
@ -202,7 +202,7 @@ function objectToRegExp(obj) {
reObj.expression = reObj.expression.substring(0, reObj.expression.length-1); reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
return objectToRegExp(reObj); return objectToRegExp(reObj);
}); });
} };
this.next = function(options) { this.next = function(options) {
// try to find the next occurence of whatever we have searched for // try to find the next occurence of whatever we have searched for
@ -215,29 +215,29 @@ function objectToRegExp(obj) {
return options.useCurrentOrPrevSearch && needle.length === 0 ? return options.useCurrentOrPrevSearch && needle.length === 0 ?
this.$prevNeedle || '' : needle; this.$prevNeedle || '' : needle;
}); });
} };
this.onMouseDown = function(evt) { this.onMouseDown = function(evt) {
// when mouse interaction happens then we quit incremental search // when mouse interaction happens then we quit incremental search
this.deactivate(); this.deactivate();
return true; return true;
} };
this.onPaste = function(text) { this.onPaste = function(text) {
this.addString(text); this.addString(text);
} };
this.convertNeedleToRegExp = function() { this.convertNeedleToRegExp = function() {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig'); return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
}); });
} };
this.convertNeedleToString = function() { this.convertNeedleToString = function() {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
return isRegExp(needle) ? regExpToObject(needle).expression : needle; return isRegExp(needle) ? regExpToObject(needle).expression : needle;
}); });
} };
this.statusMessage = function(found) { this.statusMessage = function(found) {
var options = this.$options, msg = ''; var options = this.$options, msg = '';
@ -245,7 +245,7 @@ function objectToRegExp(obj) {
msg += 'isearch: ' + options.needle; msg += 'isearch: ' + options.needle;
msg += found ? '' : ' (not found)'; msg += found ? '' : ' (not found)';
this.message(msg); this.message(msg);
} };
this.message = function(msg) { this.message = function(msg) {
if (this.$editor.showCommandLine) { if (this.$editor.showCommandLine) {
@ -254,7 +254,7 @@ function objectToRegExp(obj) {
} else { } else {
console.log(msg); console.log(msg);
} }
} };
}).call(IncrementalSearch.prototype); }).call(IncrementalSearch.prototype);

Wyświetl plik

@ -428,7 +428,7 @@ exports.emacsKeys = {
"M-;": "togglecomment", "M-;": "togglecomment",
"C-/|C-x u|S-C--|C-z": "undo", "C-/|C-x u|S-C--|C-z": "undo",
"S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo? "S-C-/|S-C-x u|C--|S-C-z": "redo", // infinite undo?
// vertical editing // vertical editing
"C-x r": "selectRectangularRegion", "C-x r": "selectRectangularRegion",
"M-x": {command: "focusCommandLine", args: "M-x "} "M-x": {command: "focusCommandLine", args: "M-x "}
@ -483,7 +483,7 @@ exports.handler.addCommands({
// different. Deactivate the mark when setMark is run with active // different. Deactivate the mark when setMark is run with active
// mark // mark
if (transientMarkModeActive && (mark || !hasNoSelection)) { if (transientMarkModeActive && (mark || !hasNoSelection)) {
if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)}) if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)});
else editor.clearSelection(); else editor.clearSelection();
if (mark) editor.pushEmacsMark(null); if (mark) editor.pushEmacsMark(null);
return; return;

Wyświetl plik

@ -236,10 +236,18 @@ MultiHashHandler.prototype = HashHandler.prototype;
} }
} }
if (data.$keyChain && keyCode > 0) if (data.$keyChain) {
data.$keyChain = ""; if ((!hashId || hashId == 4) && keyString.length == 1)
data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
else if (hashId == -1 || keyCode > 0)
data.$keyChain = ""; // reset keyChain
}
return {command: command}; return {command: command};
}; };
this.getStatusText = function(editor, data) {
return data.$keyChain || "";
};
}).call(HashHandler.prototype); }).call(HashHandler.prototype);

Wyświetl plik

@ -68,7 +68,7 @@
"c9.ide.run.debug": "#36245ee2aa", "c9.ide.run.debug": "#36245ee2aa",
"c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.emmet": "#e5f1a92ac3",
"c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.gotoline": "#4d1a93172c",
"c9.ide.ace.keymaps": "#2477fd8ac6", "c9.ide.ace.keymaps": "#6c4bb65b1f",
"c9.ide.ace.repl": "#ada99852fa", "c9.ide.ace.repl": "#ada99852fa",
"c9.ide.ace.split": "#0ae0151c78", "c9.ide.ace.split": "#0ae0151c78",
"c9.ide.ace.statusbar": "#d7b45bb7c3", "c9.ide.ace.statusbar": "#d7b45bb7c3",

Wyświetl plik

@ -614,6 +614,17 @@ define(function(require, exports, module) {
settings.set("user/ace/@fontSize", --currSize < 1 ? 1 : currSize); settings.set("user/ace/@fontSize", --currSize < 1 ? 1 : currSize);
} }
}), handle); }), handle);
commands.addCommand({
name: "toggleWordWrap",
bindKey: {win: "Ctrl-Q", mac: "Ctrl-W"},
exec: function(editor) {
editor.setOption("wrap", editor.getOption("wrap") == "off");
},
isAvailable: function(editor) {
return editor && editor.type == "ace";
}
}, handle);
} }
/***** Preferences *****/ /***** Preferences *****/

Wyświetl plik

@ -326,7 +326,6 @@ define(function(require, exports, module) {
commands.find, commands.find,
commands.openterminal, commands.openterminal,
commands.navigate, commands.navigate,
commands.navigate_altkey,
commands.searchinfiles, commands.searchinfiles,
commands.close_term_pane, commands.close_term_pane,
commands.closeallbutme, commands.closeallbutme,

Wyświetl plik

@ -1,4 +1,5 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var isWindows = require("ace/lib/useragent").isWindows;
module.exports = function initInput(ace) { module.exports = function initInput(ace) {
var HashHandler = require("ace/keyboard/hash_handler").HashHandler; var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
var KEY_MODS = require("ace/lib/keys").KEY_MODS; var KEY_MODS = require("ace/lib/keys").KEY_MODS;
@ -156,6 +157,9 @@ define(function(require, exports, module) {
passEvent: !hashId || hashId === KEY_MODS.shift || ( passEvent: !hashId || hashId === KEY_MODS.shift || (
// on mac key combos without ctrl or cmd trigger textinput // on mac key combos without ctrl or cmd trigger textinput
specialKeys.platform === "mac" && !(hashId & (KEY_MODS.ctrl | KEY_MODS.cmd)) specialKeys.platform === "mac" && !(hashId & (KEY_MODS.ctrl | KEY_MODS.cmd))
) || (
// on windows 8+ calling preventDefault on win+space breaks textinput
specialKeys.platform === "win" && hashId == KEY_MODS.cmd && (keyCode == 32 || keyCode == -1)
) )
}; };
}; };

Wyświetl plik

@ -12,18 +12,19 @@ define(function(require, exports, module) {
var c9 = imports.c9; var c9 = imports.c9;
var util = imports.util; var util = imports.util;
var Panel = imports.Panel; var Panel = imports.Panel;
var fs = imports.fs;
var panels = imports.panels; var panels = imports.panels;
var settings = imports.settings; var settings = imports.settings;
var layout = imports.layout; var fs = imports.fs;
var ui = imports.ui; var ui = imports.ui;
var menus = imports.menus;
var tabs = imports.tabManager; var tabs = imports.tabManager;
var menus = imports.menus;
var layout = imports.layout;
var clipboard = imports.clipboard; var clipboard = imports.clipboard;
var commands = imports.commands;
var watcher = imports.watcher; var watcher = imports.watcher;
var prefs = imports.preferences; var prefs = imports.preferences;
var fsCache = imports["fs.cache"];
var alert = imports["dialog.alert"].show; var alert = imports["dialog.alert"].show;
var fsCache = imports["fs.cache"];
var confirmRemove = imports["dialog.fileremove"].show; var confirmRemove = imports["dialog.fileremove"].show;
var confirmRename = imports["dialog.fileoverwrite"].show; var confirmRename = imports["dialog.fileoverwrite"].show;
var showError = imports["dialog.error"].show; var showError = imports["dialog.error"].show;
@ -99,6 +100,15 @@ define(function(require, exports, module) {
if (panels.isActive("tree")) if (panels.isActive("tree"))
tree && tree.resize(); tree && tree.resize();
}); });
commands.addCommand({
name: "focusTree",
// shortcut can be modified here
bindKey: { mac: "Shift-Esc", win: "Shift-Esc"},
exec: function() {
panels.activate("tree");
plugin.focus();
}
}, plugin);
// On Ready Resize initially // On Ready Resize initially
c9.once("ready", function(){ tree && tree.resize(); }); c9.once("ready", function(){ tree && tree.resize(); });