From f517bf97170a92ae553d1d2111089686bd3486a4 Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Tue, 15 Feb 2011 03:40:11 +0800 Subject: [PATCH] Minimal UI for Find+Replace, issue 56. The API is there, the shortcut is there as well (Ctrl-R) but the command does not exist, so added a minimal implementation, just Find has one. --- lib/ace/commands/default_commands.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index e729457e..9a748a39 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -1,4 +1,5 @@ -/* ***** BEGIN LICENSE BLOCK ***** +/* vim:ts=4:sts=4:sw=4: + * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -21,6 +22,7 @@ * Contributor(s): * Fabian Jakobs * Julian Viereck + * Mihai Sucan * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -82,6 +84,30 @@ canon.addCommand({ env.editor.find(needle); } }); +canon.addCommand({ + name: "replace", + 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}); + } +}); +canon.addCommand({ + name: "replaceall", + 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}); + } +}); canon.addCommand({ name: "undo", exec: function(env, args, request) { env.editor.undo(); }