From a48d0e768821573b3f7252cde50b58440e1b78a4 Mon Sep 17 00:00:00 2001 From: Joe Walker Date: Fri, 25 Mar 2011 12:51:49 +0000 Subject: [PATCH] catchup with changes to command syntax in cockpit/gcli --- lib/ace/commands/default_commands.js | 74 ++++++++++++++++++++-------- support/cockpit | 2 +- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 979f6842..9ae8edf9 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -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(); } }); -}); \ No newline at end of file +}); diff --git a/support/cockpit b/support/cockpit index f825fa7d..aa56894e 160000 --- a/support/cockpit +++ b/support/cockpit @@ -1 +1 @@ -Subproject commit f825fa7dff437fa488c5e291fff37a95f44e4513 +Subproject commit aa56894ef1cfa30ab038d77fbc79f72416eb43e6