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