aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/search.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/search.h')
-rw-r--r--src/search.h130
1 files changed, 8 insertions, 122 deletions
diff --git a/src/search.h b/src/search.h
index 0289423..8314f06 100644
--- a/src/search.h
+++ b/src/search.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2017 Robin Haberkorn
+ * Copyright (C) 2012-2021 Robin Haberkorn
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,127 +14,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#pragma once
-#ifndef __SEARCH_H
-#define __SEARCH_H
-
-#include <glib.h>
-
-#include "sciteco.h"
#include "parser.h"
-#include "ring.h"
-#include "qregisters.h"
-
-namespace SciTECO {
-
-/*
- * "S" command state and base class for all other search/replace commands
- */
-class StateSearch : public StateExpectString {
-public:
- StateSearch(bool last = true) : StateExpectString(true, last) {}
-
-protected:
- struct Parameters {
- gint dot;
- gint from, to;
- gint count;
-
- Buffer *from_buffer, *to_buffer;
- } parameters;
-
- QRegSpecMachine qreg_machine;
-
- enum MatchState {
- STATE_START,
- STATE_NOT,
- STATE_CTL_E,
- STATE_ANYQ,
- STATE_MANY,
- STATE_ALT
- };
-
- gchar *class2regexp(MatchState &state, const gchar *&pattern,
- bool escape_default = false);
- gchar *pattern2regexp(const gchar *&pattern, bool single_expr = false);
- void do_search(GRegex *re, gint from, gint to, gint &count);
-
- virtual void initial(void);
- virtual void process(const gchar *str, gint new_chars);
- virtual State *done(const gchar *str);
-};
-
-class StateSearchAll : public StateSearch {
-private:
- void initial(void);
- State *done(const gchar *str);
-};
-
-class StateSearchKill : public StateSearch {
-private:
- State *done(const gchar *str);
-};
-
-class StateSearchDelete : public StateSearch {
-public:
- StateSearchDelete(bool last = true) : StateSearch(last) {}
-
-protected:
- State *done(const gchar *str);
-};
-
-class StateReplace : public StateSearchDelete {
-public:
- StateReplace() : StateSearchDelete(false) {}
-
-private:
- State *done(const gchar *str);
-};
-
-class StateReplace_insert : public StateInsert {
-private:
- void initial(void) {}
-};
-
-class StateReplace_ignore : public StateExpectString {
-private:
- State *done(const gchar *str);
-};
-
-class StateReplaceDefault : public StateSearchDelete {
-public:
- StateReplaceDefault() : StateSearchDelete(false) {}
-
-private:
- State *done(const gchar *str);
-};
-
-class StateReplaceDefault_insert : public StateInsert {
-private:
- void initial(void) {}
- State *done(const gchar *str);
-};
-
-class StateReplaceDefault_ignore : public StateExpectString {
-private:
- State *done(const gchar *str);
-};
-
-namespace States {
- extern StateSearch search;
- extern StateSearchAll searchall;
- extern StateSearchKill searchkill;
- extern StateSearchDelete searchdelete;
-
- extern StateReplace replace;
- extern StateReplace_insert replace_insert;
- extern StateReplace_ignore replace_ignore;
-
- extern StateReplaceDefault replacedefault;
- extern StateReplaceDefault_insert replacedefault_insert;
- extern StateReplaceDefault_ignore replacedefault_ignore;
-}
-
-} /* namespace SciTECO */
-#endif
+TECO_DECLARE_STATE(teco_state_search);
+TECO_DECLARE_STATE(teco_state_search_all);
+TECO_DECLARE_STATE(teco_state_search_kill);
+TECO_DECLARE_STATE(teco_state_search_delete);
+TECO_DECLARE_STATE(teco_state_replace);
+TECO_DECLARE_STATE(teco_state_replace_default);