diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-12-04 04:06:45 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-12-04 04:06:45 +0100 |
commit | 575c9f45ec0f338e1d22032b98773d3ff3386bc9 (patch) | |
tree | db0362ce6f69d2a18ec6e94ad6889254050f1eae /search.cpp | |
parent | 457fe1498d5fe88e0447ddecd617281f7afd3304 (diff) | |
download | sciteco-575c9f45ec0f338e1d22032b98773d3ff3386bc9.tar.gz |
search-replace command with default replacement string (FR)
* based on FS command
* default replacement string is stored in global register "-"
Diffstat (limited to 'search.cpp')
-rw-r--r-- | search.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
@@ -1,3 +1,5 @@ +#include <string.h> + #include <glib.h> #include <glib/gprintf.h> @@ -9,10 +11,12 @@ #include "search.h" namespace States { - StateSearch search; - StateSearchAll searchall; - StateReplace replace; - StateReplace_insert replace_insert; + StateSearch search; + StateSearchAll searchall; + StateReplace replace; + StateReplace_insert replace_insert; + StateReplaceDefault replacedefault; + StateReplaceDefault_insert replacedefault_insert; } /* @@ -505,3 +509,29 @@ StateReplace::done(const gchar *str) throw (Error) return &States::replace_insert; } + +State * +StateReplaceDefault::done(const gchar *str) throw (Error) +{ + StateReplace::done(str); + return &States::replacedefault_insert; +} + +State * +StateReplaceDefault_insert::done(const gchar *str) throw (Error) +{ + BEGIN_EXEC(&States::start); + + QRegister *replace_reg = QRegisters::globals["-"]; + + if (*str) { + replace_reg->undo_set_string(); + replace_reg->set_string(str); + } else { + gchar *replace_str = replace_reg->get_string(); + StateInsert::process(replace_str, strlen(replace_str)); + g_free(replace_str); + } + + return &States::start; +} |