catchup with changes to command syntax in cockpit/gcli

This commit is contained in:
Joe Walker 2011-03-25 12:51:49 +00:00
commit a48d0e7688
2 changed files with 55 additions and 21 deletions

View file

@ -68,12 +68,19 @@ canon.addCommand({
}); });
canon.addCommand({ canon.addCommand({
name: "gotoline", name: "gotoline",
description: "Move the cursor to the given line",
bindKey: bindKey("Ctrl-L", "Command-L"), bindKey: bindKey("Ctrl-L", "Command-L"),
params: [
{ name: "line", type: "number", description: "The line number to jump to" }
],
exec: function(env, args, request) { exec: function(env, args, request) {
var line = parseInt(prompt("Enter line number:")); // TODO: manual params should not be needed
if (!isNaN(line)) { if (!args.line) {
env.editor.gotoLine(line); while (!isNaN(args.line)) {
args.line = parseInt(prompt("Enter line number:"));
}
} }
env.editor.gotoLine(args.line);
} }
}); });
canon.addCommand({ canon.addCommand({
@ -93,36 +100,63 @@ canon.addCommand({
}); });
canon.addCommand({ canon.addCommand({
name: "find", name: "find",
description: "Search for the next instance of a string",
bindKey: bindKey("Ctrl-F", "Command-F"), bindKey: bindKey("Ctrl-F", "Command-F"),
params: [
{ name: "findWhat", type: "string", description: "The text to search for" }
],
exec: function(env, args, request) { exec: function(env, args, request) {
var needle = prompt("Find:"); // TODO: manual params should not be needed
env.editor.find(needle); if (!args.findWhat) {
args.findWhat = prompt("Find:");
}
env.editor.find(args.findWhat);
} }
}); });
canon.addCommand({ canon.addCommand({
name: "replace", name: "replace",
description: "Replace the next instance of a string with a given replacement",
bindKey: bindKey("Ctrl-R", "Command-Option-F"), 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) { exec: function(env, args, request) {
var needle = prompt("Find:"); // TODO: manual params should not be needed
if (!needle) if (!args.findWhat) {
return; args.findWhat = prompt("Find:");
var replacement = prompt("Replacement:"); if (!args.findWhat) {
if (!replacement) return;
return; }
env.editor.replace(replacement, {needle: needle}); args.replacement = prompt("Replacement:");
if (!args.replacement) {
return;
}
}
env.editor.replace(args.replacement, {needle: args.findWhat});
} }
}); });
canon.addCommand({ canon.addCommand({
name: "replaceall", name: "replaceall",
description: "Replace all instances of a string with a given replacement",
bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"), 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) { exec: function(env, args, request) {
var needle = prompt("Find:"); // TODO: manual params should not be needed
if (!needle) if (!args.findWhat) {
return; args.findWhat = prompt("Find:");
var replacement = prompt("Replacement:"); if (!args.findWhat) {
if (!replacement) return;
return; }
env.editor.replaceAll(replacement, {needle: needle}); args.replacement = prompt("Replacement:");
if (!args.replacement) {
return;
}
}
env.editor.replaceAll(args.replacement, {needle: args.findWhat});
} }
}); });
canon.addCommand({ canon.addCommand({
@ -365,4 +399,4 @@ canon.addCommand({
exec: function(env, args, request) { env.editor.transposeLetters(); } exec: function(env, args, request) { env.editor.transposeLetters(); }
}); });
}); });

@ -1 +1 @@
Subproject commit f825fa7dff437fa488c5e291fff37a95f44e4513 Subproject commit aa56894ef1cfa30ab038d77fbc79f72416eb43e6