remove dependency on canon
This commit is contained in:
parent
b02541a98b
commit
18ab9b4193
13 changed files with 159 additions and 122 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,6 +1,3 @@
|
|||
[submodule "support/cockpit"]
|
||||
path = support/cockpit
|
||||
url = git://github.com/ajaxorg/cockpit.git
|
||||
[submodule "support/pilot"]
|
||||
path = support/pilot
|
||||
url = git://github.com/ajaxorg/pilot.git
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ function demo() {
|
|||
source: [
|
||||
copy.source.commonjs({
|
||||
project: project,
|
||||
require: [ "pilot/index", "ace/defaults", "demo/boot" ]
|
||||
require: [ "demo/boot" ]
|
||||
})
|
||||
],
|
||||
filter: [ copy.filter.moduleDefines ],
|
||||
|
|
@ -370,4 +370,4 @@ function demo() {
|
|||
source: demo,
|
||||
dest: 'build/demo/kitchen-sink-uncompressed.js'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@
|
|||
var require = window.__ace_shadowed__.require;
|
||||
|
||||
require("pilot/index");
|
||||
var catalog = require("pilot/plugin_manager").catalog;
|
||||
catalog.registerPlugins([ "pilot/index" ]);
|
||||
|
||||
var Dom = require("pilot/dom");
|
||||
var Event = require("pilot/event");
|
||||
|
|
@ -53,9 +51,6 @@ var EditSession = require("ace/edit_session").EditSession;
|
|||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||
|
||||
var catalog = require("pilot/plugin_manager").catalog;
|
||||
catalog.registerPlugins([ "pilot/index" ]);
|
||||
|
||||
window.__ace_shadowed__.edit = function(el) {
|
||||
if (typeof(el) == "string") {
|
||||
el = document.getElementById(el);
|
||||
|
|
@ -68,16 +63,14 @@ window.__ace_shadowed__.edit = function(el) {
|
|||
var editor = new Editor(new Renderer(el, "ace/theme/textmate"));
|
||||
editor.setSession(doc);
|
||||
|
||||
var env = require("pilot/environment").create();
|
||||
catalog.startupPlugins({ env: env }).then(function() {
|
||||
env.document = doc;
|
||||
env.editor = env;
|
||||
var env = {};
|
||||
env.document = doc;
|
||||
env.editor = env;
|
||||
editor.resize();
|
||||
Event.addListener(window, "resize", function() {
|
||||
editor.resize();
|
||||
Event.addListener(window, "resize", function() {
|
||||
editor.resize();
|
||||
});
|
||||
el.env = env;
|
||||
});
|
||||
el.env = env;
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
|
|
|||
21
demo/boot.js
21
demo/boot.js
|
|
@ -35,23 +35,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
require("pilot/fixoldbrowsers");
|
||||
require("pilot/plugin_manager");
|
||||
require("pilot/environment");
|
||||
require("demo/demo");
|
||||
|
||||
require("pilot/index");
|
||||
require("ace/defaults");
|
||||
|
||||
var plugins = [ "pilot/index"];
|
||||
var catalog = require("pilot/plugin_manager").catalog;
|
||||
catalog.registerPlugins(plugins).then(function() {
|
||||
var env = require("pilot/environment").create();
|
||||
catalog.startupPlugins({ env: env }).then(function() {
|
||||
require("demo/demo").launch(env);
|
||||
});
|
||||
});
|
||||
|
||||
require([ "pilot/fixoldbrowsers", "demo/demo" ], function() {
|
||||
require("demo/demo").launch({});
|
||||
});
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
exports.launch = function(env) {
|
||||
var canon = require("pilot/canon");
|
||||
var commands = require("ace/commands/command_manager");
|
||||
var event = require("pilot/event");
|
||||
var Range = require("ace/range").Range;
|
||||
var Editor = require("ace/editor").Editor;
|
||||
|
|
@ -189,7 +189,6 @@ exports.launch = function(env) {
|
|||
}
|
||||
|
||||
var container = document.getElementById("editor");
|
||||
var cockpitInput = document.getElementById("cockpitInput");
|
||||
|
||||
// Splitting.
|
||||
var Split = require("ace/split").Split;
|
||||
|
|
@ -555,7 +554,7 @@ exports.launch = function(env) {
|
|||
*/
|
||||
|
||||
// Fake-Save, works from the editor and the command line.
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "save",
|
||||
bindKey: {
|
||||
win: "Ctrl-S",
|
||||
|
|
@ -586,7 +585,7 @@ exports.launch = function(env) {
|
|||
}
|
||||
});
|
||||
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "fold",
|
||||
bindKey: {
|
||||
win: "Alt-L",
|
||||
|
|
@ -598,7 +597,7 @@ exports.launch = function(env) {
|
|||
}
|
||||
});
|
||||
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "unfold",
|
||||
bindKey: {
|
||||
win: "Alt-Shift-L",
|
||||
|
|
|
|||
|
|
@ -124,4 +124,4 @@
|
|||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
@ -39,8 +39,6 @@ define(function(require, exports, module) {
|
|||
|
||||
require("pilot/index");
|
||||
require("pilot/fixoldbrowsers");
|
||||
var catalog = require("pilot/plugin_manager").catalog;
|
||||
catalog.registerPlugins([ "pilot/index" ]);
|
||||
|
||||
var Dom = require("pilot/dom");
|
||||
var Event = require("pilot/event");
|
||||
|
|
@ -62,16 +60,14 @@ define(function(require, exports, module) {
|
|||
var editor = new Editor(new Renderer(el, require("ace/theme/textmate")));
|
||||
editor.setSession(doc);
|
||||
|
||||
var env = require("pilot/environment").create();
|
||||
catalog.startupPlugins({ env: env }).then(function() {
|
||||
env.document = doc;
|
||||
env.editor = editor;
|
||||
var env = {};
|
||||
env.document = doc;
|
||||
env.editor = editor;
|
||||
editor.resize();
|
||||
Event.addListener(window, "resize", function() {
|
||||
editor.resize();
|
||||
Event.addListener(window, "resize", function() {
|
||||
editor.resize();
|
||||
});
|
||||
el.env = env;
|
||||
});
|
||||
el.env = env;
|
||||
// Store env on editor such that it can be accessed later on from
|
||||
// the returned object.
|
||||
editor.env = env;
|
||||
|
|
|
|||
72
lib/ace/commands/command_manager.js
Normal file
72
lib/ace/commands/command_manager.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var keyUtil = require('pilot/keys');
|
||||
var useragent = require('pilot/useragent');
|
||||
|
||||
var commands = {};
|
||||
var commmandKeyBinding = {};
|
||||
|
||||
exports.addCommand = function(command) {
|
||||
commands[command.name] = command;
|
||||
|
||||
if (command.bindKey) {
|
||||
buildKeyHash(command);
|
||||
}
|
||||
};
|
||||
|
||||
var platform = useragent.isMac ? "mac" : "win";
|
||||
function buildKeyHash(command) {
|
||||
var binding = command.bindKey;
|
||||
var key = binding[platform];
|
||||
var ckb = commmandKeyBinding;
|
||||
|
||||
if(!binding[platform]) {
|
||||
return;
|
||||
}
|
||||
|
||||
key.split("|").forEach(function(keyPart) {
|
||||
var binding = parseKeys(keyPart, command);
|
||||
var hashId = binding.hashId;
|
||||
(ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
|
||||
});
|
||||
}
|
||||
|
||||
function parseKeys(keys, val, ret) {
|
||||
var key;
|
||||
var hashId = 0;
|
||||
var parts = splitSafe(keys, "\\-", null, true);
|
||||
|
||||
for (var i=0, l = parts.length; i < l; i++) {
|
||||
if (keyUtil.KEY_MODS[parts[i]])
|
||||
hashId = hashId | keyUtil.KEY_MODS[parts[i]];
|
||||
else
|
||||
key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
|
||||
}
|
||||
|
||||
return {
|
||||
key: key,
|
||||
hashId: hashId
|
||||
}
|
||||
}
|
||||
|
||||
function splitSafe(s, separator, limit, bLowerCase) {
|
||||
return (bLowerCase && s.toLowerCase() || s)
|
||||
.replace(/(?:^\s+|\n|\s+$)/g, "")
|
||||
.split(new RegExp("[\\s ]*" + separator + "[\\s ]*", "g"), limit || 999);
|
||||
}
|
||||
|
||||
exports.findKeyCommand = function findKeyCommand(env, hashId, textOrKey) {
|
||||
// Convert keyCode to the string representation.
|
||||
if (typeof textOrKey == "number") {
|
||||
textOrKey = keyUtil.keyCodeToString(textOrKey);
|
||||
}
|
||||
|
||||
var ckbr = commmandKeyBinding;
|
||||
return ckbr[hashId] && ckbr[hashId][textOrKey];
|
||||
}
|
||||
|
||||
exports.exec = function(command, env, args) {
|
||||
command.exec(env, args || {});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var lang = require("pilot/lang");
|
||||
var canon = require("pilot/canon");
|
||||
var commands = require("ace/commands/command_manager");
|
||||
|
||||
function bindKey(win, mac) {
|
||||
return {
|
||||
|
|
@ -51,22 +51,22 @@ function bindKey(win, mac) {
|
|||
};
|
||||
}
|
||||
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "null",
|
||||
exec: function(env, args, request) { }
|
||||
});
|
||||
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectall",
|
||||
bindKey: bindKey("Ctrl-A", "Command-A"),
|
||||
exec: function(env, args, request) { env.editor.selectAll(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "removeline",
|
||||
bindKey: bindKey("Ctrl-D", "Command-D"),
|
||||
exec: function(env, args, request) { env.editor.removeLines(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotoline",
|
||||
bindKey: bindKey("Ctrl-L", "Command-L"),
|
||||
exec: function(env, args, request) {
|
||||
|
|
@ -76,22 +76,22 @@ canon.addCommand({
|
|||
}
|
||||
}
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "togglecomment",
|
||||
bindKey: bindKey("Ctrl-7", "Command-7"),
|
||||
exec: function(env, args, request) { env.editor.toggleCommentLines(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "findnext",
|
||||
bindKey: bindKey("Ctrl-K", "Command-G"),
|
||||
exec: function(env, args, request) { env.editor.findNext(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "findprevious",
|
||||
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
|
||||
exec: function(env, args, request) { env.editor.findPrevious(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "find",
|
||||
bindKey: bindKey("Ctrl-F", "Command-F"),
|
||||
exec: function(env, args, request) {
|
||||
|
|
@ -99,7 +99,7 @@ canon.addCommand({
|
|||
env.editor.find(needle);
|
||||
}
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "replace",
|
||||
bindKey: bindKey("Ctrl-R", "Command-Option-F"),
|
||||
exec: function(env, args, request) {
|
||||
|
|
@ -112,7 +112,7 @@ canon.addCommand({
|
|||
env.editor.replace(replacement, {needle: needle});
|
||||
}
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "replaceall",
|
||||
bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"),
|
||||
exec: function(env, args, request) {
|
||||
|
|
@ -125,187 +125,187 @@ canon.addCommand({
|
|||
env.editor.replaceAll(replacement, {needle: needle});
|
||||
}
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "undo",
|
||||
bindKey: bindKey("Ctrl-Z", "Command-Z"),
|
||||
exec: function(env, args, request) { env.editor.undo(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "redo",
|
||||
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
|
||||
exec: function(env, args, request) { env.editor.redo(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "overwrite",
|
||||
bindKey: bindKey("Insert", "Insert"),
|
||||
exec: function(env, args, request) { env.editor.toggleOverwrite(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "copylinesup",
|
||||
bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"),
|
||||
exec: function(env, args, request) { env.editor.copyLinesUp(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "movelinesup",
|
||||
bindKey: bindKey("Alt-Up", "Option-Up"),
|
||||
exec: function(env, args, request) { env.editor.moveLinesUp(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selecttostart",
|
||||
bindKey: bindKey("Ctrl-Shift-Home|Alt-Shift-Up", "Command-Shift-Up"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectFileStart(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotostart",
|
||||
bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"),
|
||||
exec: function(env, args, request) { env.editor.navigateFileStart(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectup",
|
||||
bindKey: bindKey("Shift-Up", "Shift-Up"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectUp(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "golineup",
|
||||
bindKey: bindKey("Up", "Up|Ctrl-P"),
|
||||
exec: function(env, args, request) { env.editor.navigateUp(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "copylinesdown",
|
||||
bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"),
|
||||
exec: function(env, args, request) { env.editor.copyLinesDown(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "movelinesdown",
|
||||
bindKey: bindKey("Alt-Down", "Option-Down"),
|
||||
exec: function(env, args, request) { env.editor.moveLinesDown(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selecttoend",
|
||||
bindKey: bindKey("Ctrl-Shift-End|Alt-Shift-Down", "Command-Shift-Down"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectFileEnd(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotoend",
|
||||
bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"),
|
||||
exec: function(env, args, request) { env.editor.navigateFileEnd(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectdown",
|
||||
bindKey: bindKey("Shift-Down", "Shift-Down"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectDown(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "golinedown",
|
||||
bindKey: bindKey("Down", "Down|Ctrl-N"),
|
||||
exec: function(env, args, request) { env.editor.navigateDown(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectwordleft",
|
||||
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectWordLeft(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotowordleft",
|
||||
bindKey: bindKey("Ctrl-Left", "Option-Left"),
|
||||
exec: function(env, args, request) { env.editor.navigateWordLeft(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selecttolinestart",
|
||||
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotolinestart",
|
||||
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
|
||||
exec: function(env, args, request) { env.editor.navigateLineStart(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectleft",
|
||||
bindKey: bindKey("Shift-Left", "Shift-Left"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectLeft(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotoleft",
|
||||
bindKey: bindKey("Left", "Left|Ctrl-B"),
|
||||
exec: function(env, args, request) { env.editor.navigateLeft(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectwordright",
|
||||
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectWordRight(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotowordright",
|
||||
bindKey: bindKey("Ctrl-Right", "Option-Right"),
|
||||
exec: function(env, args, request) { env.editor.navigateWordRight(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selecttolineend",
|
||||
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotolineend",
|
||||
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
|
||||
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectright",
|
||||
bindKey: bindKey("Shift-Right", "Shift-Right"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectRight(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotoright",
|
||||
bindKey: bindKey("Right", "Right|Ctrl-F"),
|
||||
exec: function(env, args, request) { env.editor.navigateRight(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectpagedown",
|
||||
bindKey: bindKey("Shift-PageDown", "Shift-PageDown"),
|
||||
exec: function(env, args, request) { env.editor.selectPageDown(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "pagedown",
|
||||
bindKey: bindKey(null, "PageDown"),
|
||||
exec: function(env, args, request) { env.editor.scrollPageDown(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotopagedown",
|
||||
bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"),
|
||||
exec: function(env, args, request) { env.editor.gotoPageDown(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectpageup",
|
||||
bindKey: bindKey("Shift-PageUp", "Shift-PageUp"),
|
||||
exec: function(env, args, request) { env.editor.selectPageUp(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "pageup",
|
||||
bindKey: bindKey(null, "PageUp"),
|
||||
exec: function(env, args, request) { env.editor.scrollPageUp(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "gotopageup",
|
||||
bindKey: bindKey("PageUp", "Option-PageUp"),
|
||||
exec: function(env, args, request) { env.editor.gotoPageUp(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectlinestart",
|
||||
bindKey: bindKey("Shift-Home", "Shift-Home"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "selectlineend",
|
||||
bindKey: bindKey("Shift-End", "Shift-End"),
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "del",
|
||||
bindKey: bindKey("Delete", "Delete|Ctrl-D"),
|
||||
exec: function(env, args, request) { env.editor.removeRight(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "backspace",
|
||||
bindKey: bindKey(
|
||||
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
|
||||
|
|
@ -313,53 +313,53 @@ canon.addCommand({
|
|||
),
|
||||
exec: function(env, args, request) { env.editor.removeLeft(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "removetolinestart",
|
||||
bindKey: bindKey(null, "Option-Backspace"),
|
||||
exec: function(env, args, request) { env.editor.removeToLineStart(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "removetolineend",
|
||||
bindKey: bindKey(null, "Ctrl-K"),
|
||||
exec: function(env, args, request) { env.editor.removeToLineEnd(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "removewordleft",
|
||||
bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
|
||||
exec: function(env, args, request) { env.editor.removeWordLeft(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "removewordright",
|
||||
bindKey: bindKey(null, "Alt-Delete"),
|
||||
exec: function(env, args, request) { env.editor.removeWordRight(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "outdent",
|
||||
bindKey: bindKey("Shift-Tab", "Shift-Tab"),
|
||||
exec: function(env, args, request) { env.editor.blockOutdent(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "indent",
|
||||
bindKey: bindKey("Tab", "Tab"),
|
||||
exec: function(env, args, request) { env.editor.indent(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "inserttext",
|
||||
exec: function(env, args, request) {
|
||||
env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
|
||||
}
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "centerselection",
|
||||
bindKey: bindKey(null, "Ctrl-L"),
|
||||
exec: function(env, args, request) { env.editor.centerSelection(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "splitline",
|
||||
bindKey: bindKey(null, "Ctrl-O"),
|
||||
exec: function(env, args, request) { env.editor.splitLine(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
commands.addCommand({
|
||||
name: "transposeletters",
|
||||
bindKey: bindKey("Ctrl-T", "Ctrl-T"),
|
||||
exec: function(env, args, request) { env.editor.transposeLetters(); }
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ define(function(require, exports, module) {
|
|||
var useragent = require("pilot/useragent");
|
||||
var keyUtil = require("pilot/keys");
|
||||
var event = require("pilot/event");
|
||||
var settings = require("pilot/settings").settings;
|
||||
var canon = require("pilot/canon");
|
||||
var commands = require("ace/commands/command_manager");
|
||||
require("ace/commands/default_commands");
|
||||
|
||||
var KeyBinding = function(editor) {
|
||||
|
|
@ -76,7 +75,7 @@ var KeyBinding = function(editor) {
|
|||
if (!toExecute || !toExecute.command) {
|
||||
if (hashId != 0 || keyCode != 0) {
|
||||
toExecute = {
|
||||
command: canon.findKeyCommand(env, "editor", hashId, keyOrText)
|
||||
command: commands.findKeyCommand(env, hashId, keyOrText)
|
||||
}
|
||||
} else {
|
||||
toExecute = {
|
||||
|
|
@ -89,9 +88,11 @@ var KeyBinding = function(editor) {
|
|||
}
|
||||
|
||||
var success = false;
|
||||
if (toExecute) {
|
||||
success = canon.exec(toExecute.command,
|
||||
env, "editor", toExecute.args);
|
||||
if (toExecute && toExecute.command) {
|
||||
success = commands.exec(
|
||||
toExecute.command,
|
||||
env, toExecute.args
|
||||
);
|
||||
if (success) {
|
||||
event.stopEvent(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@
|
|||
<script type="text/javascript">
|
||||
var require = {
|
||||
paths: {
|
||||
ace: "../",
|
||||
cockpit: "../../../../support/cockpit/lib/cockpit",
|
||||
pilot: "../../../../support/pilot/lib/pilot"
|
||||
ace: "../"
|
||||
},
|
||||
packages : [{
|
||||
name: "asyncjs",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
"directories": {
|
||||
"lib": "lib/ace",
|
||||
"dependencies": {
|
||||
"cockpit": ">=0.1.1",
|
||||
"pilot": ">=0.1.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit c88bbc33e6d8c9d72f2687658648a69b7420e0ba
|
||||
Loading…
Add table
Add a link
Reference in a new issue