aboutsummaryrefslogtreecommitdiffhomepage
path: root/search.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'search.cpp')
-rw-r--r--search.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/search.cpp b/search.cpp
index 6b76825..ceb8e54 100644
--- a/search.cpp
+++ b/search.cpp
@@ -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;
+}