Conflicts:
	.gitmodules
	Makefile.dryice.js
	demo/demo.js
	demo/kitchen-sink/boot.js
	kitchen-sink.html
	lib/ace/commands/default_commands.js
	lib/ace/test/tests.html
	package.json
	support/pilot
This commit is contained in:
Fabian Jakobs 2011-11-02 13:25:32 +01:00
commit 62a3b4edf5
18 changed files with 704 additions and 808 deletions

3
.gitmodules vendored
View file

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

View file

@ -297,7 +297,7 @@ console.log('# ace worker ---------');
aceHome + "/lib/ace/worker/worker.js", aceHome + "/lib/ace/worker/worker.js",
worker worker
], ],
filter: [ copy.filter.uglifyjs, filterTextPlugin ], filter: [ filterTextPlugin, copy.filter.uglifyjs ],
dest: "build/src/worker-" + mode + ".js" dest: "build/src/worker-" + mode + ".js"
}); });
}); });
@ -349,7 +349,7 @@ function demo() {
source: [ source: [
copy.source.commonjs({ copy.source.commonjs({
project: project, project: project,
require: [ "pilot/index", "ace/defaults", "demo/kitchen-sink/boot" ] require: [ "demo/kitchen-sink/demo" ]
}) })
], ],
filter: [ copy.filter.moduleDefines ], filter: [ copy.filter.moduleDefines ],

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,8 +63,7 @@ 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(); editor.resize();
@ -77,7 +71,6 @@ window.__ace_shadowed__.edit = function(el) {
editor.resize(); editor.resize();
}); });
el.env = env; el.env = env;
});
return editor; return editor;
} }

View file

@ -1,57 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kevin Dangoor (kdangoor@mozilla.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
require("pilot/fixoldbrowsers");
require("pilot/plugin_manager");
require("pilot/environment");
require("demo/kitchen-sink/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/kitchen-sink/demo").launch(env);
});
});
});

View file

@ -40,8 +40,10 @@
define(function(require, exports, module) { define(function(require, exports, module) {
require("pilot/fixoldbrowsers");
var env = {};
var net = require("ace/lib/net"); var net = require("ace/lib/net");
var canon = require("pilot/canon");
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;
@ -86,9 +88,16 @@ Mode.prototype.supportsFile = function(filename) {
return filename.match(this.extRe); return filename.match(this.extRe);
}; };
var themes = {};
function loadTheme(name, callback) {
if (themes[name])
return callback();
themes[name] = 1;
exports.launch = function(env) { var base = name.split("/").pop();
var fileName = "src/theme-" + base + ".js";
net.loadScript(fileName, callback);
}
var modes = [ var modes = [
new Mode("c_cpp", "C/C++", require("ace/mode/c_cpp").Mode, ["c", "cpp", "cxx", "h", "hpp"]), new Mode("c_cpp", "C/C++", require("ace/mode/c_cpp").Mode, ["c", "cpp", "cxx", "h", "hpp"]),
@ -259,7 +268,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;
@ -517,7 +525,9 @@ 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({ var commands = env.editor.commands;
commands.addCommand({
name: "save", name: "save",
bindKey: { bindKey: {
win: "Ctrl-S", win: "Ctrl-S",
@ -530,7 +540,7 @@ exports.launch = function(env) {
}); });
// Fake-Print with custom lookup-sender-match function. // Fake-Print with custom lookup-sender-match function.
canon.addCommand({ commands.addCommand({
name: "print", name: "print",
bindKey: { bindKey: {
win: "Ctrl-P", win: "Ctrl-P",
@ -548,17 +558,4 @@ exports.launch = function(env) {
} }
}); });
};
var themes = {};
function loadTheme(name, callback) {
if (themes[name])
return callback();
themes[name] = 1;
var base = name.split("/").pop();
var fileName = "src/theme-" + base + ".js";
net.loadScript(fileName, callback);
}
}); });

View file

@ -188,21 +188,21 @@
<!-- DEVEL--> <!-- DEVEL-->
<script type="text/javascript"> <script type="text/javascript">
var require = { var require = {
baseUrl: "/" + window.location.pathname.split("/").slice(0, -1).join("/"),
paths: { paths: {
demo: "..", ace: "lib/ace",
ace: "../../lib/ace", pilot: "node_modules/pilot/lib/pilot"
cockpit: "../../node_modules/cockpit/lib/cockpit",
pilot: "../../node_modules/pilot/lib/pilot"
} }
}; };
</script> </script>
<script src="demo/kitchen-sink/require.js" data-main="demo/kitchen-sink/boot" type="text/javascript" charset="utf-8"></script> <script src="demo/kitchen-sink/require.js" data-main="demo/kitchen-sink/demo" type="text/javascript"></script>
<!--DEVEL --> <!--DEVEL -->
<!--PACKAGE <!--PACKAGE
<script src="demo/kitchen-sink/kitchen-sink-uncompressed.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script> <script src="demo/kitchen-sink/kitchen-sink-uncompressed.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
require("demo/kitchen-sink/boot"); require("demo/kitchen-sink/demo");
</script> </script>
<!--PACKAGE--> <!--PACKAGE-->

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,8 +60,7 @@ 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(); editor.resize();
@ -71,7 +68,6 @@ define(function(require, exports, module) {
editor.resize(); 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,87 @@
define(function(require, exports, module) {
var keyUtil = require('pilot/keys');
var useragent = require('pilot/useragent');
var CommandManager = function(commands) {
this.commands = {};
this.commmandKeyBinding = {};
if (commands)
commands.forEach(this.addCommand, this);
};
(function() {
this.addCommand = function(command) {
this.commands[command.name] = command;
if (command.bindKey) {
this._buildKeyHash(command);
}
};
var platform = useragent.isMac ? "mac" : "win";
this._buildKeyHash = function(command) {
var binding = command.bindKey;
var key = binding[platform];
var ckb = this.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);
}
this.findKeyCommand = function findKeyCommand(env, hashId, textOrKey) {
// Convert keyCode to the string representation.
if (typeof textOrKey == "number") {
textOrKey = keyUtil.keyCodeToString(textOrKey);
}
var ckbr = this.commmandKeyBinding;
return ckbr[hashId] && ckbr[hashId][textOrKey];
}
this.exec = function(command, env, args) {
if (typeof command === 'string')
command = this.commands[command];
command.exec(env, args || {});
};
}).call(CommandManager.prototype);
exports.CommandManager = CommandManager;
});

View file

@ -41,7 +41,6 @@
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");
function bindKey(win, mac) { function bindKey(win, mac) {
return { return {
@ -51,58 +50,46 @@ function bindKey(win, mac) {
}; };
} }
canon.addCommand({ exports.commands = [{
name: "null",
exec: function(env, args, request) { }
});
canon.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) { env.editor.selectAll(); }
}); }, {
canon.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) { env.editor.removeLines(); }
}); }, {
canon.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) {
var line = parseInt(prompt("Enter line number:")); var line = parseInt(prompt("Enter line number:"));
if (!isNaN(line)) { if (!isNaN(line)) {
env.editor.gotoLine(line); env.editor.gotoLine(line);
} }
} }
}); }, {
canon.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) { env.editor.toggleCommentLines(); }
}); }, {
canon.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) { env.editor.findNext(); }
}); }, {
canon.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) { env.editor.findPrevious(); }
}); }, {
canon.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) {
var needle = prompt("Find:", env.editor.getCopyText()); var needle = prompt("Find:", env.editor.getCopyText());
env.editor.find(needle); env.editor.find(needle);
} }
}); }, {
canon.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) {
var needle = prompt("Find:", env.editor.getCopyText()); var needle = prompt("Find:", env.editor.getCopyText());
if (!needle) if (!needle)
return; return;
@ -111,11 +98,10 @@ canon.addCommand({
return; return;
env.editor.replace(replacement, {needle: needle}); env.editor.replace(replacement, {needle: needle});
} }
}); }, {
canon.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) {
var needle = prompt("Find:"); var needle = prompt("Find:");
if (!needle) if (!needle)
return; return;
@ -124,274 +110,222 @@ canon.addCommand({
return; return;
env.editor.replaceAll(replacement, {needle: needle}); env.editor.replaceAll(replacement, {needle: needle});
} }
}); }, {
canon.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) { env.editor.undo(); }
}); }, {
canon.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) { env.editor.redo(); }
}); }, {
canon.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) { env.editor.toggleOverwrite(); }
}); }, {
canon.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) { env.editor.copyLinesUp(); }
}); }, {
canon.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) { env.editor.moveLinesUp(); }
}); }, {
canon.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) { env.editor.getSelection().selectFileStart(); }
}); }, {
canon.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) { env.editor.navigateFileStart(); }
}); }, {
canon.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) { env.editor.getSelection().selectUp(); }
}); }, {
canon.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) { env.editor.navigateUp(args.times); }
}); }, {
canon.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) { env.editor.copyLinesDown(); }
}); }, {
canon.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) { env.editor.moveLinesDown(); }
}); }, {
canon.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) { env.editor.getSelection().selectFileEnd(); }
}); }, {
canon.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) { env.editor.navigateFileEnd(); }
}); }, {
canon.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) { env.editor.getSelection().selectDown(); }
}); }, {
canon.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) { env.editor.navigateDown(args.times); }
}); }, {
canon.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) { env.editor.getSelection().selectWordLeft(); }
}); }, {
canon.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) { env.editor.navigateWordLeft(); }
}); }, {
canon.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) { env.editor.getSelection().selectLineStart(); }
}); }, {
canon.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) { env.editor.navigateLineStart(); }
}); }, {
canon.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) { env.editor.getSelection().selectLeft(); }
}); }, {
canon.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) { env.editor.navigateLeft(args.times); }
}); }, {
canon.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) { env.editor.getSelection().selectWordRight(); }
}); }, {
canon.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) { env.editor.navigateWordRight(); }
}); }, {
canon.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) { env.editor.getSelection().selectLineEnd(); }
}); }, {
canon.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) { env.editor.navigateLineEnd(); }
}); }, {
canon.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) { env.editor.getSelection().selectRight(); }
}); }, {
canon.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) { env.editor.navigateRight(args.times); }
}); }, {
canon.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) { env.editor.selectPageDown(); }
}); }, {
canon.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) { env.editor.scrollPageDown(); }
}); }, {
canon.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) { env.editor.gotoPageDown(); }
}); }, {
canon.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) { env.editor.selectPageUp(); }
}); }, {
canon.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) { env.editor.scrollPageUp(); }
}); }, {
canon.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) { env.editor.gotoPageUp(); }
}); }, {
canon.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) { env.editor.getSelection().selectLineStart(); }
}); }, {
canon.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) { env.editor.getSelection().selectLineEnd(); }
}); }, {
canon.addCommand({
name: "del", name: "del",
bindKey: bindKey("Delete", "Delete|Ctrl-D"), bindKey: bindKey("Delete", "Delete|Ctrl-D"),
exec: function(env, args, request) { env.editor.remove("right"); } exec: function(env, args) { env.editor.remove("right"); }
}); }, {
canon.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",
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
), ),
exec: function(env, args, request) { env.editor.remove("left"); } exec: function(env, args) { env.editor.removeLeft(); }
}); }, {
canon.addCommand({
name: "removetolinestart", name: "removetolinestart",
bindKey: bindKey("Alt-Backspace", "Option-Backspace"), bindKey: bindKey("Alt-Backspace", "Option-Backspace"),
exec: function(env, args, request) { env.editor.removeToLineStart(); } exec: function(env, args) { env.editor.removeToLineStart(); }
}); }, {
canon.addCommand({
name: "removetolineend", name: "removetolineend",
bindKey: bindKey("Alt-Delete", "Ctrl-K"), bindKey: bindKey("Alt-Delete", "Ctrl-K"),
exec: function(env, args, request) { env.editor.removeToLineEnd(); } exec: function(env, args) { env.editor.removeToLineEnd(); }
}); }, {
canon.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) { env.editor.removeWordLeft(); }
}); }, {
canon.addCommand({
name: "removewordright", name: "removewordright",
bindKey: bindKey("Ctrl-Delete", "Alt-Delete"), bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
exec: function(env, args, request) { env.editor.removeWordRight(); } exec: function(env, args) { env.editor.removeWordRight(); }
}); }, {
canon.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) { env.editor.blockOutdent(); }
}); }, {
canon.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) { env.editor.indent(); }
}); }, {
canon.addCommand({
name: "inserttext", name: "inserttext",
exec: function(env, args, request) { exec: function(env, args) {
env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
} }
}); }, {
canon.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) { env.editor.centerSelection(); }
}); }, {
canon.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) { env.editor.splitLine(); }
}); }, {
canon.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) { env.editor.transposeLetters(); }
}); }, {
canon.addCommand({
name: "fold", name: "fold",
bindKey: bindKey("Alt-L", "Alt-L"), bindKey: bindKey("Alt-L", "Alt-L"),
exec: function(env) { exec: function(env) {
env.editor.session.toggleFold(false); env.editor.session.toggleFold(false);
} }
}); }, {
canon.addCommand({
name: "unfold", name: "unfold",
bindKey: bindKey("Alt-Shift-L", "Alt-Shift-L"), bindKey: bindKey("Alt-Shift-L", "Alt-Shift-L"),
exec: function(env) { exec: function(env) {
env.editor.session.toggleFold(true); env.editor.session.toggleFold(true);
} }
}); }, {
canon.addCommand({
name: "foldall", name: "foldall",
bindKey: bindKey("Alt-Shift-0", "Alt-Shift-0"), bindKey: bindKey("Alt-Shift-0", "Alt-Shift-0"),
exec: function(env) { exec: function(env) {
env.editor.session.foldAll(); env.editor.session.foldAll();
} }
}); }, {
canon.addCommand({
name: "unfoldall", name: "unfoldall",
bindKey: bindKey("Alt-Shift-0", "Alt-Shift-0"), bindKey: bindKey("Alt-Shift-0", "Alt-Shift-0"),
exec: function(env) { exec: function(env) {
env.editor.session.unFoldAll(); env.editor.session.unFoldAll();
} }
}); }];
}); });

View file

@ -1,51 +0,0 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var settings = require("ace/settings/default-settings")
exports.startup = function startup(data, reason) {
settings.startup(data, reason)
}
exports.shutdown = function shutdown(data, reason) {
settings.shutdown(data, reason)
}
})

View file

@ -54,6 +54,8 @@ var EditSession = require("ace/edit_session").EditSession;
var Search = require("ace/search").Search; var Search = require("ace/search").Search;
var Range = require("ace/range").Range; var Range = require("ace/range").Range;
var EventEmitter = require("pilot/event_emitter").EventEmitter; var EventEmitter = require("pilot/event_emitter").EventEmitter;
var CommandManager = require("ace/commands/command_manager").CommandManager;
var defaultCommands = require("ace/commands/default_commands").commands;
var Editor = function(renderer, session) { var Editor = function(renderer, session) {
var container = renderer.getContainerElement(); var container = renderer.getContainerElement();
@ -75,6 +77,7 @@ var Editor =function(renderer, session) {
wrap: true wrap: true
}); });
this.commands = new CommandManager(defaultCommands);
this.setSession(session || new EditSession("")); this.setSession(session || new EditSession(""));
}; };

View file

@ -41,8 +41,6 @@ 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 canon = require("pilot/canon");
require("ace/commands/default_commands"); require("ace/commands/default_commands");
var KeyBinding = function(editor) { var KeyBinding = function(editor) {
@ -64,19 +62,21 @@ var KeyBinding = function(editor) {
}; };
this.$callKeyboardHandler = function (e, hashId, keyOrText, keyCode) { this.$callKeyboardHandler = function (e, hashId, keyOrText, keyCode) {
var env = {editor: this.$editor}, var env = {editor: this.$editor};
toExecute; var toExecute;
var commands = this.$editor.commands;
if (this.$keyboardHandler) { if (this.$keyboardHandler) {
toExecute = toExecute =
this.$keyboardHandler.handleKeyboard(this.$data, hashId, keyOrText, keyCode, e); this.$keyboardHandler.handleKeyboard(this.$data, hashId, keyOrText, keyCode, e);
} }
// If there is nothing to execute yet, then use the default keymapping. // If there is nothing to execute yet, then use the default keymapping.
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 +89,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,8 +26,7 @@
<script type="text/javascript"> <script type="text/javascript">
var require = { var require = {
paths: { paths: {
ace: "../", ace: "../"
pilot: "../../../support/pilot/lib/pilot"
}, },
packages : [{ packages : [{
name: "asyncjs", name: "asyncjs",

@ -1 +0,0 @@
Subproject commit 33f02ab3af5d755c98b3c58309ac2c62fc6de736

@ -1 +0,0 @@
Subproject commit 375d9a339646d70846ad40eddaad406198dd9d40

@ -1 +0,0 @@
Subproject commit 51938ca15ac7bd16f94e534cda3779f8a0a9f130

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