catchup with changes to command syntax in cockpit/gcli
This commit is contained in:
parent
4900fa2f9f
commit
a48d0e7688
2 changed files with 55 additions and 21 deletions
|
|
@ -68,12 +68,19 @@ canon.addCommand({
|
|||
});
|
||||
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) {
|
||||
var line = parseInt(prompt("Enter line number:"));
|
||||
if (!isNaN(line)) {
|
||||
env.editor.gotoLine(line);
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
canon.addCommand({
|
||||
|
|
@ -93,36 +100,63 @@ canon.addCommand({
|
|||
});
|
||||
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) {
|
||||
var needle = prompt("Find:");
|
||||
env.editor.find(needle);
|
||||
// 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) {
|
||||
var needle = prompt("Find:");
|
||||
if (!needle)
|
||||
return;
|
||||
var replacement = prompt("Replacement:");
|
||||
if (!replacement)
|
||||
return;
|
||||
env.editor.replace(replacement, {needle: needle});
|
||||
// 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.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) {
|
||||
var needle = prompt("Find:");
|
||||
if (!needle)
|
||||
return;
|
||||
var replacement = prompt("Replacement:");
|
||||
if (!replacement)
|
||||
return;
|
||||
env.editor.replaceAll(replacement, {needle: needle});
|
||||
// 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({
|
||||
|
|
@ -365,4 +399,4 @@ canon.addCommand({
|
|||
exec: function(env, args, request) { env.editor.transposeLetters(); }
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit f825fa7dff437fa488c5e291fff37a95f44e4513
|
||||
Subproject commit aa56894ef1cfa30ab038d77fbc79f72416eb43e6
|
||||
Loading…
Add table
Add a link
Reference in a new issue