From ec37b09faf4cd88f1908e6701e1c7cd437c33f32 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Fri, 12 Jun 2015 14:16:50 +0200 Subject: [PATCH] Use find clipboard when no string is present in macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it possible to combine the “Use Selection for Find / Replace” with a non-simple find action (e.g. “Replace All”). If any find options are set (case sensitive, regular expression, etc.) then these will trump the options set for the entry on the find clipboard. --- Frameworks/editor/src/dispatch.cc | 10 ++++++++++ Frameworks/editor/src/editor.cc | 2 +- Frameworks/editor/src/editor.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Frameworks/editor/src/dispatch.cc b/Frameworks/editor/src/dispatch.cc index 2cb42335..5ce7f50c 100644 --- a/Frameworks/editor/src/dispatch.cc +++ b/Frameworks/editor/src/dispatch.cc @@ -211,9 +211,19 @@ namespace ng plist::get_key_path(args, "replaceString", replaceWith); if(searchFor != NULL_STR) + { find_clipboard()->push_back(searchFor); + } + else if(clipboard_t::entry_ptr searchEntry = find_clipboard()->current()) + { + searchFor = searchEntry->content(); + options |= convert(searchEntry->options()); + } + if(replaceWith != NULL_STR) replace_clipboard()->push_back(replaceWith); + else if(clipboard_t::entry_ptr replaceEntry = replace_clipboard()->current()) + replaceWith = replaceEntry->content(); std::string where; bool searchOnlySelection = plist::get_key_path(args, "replaceAllScope", where) && where == "selection"; diff --git a/Frameworks/editor/src/editor.cc b/Frameworks/editor/src/editor.cc index a1ba74eb..8cfa3c30 100644 --- a/Frameworks/editor/src/editor.cc +++ b/Frameworks/editor/src/editor.cc @@ -59,7 +59,7 @@ namespace ng return str; } - static find::options_t convert (std::map const& options) + find::options_t convert (std::map const& options) { static struct { std::string key; find::options_t flag; } const optionMap[] = { diff --git a/Frameworks/editor/src/editor.h b/Frameworks/editor/src/editor.h index f2e60cec..00614607 100644 --- a/Frameworks/editor/src/editor.h +++ b/Frameworks/editor/src/editor.h @@ -11,6 +11,8 @@ namespace ng { + find::options_t convert (std::map const& options); + enum action_t { kMoveBackward,