remove dependency on canon

This commit is contained in:
Fabian Jakobs 2011-07-23 12:32:30 +02:00
commit 18ab9b4193
13 changed files with 159 additions and 122 deletions

3
.gitmodules vendored
View file

@ -1,6 +1,3 @@
[submodule "support/cockpit"]
path = support/cockpit
url = git://github.com/ajaxorg/cockpit.git
[submodule "support/pilot"] [submodule "support/pilot"]
path = support/pilot path = support/pilot
url = git://github.com/ajaxorg/pilot.git url = git://github.com/ajaxorg/pilot.git

View file

@ -336,7 +336,7 @@ function demo() {
source: [ source: [
copy.source.commonjs({ copy.source.commonjs({
project: project, project: project,
require: [ "pilot/index", "ace/defaults", "demo/boot" ] require: [ "demo/boot" ]
}) })
], ],
filter: [ copy.filter.moduleDefines ], filter: [ copy.filter.moduleDefines ],
@ -370,4 +370,4 @@ function demo() {
source: demo, source: demo,
dest: 'build/demo/kitchen-sink-uncompressed.js' dest: 'build/demo/kitchen-sink-uncompressed.js'
}); });
} }

View file

@ -41,8 +41,6 @@
var require = window.__ace_shadowed__.require; var require = window.__ace_shadowed__.require;
require("pilot/index"); require("pilot/index");
var catalog = require("pilot/plugin_manager").catalog;
catalog.registerPlugins([ "pilot/index" ]);
var Dom = require("pilot/dom"); var Dom = require("pilot/dom");
var Event = require("pilot/event"); var Event = require("pilot/event");
@ -53,9 +51,6 @@ var EditSession = require("ace/edit_session").EditSession;
var UndoManager = require("ace/undomanager").UndoManager; var UndoManager = require("ace/undomanager").UndoManager;
var Renderer = require("ace/virtual_renderer").VirtualRenderer; var Renderer = require("ace/virtual_renderer").VirtualRenderer;
var catalog = require("pilot/plugin_manager").catalog;
catalog.registerPlugins([ "pilot/index" ]);
window.__ace_shadowed__.edit = function(el) { window.__ace_shadowed__.edit = function(el) {
if (typeof(el) == "string") { if (typeof(el) == "string") {
el = document.getElementById(el); el = document.getElementById(el);
@ -68,16 +63,14 @@ window.__ace_shadowed__.edit = function(el) {
var editor = new Editor(new Renderer(el, "ace/theme/textmate")); var editor = new Editor(new Renderer(el, "ace/theme/textmate"));
editor.setSession(doc); editor.setSession(doc);
var env = require("pilot/environment").create(); var env = {};
catalog.startupPlugins({ env: env }).then(function() { env.document = doc;
env.document = doc; env.editor = env;
env.editor = env; editor.resize();
Event.addListener(window, "resize", function() {
editor.resize(); editor.resize();
Event.addListener(window, "resize", function() {
editor.resize();
});
el.env = env;
}); });
el.env = env;
return editor; return editor;
} }

View file

@ -35,23 +35,6 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) { require([ "pilot/fixoldbrowsers", "demo/demo" ], function() {
require("demo/demo").launch({});
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);
});
});
}); });

View file

@ -41,7 +41,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
exports.launch = function(env) { exports.launch = function(env) {
var canon = require("pilot/canon"); var commands = require("ace/commands/command_manager");
var event = require("pilot/event"); var event = require("pilot/event");
var Range = require("ace/range").Range; var Range = require("ace/range").Range;
var Editor = require("ace/editor").Editor; var Editor = require("ace/editor").Editor;
@ -189,7 +189,6 @@ exports.launch = function(env) {
} }
var container = document.getElementById("editor"); var container = document.getElementById("editor");
var cockpitInput = document.getElementById("cockpitInput");
// Splitting. // Splitting.
var Split = require("ace/split").Split; var Split = require("ace/split").Split;
@ -555,7 +554,7 @@ exports.launch = function(env) {
*/ */
// Fake-Save, works from the editor and the command line. // Fake-Save, works from the editor and the command line.
canon.addCommand({ commands.addCommand({
name: "save", name: "save",
bindKey: { bindKey: {
win: "Ctrl-S", win: "Ctrl-S",
@ -586,7 +585,7 @@ exports.launch = function(env) {
} }
}); });
canon.addCommand({ commands.addCommand({
name: "fold", name: "fold",
bindKey: { bindKey: {
win: "Alt-L", win: "Alt-L",
@ -598,7 +597,7 @@ exports.launch = function(env) {
} }
}); });
canon.addCommand({ commands.addCommand({
name: "unfold", name: "unfold",
bindKey: { bindKey: {
win: "Alt-Shift-L", win: "Alt-Shift-L",

View file

@ -124,4 +124,4 @@
})(); })();
</script> </script>
</body> </body>
</html> </html>

View file

@ -39,8 +39,6 @@ define(function(require, exports, module) {
require("pilot/index"); require("pilot/index");
require("pilot/fixoldbrowsers"); require("pilot/fixoldbrowsers");
var catalog = require("pilot/plugin_manager").catalog;
catalog.registerPlugins([ "pilot/index" ]);
var Dom = require("pilot/dom"); var Dom = require("pilot/dom");
var Event = require("pilot/event"); 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"))); var editor = new Editor(new Renderer(el, require("ace/theme/textmate")));
editor.setSession(doc); editor.setSession(doc);
var env = require("pilot/environment").create(); var env = {};
catalog.startupPlugins({ env: env }).then(function() { env.document = doc;
env.document = doc; env.editor = editor;
env.editor = editor; editor.resize();
Event.addListener(window, "resize", function() {
editor.resize(); 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 // Store env on editor such that it can be accessed later on from
// the returned object. // the returned object.
editor.env = env; editor.env = env;

View 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 || {});
};
});

View file

@ -41,7 +41,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var lang = require("pilot/lang"); var lang = require("pilot/lang");
var canon = require("pilot/canon"); var commands = require("ace/commands/command_manager");
function bindKey(win, mac) { function bindKey(win, mac) {
return { return {
@ -51,22 +51,22 @@ function bindKey(win, mac) {
}; };
} }
canon.addCommand({ commands.addCommand({
name: "null", name: "null",
exec: function(env, args, request) { } exec: function(env, args, request) { }
}); });
canon.addCommand({ commands.addCommand({
name: "selectall", name: "selectall",
bindKey: bindKey("Ctrl-A", "Command-A"), bindKey: bindKey("Ctrl-A", "Command-A"),
exec: function(env, args, request) { env.editor.selectAll(); } exec: function(env, args, request) { env.editor.selectAll(); }
}); });
canon.addCommand({ commands.addCommand({
name: "removeline", name: "removeline",
bindKey: bindKey("Ctrl-D", "Command-D"), bindKey: bindKey("Ctrl-D", "Command-D"),
exec: function(env, args, request) { env.editor.removeLines(); } exec: function(env, args, request) { env.editor.removeLines(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotoline", name: "gotoline",
bindKey: bindKey("Ctrl-L", "Command-L"), bindKey: bindKey("Ctrl-L", "Command-L"),
exec: function(env, args, request) { exec: function(env, args, request) {
@ -76,22 +76,22 @@ canon.addCommand({
} }
} }
}); });
canon.addCommand({ commands.addCommand({
name: "togglecomment", name: "togglecomment",
bindKey: bindKey("Ctrl-7", "Command-7"), bindKey: bindKey("Ctrl-7", "Command-7"),
exec: function(env, args, request) { env.editor.toggleCommentLines(); } exec: function(env, args, request) { env.editor.toggleCommentLines(); }
}); });
canon.addCommand({ commands.addCommand({
name: "findnext", name: "findnext",
bindKey: bindKey("Ctrl-K", "Command-G"), bindKey: bindKey("Ctrl-K", "Command-G"),
exec: function(env, args, request) { env.editor.findNext(); } exec: function(env, args, request) { env.editor.findNext(); }
}); });
canon.addCommand({ commands.addCommand({
name: "findprevious", name: "findprevious",
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
exec: function(env, args, request) { env.editor.findPrevious(); } exec: function(env, args, request) { env.editor.findPrevious(); }
}); });
canon.addCommand({ commands.addCommand({
name: "find", name: "find",
bindKey: bindKey("Ctrl-F", "Command-F"), bindKey: bindKey("Ctrl-F", "Command-F"),
exec: function(env, args, request) { exec: function(env, args, request) {
@ -99,7 +99,7 @@ canon.addCommand({
env.editor.find(needle); env.editor.find(needle);
} }
}); });
canon.addCommand({ commands.addCommand({
name: "replace", name: "replace",
bindKey: bindKey("Ctrl-R", "Command-Option-F"), bindKey: bindKey("Ctrl-R", "Command-Option-F"),
exec: function(env, args, request) { exec: function(env, args, request) {
@ -112,7 +112,7 @@ canon.addCommand({
env.editor.replace(replacement, {needle: needle}); env.editor.replace(replacement, {needle: needle});
} }
}); });
canon.addCommand({ commands.addCommand({
name: "replaceall", name: "replaceall",
bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"), bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"),
exec: function(env, args, request) { exec: function(env, args, request) {
@ -125,187 +125,187 @@ canon.addCommand({
env.editor.replaceAll(replacement, {needle: needle}); env.editor.replaceAll(replacement, {needle: needle});
} }
}); });
canon.addCommand({ commands.addCommand({
name: "undo", name: "undo",
bindKey: bindKey("Ctrl-Z", "Command-Z"), bindKey: bindKey("Ctrl-Z", "Command-Z"),
exec: function(env, args, request) { env.editor.undo(); } exec: function(env, args, request) { env.editor.undo(); }
}); });
canon.addCommand({ commands.addCommand({
name: "redo", name: "redo",
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"), bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
exec: function(env, args, request) { env.editor.redo(); } exec: function(env, args, request) { env.editor.redo(); }
}); });
canon.addCommand({ commands.addCommand({
name: "overwrite", name: "overwrite",
bindKey: bindKey("Insert", "Insert"), bindKey: bindKey("Insert", "Insert"),
exec: function(env, args, request) { env.editor.toggleOverwrite(); } exec: function(env, args, request) { env.editor.toggleOverwrite(); }
}); });
canon.addCommand({ commands.addCommand({
name: "copylinesup", name: "copylinesup",
bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"), bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"),
exec: function(env, args, request) { env.editor.copyLinesUp(); } exec: function(env, args, request) { env.editor.copyLinesUp(); }
}); });
canon.addCommand({ commands.addCommand({
name: "movelinesup", name: "movelinesup",
bindKey: bindKey("Alt-Up", "Option-Up"), bindKey: bindKey("Alt-Up", "Option-Up"),
exec: function(env, args, request) { env.editor.moveLinesUp(); } exec: function(env, args, request) { env.editor.moveLinesUp(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selecttostart", name: "selecttostart",
bindKey: bindKey("Ctrl-Shift-Home|Alt-Shift-Up", "Command-Shift-Up"), bindKey: bindKey("Ctrl-Shift-Home|Alt-Shift-Up", "Command-Shift-Up"),
exec: function(env, args, request) { env.editor.getSelection().selectFileStart(); } exec: function(env, args, request) { env.editor.getSelection().selectFileStart(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotostart", name: "gotostart",
bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"), bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"),
exec: function(env, args, request) { env.editor.navigateFileStart(); } exec: function(env, args, request) { env.editor.navigateFileStart(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectup", name: "selectup",
bindKey: bindKey("Shift-Up", "Shift-Up"), bindKey: bindKey("Shift-Up", "Shift-Up"),
exec: function(env, args, request) { env.editor.getSelection().selectUp(); } exec: function(env, args, request) { env.editor.getSelection().selectUp(); }
}); });
canon.addCommand({ commands.addCommand({
name: "golineup", name: "golineup",
bindKey: bindKey("Up", "Up|Ctrl-P"), bindKey: bindKey("Up", "Up|Ctrl-P"),
exec: function(env, args, request) { env.editor.navigateUp(args.times); } exec: function(env, args, request) { env.editor.navigateUp(args.times); }
}); });
canon.addCommand({ commands.addCommand({
name: "copylinesdown", name: "copylinesdown",
bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"), bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"),
exec: function(env, args, request) { env.editor.copyLinesDown(); } exec: function(env, args, request) { env.editor.copyLinesDown(); }
}); });
canon.addCommand({ commands.addCommand({
name: "movelinesdown", name: "movelinesdown",
bindKey: bindKey("Alt-Down", "Option-Down"), bindKey: bindKey("Alt-Down", "Option-Down"),
exec: function(env, args, request) { env.editor.moveLinesDown(); } exec: function(env, args, request) { env.editor.moveLinesDown(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selecttoend", name: "selecttoend",
bindKey: bindKey("Ctrl-Shift-End|Alt-Shift-Down", "Command-Shift-Down"), bindKey: bindKey("Ctrl-Shift-End|Alt-Shift-Down", "Command-Shift-Down"),
exec: function(env, args, request) { env.editor.getSelection().selectFileEnd(); } exec: function(env, args, request) { env.editor.getSelection().selectFileEnd(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotoend", name: "gotoend",
bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"), bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"),
exec: function(env, args, request) { env.editor.navigateFileEnd(); } exec: function(env, args, request) { env.editor.navigateFileEnd(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectdown", name: "selectdown",
bindKey: bindKey("Shift-Down", "Shift-Down"), bindKey: bindKey("Shift-Down", "Shift-Down"),
exec: function(env, args, request) { env.editor.getSelection().selectDown(); } exec: function(env, args, request) { env.editor.getSelection().selectDown(); }
}); });
canon.addCommand({ commands.addCommand({
name: "golinedown", name: "golinedown",
bindKey: bindKey("Down", "Down|Ctrl-N"), bindKey: bindKey("Down", "Down|Ctrl-N"),
exec: function(env, args, request) { env.editor.navigateDown(args.times); } exec: function(env, args, request) { env.editor.navigateDown(args.times); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectwordleft", name: "selectwordleft",
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"), bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
exec: function(env, args, request) { env.editor.getSelection().selectWordLeft(); } exec: function(env, args, request) { env.editor.getSelection().selectWordLeft(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotowordleft", name: "gotowordleft",
bindKey: bindKey("Ctrl-Left", "Option-Left"), bindKey: bindKey("Ctrl-Left", "Option-Left"),
exec: function(env, args, request) { env.editor.navigateWordLeft(); } exec: function(env, args, request) { env.editor.navigateWordLeft(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selecttolinestart", name: "selecttolinestart",
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"), bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); } exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotolinestart", name: "gotolinestart",
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
exec: function(env, args, request) { env.editor.navigateLineStart(); } exec: function(env, args, request) { env.editor.navigateLineStart(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectleft", name: "selectleft",
bindKey: bindKey("Shift-Left", "Shift-Left"), bindKey: bindKey("Shift-Left", "Shift-Left"),
exec: function(env, args, request) { env.editor.getSelection().selectLeft(); } exec: function(env, args, request) { env.editor.getSelection().selectLeft(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotoleft", name: "gotoleft",
bindKey: bindKey("Left", "Left|Ctrl-B"), bindKey: bindKey("Left", "Left|Ctrl-B"),
exec: function(env, args, request) { env.editor.navigateLeft(args.times); } exec: function(env, args, request) { env.editor.navigateLeft(args.times); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectwordright", name: "selectwordright",
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"), bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
exec: function(env, args, request) { env.editor.getSelection().selectWordRight(); } exec: function(env, args, request) { env.editor.getSelection().selectWordRight(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotowordright", name: "gotowordright",
bindKey: bindKey("Ctrl-Right", "Option-Right"), bindKey: bindKey("Ctrl-Right", "Option-Right"),
exec: function(env, args, request) { env.editor.navigateWordRight(); } exec: function(env, args, request) { env.editor.navigateWordRight(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selecttolineend", name: "selecttolineend",
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"), bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); } exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotolineend", name: "gotolineend",
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"), bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
exec: function(env, args, request) { env.editor.navigateLineEnd(); } exec: function(env, args, request) { env.editor.navigateLineEnd(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectright", name: "selectright",
bindKey: bindKey("Shift-Right", "Shift-Right"), bindKey: bindKey("Shift-Right", "Shift-Right"),
exec: function(env, args, request) { env.editor.getSelection().selectRight(); } exec: function(env, args, request) { env.editor.getSelection().selectRight(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotoright", name: "gotoright",
bindKey: bindKey("Right", "Right|Ctrl-F"), bindKey: bindKey("Right", "Right|Ctrl-F"),
exec: function(env, args, request) { env.editor.navigateRight(args.times); } exec: function(env, args, request) { env.editor.navigateRight(args.times); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectpagedown", name: "selectpagedown",
bindKey: bindKey("Shift-PageDown", "Shift-PageDown"), bindKey: bindKey("Shift-PageDown", "Shift-PageDown"),
exec: function(env, args, request) { env.editor.selectPageDown(); } exec: function(env, args, request) { env.editor.selectPageDown(); }
}); });
canon.addCommand({ commands.addCommand({
name: "pagedown", name: "pagedown",
bindKey: bindKey(null, "PageDown"), bindKey: bindKey(null, "PageDown"),
exec: function(env, args, request) { env.editor.scrollPageDown(); } exec: function(env, args, request) { env.editor.scrollPageDown(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotopagedown", name: "gotopagedown",
bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"), bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"),
exec: function(env, args, request) { env.editor.gotoPageDown(); } exec: function(env, args, request) { env.editor.gotoPageDown(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectpageup", name: "selectpageup",
bindKey: bindKey("Shift-PageUp", "Shift-PageUp"), bindKey: bindKey("Shift-PageUp", "Shift-PageUp"),
exec: function(env, args, request) { env.editor.selectPageUp(); } exec: function(env, args, request) { env.editor.selectPageUp(); }
}); });
canon.addCommand({ commands.addCommand({
name: "pageup", name: "pageup",
bindKey: bindKey(null, "PageUp"), bindKey: bindKey(null, "PageUp"),
exec: function(env, args, request) { env.editor.scrollPageUp(); } exec: function(env, args, request) { env.editor.scrollPageUp(); }
}); });
canon.addCommand({ commands.addCommand({
name: "gotopageup", name: "gotopageup",
bindKey: bindKey("PageUp", "Option-PageUp"), bindKey: bindKey("PageUp", "Option-PageUp"),
exec: function(env, args, request) { env.editor.gotoPageUp(); } exec: function(env, args, request) { env.editor.gotoPageUp(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectlinestart", name: "selectlinestart",
bindKey: bindKey("Shift-Home", "Shift-Home"), bindKey: bindKey("Shift-Home", "Shift-Home"),
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); } exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
}); });
canon.addCommand({ commands.addCommand({
name: "selectlineend", name: "selectlineend",
bindKey: bindKey("Shift-End", "Shift-End"), bindKey: bindKey("Shift-End", "Shift-End"),
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); } exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
}); });
canon.addCommand({ commands.addCommand({
name: "del", name: "del",
bindKey: bindKey("Delete", "Delete|Ctrl-D"), bindKey: bindKey("Delete", "Delete|Ctrl-D"),
exec: function(env, args, request) { env.editor.removeRight(); } exec: function(env, args, request) { env.editor.removeRight(); }
}); });
canon.addCommand({ commands.addCommand({
name: "backspace", name: "backspace",
bindKey: bindKey( bindKey: bindKey(
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", "Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
@ -313,53 +313,53 @@ canon.addCommand({
), ),
exec: function(env, args, request) { env.editor.removeLeft(); } exec: function(env, args, request) { env.editor.removeLeft(); }
}); });
canon.addCommand({ commands.addCommand({
name: "removetolinestart", name: "removetolinestart",
bindKey: bindKey(null, "Option-Backspace"), bindKey: bindKey(null, "Option-Backspace"),
exec: function(env, args, request) { env.editor.removeToLineStart(); } exec: function(env, args, request) { env.editor.removeToLineStart(); }
}); });
canon.addCommand({ commands.addCommand({
name: "removetolineend", name: "removetolineend",
bindKey: bindKey(null, "Ctrl-K"), bindKey: bindKey(null, "Ctrl-K"),
exec: function(env, args, request) { env.editor.removeToLineEnd(); } exec: function(env, args, request) { env.editor.removeToLineEnd(); }
}); });
canon.addCommand({ commands.addCommand({
name: "removewordleft", name: "removewordleft",
bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
exec: function(env, args, request) { env.editor.removeWordLeft(); } exec: function(env, args, request) { env.editor.removeWordLeft(); }
}); });
canon.addCommand({ commands.addCommand({
name: "removewordright", name: "removewordright",
bindKey: bindKey(null, "Alt-Delete"), bindKey: bindKey(null, "Alt-Delete"),
exec: function(env, args, request) { env.editor.removeWordRight(); } exec: function(env, args, request) { env.editor.removeWordRight(); }
}); });
canon.addCommand({ commands.addCommand({
name: "outdent", name: "outdent",
bindKey: bindKey("Shift-Tab", "Shift-Tab"), bindKey: bindKey("Shift-Tab", "Shift-Tab"),
exec: function(env, args, request) { env.editor.blockOutdent(); } exec: function(env, args, request) { env.editor.blockOutdent(); }
}); });
canon.addCommand({ commands.addCommand({
name: "indent", name: "indent",
bindKey: bindKey("Tab", "Tab"), bindKey: bindKey("Tab", "Tab"),
exec: function(env, args, request) { env.editor.indent(); } exec: function(env, args, request) { env.editor.indent(); }
}); });
canon.addCommand({ commands.addCommand({
name: "inserttext", name: "inserttext",
exec: function(env, args, request) { exec: function(env, args, request) {
env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
} }
}); });
canon.addCommand({ commands.addCommand({
name: "centerselection", name: "centerselection",
bindKey: bindKey(null, "Ctrl-L"), bindKey: bindKey(null, "Ctrl-L"),
exec: function(env, args, request) { env.editor.centerSelection(); } exec: function(env, args, request) { env.editor.centerSelection(); }
}); });
canon.addCommand({ commands.addCommand({
name: "splitline", name: "splitline",
bindKey: bindKey(null, "Ctrl-O"), bindKey: bindKey(null, "Ctrl-O"),
exec: function(env, args, request) { env.editor.splitLine(); } exec: function(env, args, request) { env.editor.splitLine(); }
}); });
canon.addCommand({ commands.addCommand({
name: "transposeletters", name: "transposeletters",
bindKey: bindKey("Ctrl-T", "Ctrl-T"), bindKey: bindKey("Ctrl-T", "Ctrl-T"),
exec: function(env, args, request) { env.editor.transposeLetters(); } exec: function(env, args, request) { env.editor.transposeLetters(); }

View file

@ -41,8 +41,7 @@ define(function(require, exports, module) {
var useragent = require("pilot/useragent"); var useragent = require("pilot/useragent");
var keyUtil = require("pilot/keys"); var keyUtil = require("pilot/keys");
var event = require("pilot/event"); var event = require("pilot/event");
var settings = require("pilot/settings").settings; var commands = require("ace/commands/command_manager");
var canon = require("pilot/canon");
require("ace/commands/default_commands"); require("ace/commands/default_commands");
var KeyBinding = function(editor) { var KeyBinding = function(editor) {
@ -76,7 +75,7 @@ var KeyBinding = function(editor) {
if (!toExecute || !toExecute.command) { if (!toExecute || !toExecute.command) {
if (hashId != 0 || keyCode != 0) { if (hashId != 0 || keyCode != 0) {
toExecute = { toExecute = {
command: canon.findKeyCommand(env, "editor", hashId, keyOrText) command: commands.findKeyCommand(env, hashId, keyOrText)
} }
} else { } else {
toExecute = { toExecute = {
@ -89,9 +88,11 @@ var KeyBinding = function(editor) {
} }
var success = false; var success = false;
if (toExecute) { if (toExecute && toExecute.command) {
success = canon.exec(toExecute.command, success = commands.exec(
env, "editor", toExecute.args); toExecute.command,
env, toExecute.args
);
if (success) { if (success) {
event.stopEvent(e); event.stopEvent(e);
} }

View file

@ -26,9 +26,7 @@
<script type="text/javascript"> <script type="text/javascript">
var require = { var require = {
paths: { paths: {
ace: "../", ace: "../"
cockpit: "../../../../support/cockpit/lib/cockpit",
pilot: "../../../../support/pilot/lib/pilot"
}, },
packages : [{ packages : [{
name: "asyncjs", name: "asyncjs",

View file

@ -15,7 +15,6 @@
"directories": { "directories": {
"lib": "lib/ace", "lib": "lib/ace",
"dependencies": { "dependencies": {
"cockpit": ">=0.1.1",
"pilot": ">=0.1.1" "pilot": ">=0.1.1"
} }
} }

@ -1 +0,0 @@
Subproject commit c88bbc33e6d8c9d72f2687658648a69b7420e0ba