remove request argument to commands

This commit is contained in:
Fabian Jakobs 2011-07-23 12:41:20 +02:00
commit 8d0e1784e2

View file

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