aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-04 04:46:13 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-04 04:57:18 +0100
commit266cdca115c7e9b14f734da478d04a8ce0c2cb69 (patch)
treefc955705cbca32957a929fc803ad5801dfe212b9
parent99bc57227170fea32cb3dbf923a4b4ab00aca1cc (diff)
downloadsciteco-266cdca115c7e9b14f734da478d04a8ce0c2cb69.tar.gz
search-kill command (FK)
* like the other search-related commands the operation (delete, kill, replace) is not performed until the search pattern string argument is terminated (simplifies implementation and has visual advantages)
-rw-r--r--parser.cpp1
-rw-r--r--search.cpp25
-rw-r--r--search.h6
3 files changed, 32 insertions, 0 deletions
diff --git a/parser.cpp b/parser.cpp
index 10c0ea3..bb05d66 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -1015,6 +1015,7 @@ StateStart::custom(gchar chr) throw (Error)
StateFCommand::StateFCommand() : State()
{
transitions['\0'] = this;
+ transitions['K'] = &States::searchkill;
transitions['D'] = &States::searchdelete;
transitions['S'] = &States::replace;
transitions['R'] = &States::replacedefault;
diff --git a/search.cpp b/search.cpp
index ea0613a..f27e744 100644
--- a/search.cpp
+++ b/search.cpp
@@ -13,6 +13,7 @@
namespace States {
StateSearch search;
StateSearchAll searchall;
+ StateSearchKill searchkill;
StateSearchDelete searchdelete;
StateReplace replace;
StateReplace_insert replace_insert;
@@ -495,6 +496,30 @@ StateSearchAll::done(const gchar *str) throw (Error)
}
State *
+StateSearchKill::done(const gchar *str) throw (Error)
+{
+ gint anchor;
+
+ BEGIN_EXEC(&States::start);
+
+ StateSearch::done(str);
+
+ undo.push_msg(SCI_GOTOPOS, interface.ssm(SCI_GETCURRENTPOS));
+ anchor = interface.ssm(SCI_GETANCHOR);
+ interface.ssm(SCI_GOTOPOS, anchor);
+
+ interface.ssm(SCI_BEGINUNDOACTION);
+ interface.ssm(SCI_DELETERANGE,
+ parameters.dot, anchor - parameters.dot);
+ interface.ssm(SCI_ENDUNDOACTION);
+ ring.dirtify();
+
+ undo.push_msg(SCI_UNDO);
+
+ return &States::start;
+}
+
+State *
StateSearchDelete::done(const gchar *str) throw (Error)
{
BEGIN_EXEC(&States::start);
diff --git a/search.h b/search.h
index 8a23ac6..12b95db 100644
--- a/search.h
+++ b/search.h
@@ -48,6 +48,11 @@ private:
State *done(const gchar *str) throw (Error);
};
+class StateSearchKill : public StateSearch {
+private:
+ State *done(const gchar *str) throw (Error);
+};
+
class StateSearchDelete : public StateSearch {
public:
StateSearchDelete(bool last = true) : StateSearch(last) {}
@@ -86,6 +91,7 @@ private:
namespace States {
extern StateSearch search;
extern StateSearchAll searchall;
+ extern StateSearchKill searchkill;
extern StateSearchDelete searchdelete;
extern StateReplace replace;
extern StateReplace_insert replace_insert;