changes resulting from resource moves from pilot to cockpit

This commit is contained in:
Joe Walker 2011-03-30 09:19:03 +01:00
commit 953cc3b240
10 changed files with 388 additions and 395 deletions

View file

@ -35,7 +35,6 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*
require({ require({
paths: { paths: {
demo: "../demo", demo: "../demo",
@ -45,42 +44,41 @@ require({
} }
}); });
var deps = [ "pilot/fixoldbrowsers", "ace/plugin_manager", //*
"ace/environment", "demo/demo" ]; var deps = [
"pilot/fixoldbrowsers",
"ace/plugin_manager",
"ace/environment",
"demo/demo"
];
var plugins = [ "pilot/index", "cockpit/index", "ace/index" ];
require(deps, function() { require(deps, function() {
var catalog = require("ace/plugin_manager").catalog; var catalog = require("ace/plugin_manager").catalog;
var plugins = [ "cockpit/index", "ace/index" ];
catalog.registerPlugins(plugins).then(function() { catalog.registerPlugins(plugins).then(function() {
var env = require("ace/environment").create(); var env = require("ace/environment").create();
catalog.startupPlugins({ env: env }).then(function() { catalog.startupPlugins({ env: env }).then(function() {
var gcli = require("cockpit/index");
new gcli.CliView(env);
require("demo/demo").launch(env); require("demo/demo").launch(env);
}); });
}); });
}); });
*/ //*/
require({
paths: {
demo: "../demo",
ace: "../lib/ace",
cockpit: "../support/cockpit/lib/cockpit",
pilot: "../support/cockpit/support/pilot/lib/pilot"
}
});
/*
var deps = [ var deps = [
"ace/environment", "pilot/index", "cockpit/index", "ace/index", "ace/environment", "cockpit/index", "ace/index", "demo/demo",
"pilot/fixoldbrowsers" "pilot/fixoldbrowsers"
]; ];
require(deps, function(environment, pilot, cockpit) { require(deps, function(environment, cockpit, ace, demo) {
var data = { env: environment.create() }; var data = { env: environment.create() };
pilot.startup(data);
cockpit.startup(data); cockpit.startup(data);
new cockpit.CliView(data.env); new cockpit.CliView(data.env);
ace.startup(data);
require([ "demo/demo" ], function(demo) { demo.launch(data.env);
demo.launch(data.env);
});
}.bind(this)); }.bind(this));
//*/

View file

@ -40,7 +40,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 canon = require("cockpit/canon");
var event = require("pilot/event"); var event = require("pilot/event");
var Editor = require("ace/editor").Editor; var Editor = require("ace/editor").Editor;
var Renderer = require("ace/virtual_renderer").VirtualRenderer; var Renderer = require("ace/virtual_renderer").VirtualRenderer;

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 canon = require("cockpit/canon");
function bindKey(win, mac) { function bindKey(win, mac) {
return { return {
@ -51,352 +51,358 @@ function bindKey(win, mac) {
}; };
} }
canon.addCommand({ /**
name: "null", * TODO: This could be done more concisely and reversibly
exec: function(env, args, request) { } */
}); exports.startup = function() {
canon.addCommand({
name: "null",
exec: function(env, args, request) { }
});
canon.addCommand({ 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, request) { env.editor.selectAll(); }
}); });
canon.addCommand({ 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, request) { env.editor.removeLines(); }
}); });
canon.addCommand({ canon.addCommand({
name: "gotoline", name: "gotoline",
description: "Move the cursor to the given line", description: "Move the cursor to the given line",
bindKey: bindKey("Ctrl-L", "Command-L"), bindKey: bindKey("Ctrl-L", "Command-L"),
params: [ params: [
{ name: "line", type: "number", description: "The line number to jump to" } { name: "line", type: "number", description: "The line number to jump to" }
], ],
exec: function(env, args, request) { exec: function(env, args, request) {
// TODO: manual params should not be needed // TODO: manual params should not be needed
if (!args.line) { if (!args.line) {
while (!isNaN(args.line)) { while (!isNaN(args.line)) {
args.line = parseInt(prompt("Enter line number:")); args.line = parseInt(prompt("Enter line number:"));
}
} }
env.editor.gotoLine(args.line);
} }
env.editor.gotoLine(args.line); });
} canon.addCommand({
}); name: "togglecomment",
canon.addCommand({ bindKey: bindKey("Ctrl-7", "Command-7"),
name: "togglecomment", exec: function(env, args, request) { env.editor.toggleCommentLines(); }
bindKey: bindKey("Ctrl-7", "Command-7"), });
exec: function(env, args, request) { env.editor.toggleCommentLines(); } canon.addCommand({
}); name: "findnext",
canon.addCommand({ bindKey: bindKey("Ctrl-K", "Command-G"),
name: "findnext", exec: function(env, args, request) { env.editor.findNext(); }
bindKey: bindKey("Ctrl-K", "Command-G"), });
exec: function(env, args, request) { env.editor.findNext(); } canon.addCommand({
}); name: "findprevious",
canon.addCommand({ bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
name: "findprevious", exec: function(env, args, request) { env.editor.findPrevious(); }
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), });
exec: function(env, args, request) { env.editor.findPrevious(); } canon.addCommand({
}); name: "find",
canon.addCommand({ description: "Search for the next instance of a string",
name: "find", bindKey: bindKey("Ctrl-F", "Command-F"),
description: "Search for the next instance of a string", params: [
bindKey: bindKey("Ctrl-F", "Command-F"), { name: "findWhat", type: "string", description: "The text to search for" }
params: [ ],
{ name: "findWhat", type: "string", description: "The text to search for" } exec: function(env, args, request) {
], // TODO: manual params should not be needed
exec: function(env, args, request) {
// TODO: manual params should not be needed
if (!args.findWhat) {
args.findWhat = prompt("Find:");
}
env.editor.find(args.findWhat);
}
});
canon.addCommand({
name: "replace",
description: "Replace the next instance of a string with a given replacement",
bindKey: bindKey("Ctrl-R", "Command-Option-F"),
params: [
{ name: "findWhat", type: "string", description: "The text to search for" },
{ name: "replacement", type: "string", description: "The replacement text" }
],
exec: function(env, args, request) {
// TODO: manual params should not be needed
if (!args.findWhat) {
args.findWhat = prompt("Find:");
if (!args.findWhat) { if (!args.findWhat) {
return; args.findWhat = prompt("Find:");
}
args.replacement = prompt("Replacement:");
if (!args.replacement) {
return;
} }
env.editor.find(args.findWhat);
} }
env.editor.replace(args.replacement, {needle: args.findWhat}); });
} canon.addCommand({
}); name: "replace",
canon.addCommand({ description: "Replace the next instance of a string with a given replacement",
name: "replaceall", bindKey: bindKey("Ctrl-R", "Command-Option-F"),
description: "Replace all instances of a string with a given replacement", params: [
bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"), { name: "findWhat", type: "string", description: "The text to search for" },
params: [ { name: "replacement", type: "string", description: "The replacement text" }
{ name: "findWhat", type: "string", description: "The text to search for" }, ],
{ name: "replacement", type: "string", description: "The replacement text" } exec: function(env, args, request) {
], // TODO: manual params should not be needed
exec: function(env, args, request) {
// TODO: manual params should not be needed
if (!args.findWhat) {
args.findWhat = prompt("Find:");
if (!args.findWhat) { if (!args.findWhat) {
return; args.findWhat = prompt("Find:");
} if (!args.findWhat) {
args.replacement = prompt("Replacement:"); return;
if (!args.replacement) { }
return; args.replacement = prompt("Replacement:");
if (!args.replacement) {
return;
}
} }
env.editor.replace(args.replacement, {needle: args.findWhat});
} }
env.editor.replaceAll(args.replacement, {needle: args.findWhat}); });
} canon.addCommand({
}); name: "replaceall",
canon.addCommand({ description: "Replace all instances of a string with a given replacement",
name: "undo", bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"),
bindKey: bindKey("Ctrl-Z", "Command-Z"), params: [
exec: function(env, args, request) { env.editor.undo(); } { name: "findWhat", type: "string", description: "The text to search for" },
}); { name: "replacement", type: "string", description: "The replacement text" }
canon.addCommand({ ],
name: "redo", exec: function(env, args, request) {
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"), // TODO: manual params should not be needed
exec: function(env, args, request) { env.editor.redo(); } if (!args.findWhat) {
}); args.findWhat = prompt("Find:");
canon.addCommand({ if (!args.findWhat) {
name: "overwrite", return;
bindKey: bindKey("Insert", "Insert"), }
exec: function(env, args, request) { env.editor.toggleOverwrite(); } args.replacement = prompt("Replacement:");
}); if (!args.replacement) {
canon.addCommand({ return;
name: "copylinesup", }
bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"), }
exec: function(env, args, request) { env.editor.copyLinesUp(); } env.editor.replaceAll(args.replacement, {needle: args.findWhat});
}); }
canon.addCommand({ });
name: "movelinesup", canon.addCommand({
bindKey: bindKey("Alt-Up", "Option-Up"), name: "undo",
exec: function(env, args, request) { env.editor.moveLinesUp(); } bindKey: bindKey("Ctrl-Z", "Command-Z"),
}); exec: function(env, args, request) { env.editor.undo(); }
canon.addCommand({ });
name: "selecttostart", canon.addCommand({
bindKey: bindKey("Alt-Shift-Up", "Command-Shift-Up"), name: "redo",
exec: function(env, args, request) { env.editor.getSelection().selectFileStart(); } bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
}); exec: function(env, args, request) { env.editor.redo(); }
canon.addCommand({ });
name: "gotostart", canon.addCommand({
bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"), name: "overwrite",
exec: function(env, args, request) { env.editor.navigateFileStart(); } bindKey: bindKey("Insert", "Insert"),
}); exec: function(env, args, request) { env.editor.toggleOverwrite(); }
canon.addCommand({ });
name: "selectup", canon.addCommand({
bindKey: bindKey("Shift-Up", "Shift-Up"), name: "copylinesup",
exec: function(env, args, request) { env.editor.getSelection().selectUp(); } bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"),
}); exec: function(env, args, request) { env.editor.copyLinesUp(); }
canon.addCommand({ });
name: "golineup", canon.addCommand({
bindKey: bindKey("Up", "Up|Ctrl-P"), name: "movelinesup",
exec: function(env, args, request) { env.editor.navigateUp(args.times); } bindKey: bindKey("Alt-Up", "Option-Up"),
}); exec: function(env, args, request) { env.editor.moveLinesUp(); }
canon.addCommand({ });
name: "copylinesdown", canon.addCommand({
bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"), name: "selecttostart",
exec: function(env, args, request) { env.editor.copyLinesDown(); } bindKey: bindKey("Alt-Shift-Up", "Command-Shift-Up"),
}); exec: function(env, args, request) { env.editor.getSelection().selectFileStart(); }
canon.addCommand({ });
name: "movelinesdown", canon.addCommand({
bindKey: bindKey("Alt-Down", "Option-Down"), name: "gotostart",
exec: function(env, args, request) { env.editor.moveLinesDown(); } bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"),
}); exec: function(env, args, request) { env.editor.navigateFileStart(); }
canon.addCommand({ });
name: "selecttoend", canon.addCommand({
bindKey: bindKey("Alt-Shift-Down", "Command-Shift-Down"), name: "selectup",
exec: function(env, args, request) { env.editor.getSelection().selectFileEnd(); } bindKey: bindKey("Shift-Up", "Shift-Up"),
}); exec: function(env, args, request) { env.editor.getSelection().selectUp(); }
canon.addCommand({ });
name: "gotoend", canon.addCommand({
bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"), name: "golineup",
exec: function(env, args, request) { env.editor.navigateFileEnd(); } bindKey: bindKey("Up", "Up|Ctrl-P"),
}); exec: function(env, args, request) { env.editor.navigateUp(args.times); }
canon.addCommand({ });
name: "selectdown", canon.addCommand({
bindKey: bindKey("Shift-Down", "Shift-Down"), name: "copylinesdown",
exec: function(env, args, request) { env.editor.getSelection().selectDown(); } bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"),
}); exec: function(env, args, request) { env.editor.copyLinesDown(); }
canon.addCommand({ });
name: "golinedown", canon.addCommand({
bindKey: bindKey("Down", "Down|Ctrl-N"), name: "movelinesdown",
exec: function(env, args, request) { env.editor.navigateDown(args.times); } bindKey: bindKey("Alt-Down", "Option-Down"),
}); exec: function(env, args, request) { env.editor.moveLinesDown(); }
canon.addCommand({ });
name: "selectwordleft", canon.addCommand({
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"), name: "selecttoend",
exec: function(env, args, request) { env.editor.getSelection().selectWordLeft(); } bindKey: bindKey("Alt-Shift-Down", "Command-Shift-Down"),
}); exec: function(env, args, request) { env.editor.getSelection().selectFileEnd(); }
canon.addCommand({ });
name: "gotowordleft", canon.addCommand({
bindKey: bindKey("Ctrl-Left", "Option-Left"), name: "gotoend",
exec: function(env, args, request) { env.editor.navigateWordLeft(); } bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"),
}); exec: function(env, args, request) { env.editor.navigateFileEnd(); }
canon.addCommand({ });
name: "selecttolinestart", canon.addCommand({
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"), name: "selectdown",
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); } bindKey: bindKey("Shift-Down", "Shift-Down"),
}); exec: function(env, args, request) { env.editor.getSelection().selectDown(); }
canon.addCommand({ });
name: "gotolinestart", canon.addCommand({
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), name: "golinedown",
exec: function(env, args, request) { env.editor.navigateLineStart(); } bindKey: bindKey("Down", "Down|Ctrl-N"),
}); exec: function(env, args, request) { env.editor.navigateDown(args.times); }
canon.addCommand({ });
name: "selectleft", canon.addCommand({
bindKey: bindKey("Shift-Left", "Shift-Left"), name: "selectwordleft",
exec: function(env, args, request) { env.editor.getSelection().selectLeft(); } bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
}); exec: function(env, args, request) { env.editor.getSelection().selectWordLeft(); }
canon.addCommand({ });
name: "gotoleft", canon.addCommand({
bindKey: bindKey("Left", "Left|Ctrl-B"), name: "gotowordleft",
exec: function(env, args, request) { env.editor.navigateLeft(args.times); } bindKey: bindKey("Ctrl-Left", "Option-Left"),
}); exec: function(env, args, request) { env.editor.navigateWordLeft(); }
canon.addCommand({ });
name: "selectwordright", canon.addCommand({
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"), name: "selecttolinestart",
exec: function(env, args, request) { env.editor.getSelection().selectWordRight(); } bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
}); exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
canon.addCommand({ });
name: "gotowordright", canon.addCommand({
bindKey: bindKey("Ctrl-Right", "Option-Right"), name: "gotolinestart",
exec: function(env, args, request) { env.editor.navigateWordRight(); } bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
}); exec: function(env, args, request) { env.editor.navigateLineStart(); }
canon.addCommand({ });
name: "selecttolineend", canon.addCommand({
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"), name: "selectleft",
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); } bindKey: bindKey("Shift-Left", "Shift-Left"),
}); exec: function(env, args, request) { env.editor.getSelection().selectLeft(); }
canon.addCommand({ });
name: "gotolineend", canon.addCommand({
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"), name: "gotoleft",
exec: function(env, args, request) { env.editor.navigateLineEnd(); } bindKey: bindKey("Left", "Left|Ctrl-B"),
}); exec: function(env, args, request) { env.editor.navigateLeft(args.times); }
canon.addCommand({ });
name: "selectright", canon.addCommand({
bindKey: bindKey("Shift-Right", "Shift-Right"), name: "selectwordright",
exec: function(env, args, request) { env.editor.getSelection().selectRight(); } bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
}); exec: function(env, args, request) { env.editor.getSelection().selectWordRight(); }
canon.addCommand({ });
name: "gotoright", canon.addCommand({
bindKey: bindKey("Right", "Right|Ctrl-F"), name: "gotowordright",
exec: function(env, args, request) { env.editor.navigateRight(args.times); } bindKey: bindKey("Ctrl-Right", "Option-Right"),
}); exec: function(env, args, request) { env.editor.navigateWordRight(); }
canon.addCommand({ });
name: "selectpagedown", canon.addCommand({
bindKey: bindKey("Shift-PageDown", "Shift-PageDown"), name: "selecttolineend",
exec: function(env, args, request) { env.editor.selectPageDown(); } bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
}); exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
canon.addCommand({ });
name: "pagedown", canon.addCommand({
bindKey: bindKey(null, "PageDown"), name: "gotolineend",
exec: function(env, args, request) { env.editor.scrollPageDown(); } bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
}); exec: function(env, args, request) { env.editor.navigateLineEnd(); }
canon.addCommand({ });
name: "gotopagedown", canon.addCommand({
bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"), name: "selectright",
exec: function(env, args, request) { env.editor.gotoPageDown(); } bindKey: bindKey("Shift-Right", "Shift-Right"),
}); exec: function(env, args, request) { env.editor.getSelection().selectRight(); }
canon.addCommand({ });
name: "selectpageup", canon.addCommand({
bindKey: bindKey("Shift-PageUp", "Shift-PageUp"), name: "gotoright",
exec: function(env, args, request) { env.editor.selectPageUp(); } bindKey: bindKey("Right", "Right|Ctrl-F"),
}); exec: function(env, args, request) { env.editor.navigateRight(args.times); }
canon.addCommand({ });
name: "pageup", canon.addCommand({
bindKey: bindKey(null, "PageUp"), name: "selectpagedown",
exec: function(env, args, request) { env.editor.scrollPageUp(); } bindKey: bindKey("Shift-PageDown", "Shift-PageDown"),
}); exec: function(env, args, request) { env.editor.selectPageDown(); }
canon.addCommand({ });
name: "gotopageup", canon.addCommand({
bindKey: bindKey("PageUp", "Option-PageUp"), name: "pagedown",
exec: function(env, args, request) { env.editor.gotoPageUp(); } bindKey: bindKey(null, "PageDown"),
}); exec: function(env, args, request) { env.editor.scrollPageDown(); }
canon.addCommand({ });
name: "selectlinestart", canon.addCommand({
bindKey: bindKey("Shift-Home", "Shift-Home"), name: "gotopagedown",
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); } bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"),
}); exec: function(env, args, request) { env.editor.gotoPageDown(); }
canon.addCommand({ });
name: "selectlineend", canon.addCommand({
bindKey: bindKey("Shift-End", "Shift-End"), name: "selectpageup",
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); } bindKey: bindKey("Shift-PageUp", "Shift-PageUp"),
}); exec: function(env, args, request) { env.editor.selectPageUp(); }
canon.addCommand({ });
name: "del", canon.addCommand({
bindKey: bindKey("Delete", "Delete|Ctrl-D"), name: "pageup",
exec: function(env, args, request) { env.editor.removeRight(); } bindKey: bindKey(null, "PageUp"),
}); exec: function(env, args, request) { env.editor.scrollPageUp(); }
canon.addCommand({ });
name: "backspace", canon.addCommand({
bindKey: bindKey( name: "gotopageup",
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", bindKey: bindKey("PageUp", "Option-PageUp"),
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" exec: function(env, args, request) { env.editor.gotoPageUp(); }
), });
exec: function(env, args, request) { env.editor.removeLeft(); } canon.addCommand({
}); name: "selectlinestart",
canon.addCommand({ bindKey: bindKey("Shift-Home", "Shift-Home"),
name: "removetolinestart", exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
bindKey: bindKey(null, "Option-Backspace"), });
exec: function(env, args, request) { env.editor.removeToLineStart(); } canon.addCommand({
}); name: "selectlineend",
canon.addCommand({ bindKey: bindKey("Shift-End", "Shift-End"),
name: "removetolineend", exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
bindKey: bindKey(null, "Ctrl-K"), });
exec: function(env, args, request) { env.editor.removeToLineEnd(); } canon.addCommand({
}); name: "del",
canon.addCommand({ bindKey: bindKey("Delete", "Delete|Ctrl-D"),
name: "removewordleft", exec: function(env, args, request) { env.editor.removeRight(); }
bindKey: bindKey(null, "Alt-Backspace|Ctrl-Alt-Backspace"), });
exec: function(env, args, request) { env.editor.removeWordLeft(); } canon.addCommand({
}); name: "backspace",
canon.addCommand({ bindKey: bindKey(
name: "removewordright", "Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
bindKey: bindKey(null, "Alt-Delete"), "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
exec: function(env, args, request) { env.editor.removeWordRight(); } ),
}); exec: function(env, args, request) { env.editor.removeLeft(); }
canon.addCommand({ });
name: "outdent", canon.addCommand({
bindKey: bindKey("Shift-Tab", "Shift-Tab"), name: "removetolinestart",
exec: function(env, args, request) { env.editor.blockOutdent(); } bindKey: bindKey(null, "Option-Backspace"),
}); exec: function(env, args, request) { env.editor.removeToLineStart(); }
canon.addCommand({ });
name: "indent", canon.addCommand({
bindKey: bindKey("Tab", "Tab"), name: "removetolineend",
exec: function(env, args, request) { env.editor.indent(); } bindKey: bindKey(null, "Ctrl-K"),
}); exec: function(env, args, request) { env.editor.removeToLineEnd(); }
canon.addCommand({ });
name: "inserttext", canon.addCommand({
exec: function(env, args, request) { name: "removewordleft",
env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); bindKey: bindKey(null, "Alt-Backspace|Ctrl-Alt-Backspace"),
} exec: function(env, args, request) { env.editor.removeWordLeft(); }
}); });
canon.addCommand({ canon.addCommand({
name: "centerselection", name: "removewordright",
bindKey: bindKey("Ctrl-L", "Ctrl-L"), bindKey: bindKey(null, "Alt-Delete"),
exec: function(env, args, request) { env.editor.centerSelection(); } exec: function(env, args, request) { env.editor.removeWordRight(); }
}); });
canon.addCommand({ canon.addCommand({
name: "splitline", name: "outdent",
bindKey: bindKey(null, "Ctrl-O"), bindKey: bindKey("Shift-Tab", "Shift-Tab"),
exec: function(env, args, request) { env.editor.splitLine(); } exec: function(env, args, request) { env.editor.blockOutdent(); }
}); });
canon.addCommand({ canon.addCommand({
name: "transposeletters", name: "indent",
bindKey: bindKey("Ctrl-T", "Ctrl-T"), bindKey: bindKey("Tab", "Tab"),
exec: function(env, args, request) { env.editor.transposeLetters(); } exec: function(env, args, request) { env.editor.indent(); }
}); });
canon.addCommand({
name: "inserttext",
exec: function(env, args, request) {
env.editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
}
});
canon.addCommand({
name: "centerselection",
bindKey: bindKey("Ctrl-L", "Ctrl-L"),
exec: function(env, args, request) { env.editor.centerSelection(); }
});
canon.addCommand({
name: "splitline",
bindKey: bindKey(null, "Ctrl-O"),
exec: function(env, args, request) { env.editor.splitLine(); }
});
canon.addCommand({
name: "transposeletters",
bindKey: bindKey("Ctrl-T", "Ctrl-T"),
exec: function(env, args, request) { env.editor.transposeLetters(); }
});
};
}); });

View file

@ -38,7 +38,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var canon = require('pilot/canon'); var canon = require('cockpit/canon');
var pref = { var pref = {
metadata: { metadata: {

View file

@ -37,11 +37,14 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var settings = require("ace/settings").settings;
/** /**
* Create an environment object * Create an environment object
*/ */
function create() { function create() {
return { return {
settings: settings
}; };
}; };

View file

@ -40,7 +40,7 @@ define(function(require, exports, module) {
var useragent = require("pilot/useragent"); var useragent = require("pilot/useragent");
var event = require("pilot/event"); var event = require("pilot/event");
var canon = require("pilot/canon"); var canon = require("cockpit/canon");
var keyUtil = require("ace/keys"); var keyUtil = require("ace/keys");
var settings = require("ace/settings").settings; var settings = require("ace/settings").settings;

View file

@ -37,7 +37,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var Promise = require("pilot/promise").Promise; var Promise = require("ace/promise").Promise;
exports.REASONS = { exports.REASONS = {
APP_STARTUP: 1, APP_STARTUP: 1,

View file

@ -44,12 +44,12 @@ define(function(require, exports, module) {
var console = require('pilot/console'); var console = require('pilot/console');
var oop = require('pilot/oop'); var oop = require('pilot/oop');
var types = require('pilot/types'); var types = require('cockpit/types');
var EventEmitter = require('pilot/event_emitter').EventEmitter; var EventEmitter = require('pilot/event_emitter').EventEmitter;
var SelectionType = require('pilot/types/basic').SelectionType; var SelectionType = require('cockpit/basic').SelectionType;
var DeferredType = require('pilot/types/basic').DeferredType; var DeferredType = require('cockpit/basic').DeferredType;
var Argument = require('pilot/argument').Argument; var Argument = require('cockpit/argument').Argument;
/** /**
@ -314,7 +314,7 @@ exports.CookiePersister = CookiePersister;
/** /**
* EVIL: This relies on us using settingValue in the same event as setting * This relies on us using settingValue in the same event as setting
* The alternative is to have some central place where we store the current * The alternative is to have some central place where we store the current
* command line, but this might be a lesser evil for now. * command line, but this might be a lesser evil for now.
*/ */
@ -330,22 +330,17 @@ var setting = new SelectionType({
}, },
noMatch: function() { noMatch: function() {
lastSetting = null; lastSetting = null;
} },
}); stringify: function(setting) {
(function() {
var originalStringify = setting.stringify;
setting.stringify = function(setting) {
lastSetting = setting; lastSetting = setting;
return originalStringify.call(this, setting); return SelectionType.prototype.stringify.call(this, setting);
}; },
parse: function(arg) {
var originalParse = setting.parse; var conversion = SelectionType.prototype.parse.call(this, arg);
setting.parse = function(arg) {
var conversion = originalParse.call(this, arg);
lastSetting = conversion.value; lastSetting = conversion.value;
return conversion; return conversion;
}; }
})(); });
/** /**
* Something of a hack to allow the set command to give a clearer definition * Something of a hack to allow the set command to give a clearer definition

View file

@ -38,17 +38,9 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var types = require('pilot/types');
var SelectionType = require('pilot/types/basic').SelectionType;
var env; var env;
var settingTypes = {
selectionStyle: new SelectionType({
data: [ 'line', 'text' ]
})
};
var settings = { var settings = {
printMargin: { printMargin: {
description: 'Position of the print margin column.', description: 'Position of the print margin column.',
@ -76,7 +68,7 @@ var settings = {
}, },
selectionStyle: { selectionStyle: {
description: 'Type of text selection.', description: 'Type of text selection.',
type: 'selectionStyle', type: { name: 'selection', data: [ 'line', 'text' ] },
defaultValue: 'line', defaultValue: 'line',
onChange: function onChange(event) { onChange: function onChange(event) {
if (env.editor) env.editor.setSelectionStyle(event.value); if (env.editor) env.editor.setSelectionStyle(event.value);
@ -86,7 +78,6 @@ var settings = {
exports.startup = function startup(data) { exports.startup = function startup(data) {
env = data.env; env = data.env;
types.registerTypes(settingTypes);
data.env.settings.addSettings(settings); data.env.settings.addSettings(settings);
}; };

@ -1 +1 @@
Subproject commit e20180cc3311b0d366e2624ddd1b150767bb41e4 Subproject commit ebd56b41a28bb28805ae92b3d2356fdbed3a49c9