[vte] widget: Move some public API to its own file



commit 95f1b9900e744b4dd9520ae7372333b5a00c5a20
Author: Christian Persch <chpe gnome org>
Date:   Wed Nov 18 21:15:43 2015 +0100

    widget: Move some public API to its own file

 src/vte.cc         |  126 +++++++++++++++++-----------------------------------
 src/vtegtk.cc      |   78 ++++++++++++++++++++++++++++++++
 src/vteinternal.hh |    7 +++
 3 files changed, 126 insertions(+), 85 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 95a044b..f95487e 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -12542,116 +12542,72 @@ vte_terminal_write_contents_sync (VteTerminal *terminal,
 
 /* TODO Add properties & signals */
 
-/**
- * vte_terminal_search_set_regex:
- * @terminal: a #VteTerminal
- * @regex: (allow-none): a #VteRegex, or %NULL
+#ifdef WITH_PCRE2
+
+/*
+ * VteTerminalPrivate::search_set_regex:
+ * @regex: (allow-none): a #VteRegex, or %nullptr
  * @flags: PCRE2 match flags, or 0
  *
- * Sets the regex to search for. Unsets the search regex when passed %NULL.
- *
- * Since: 0.44
+ * Sets the regex to search for. Unsets the search regex when passed %nullptr.
  */
-void
-vte_terminal_search_set_regex (VteTerminal *terminal,
-                               VteRegex    *regex,
-                               guint32      flags)
+bool
+VteTerminalPrivate::search_set_regex (VteRegex *regex,
+                                      guint32 flags)
 {
-        struct vte_regex_and_flags *search_regex;
-
-        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+        struct vte_regex_and_flags *rx;
 
-        search_regex = &terminal->pvt->search_regex;
+        rx = &m_search_regex;
 
-        if (search_regex->mode == VTE_REGEX_PCRE2 &&
-            search_regex->pcre.regex == regex &&
-            search_regex->pcre.match_flags == flags)
-                return;
+        if (rx->mode == VTE_REGEX_PCRE2 &&
+            rx->pcre.regex == regex &&
+            rx->pcre.match_flags == flags)
+                return false;
 
-        regex_and_flags_clear(search_regex);
+        regex_and_flags_clear(rx);
 
         if (regex != NULL) {
-                search_regex->mode = VTE_REGEX_PCRE2;
-                search_regex->pcre.regex = vte_regex_ref(regex);
-                search_regex->pcre.match_flags = flags;
+                rx->mode = VTE_REGEX_PCRE2;
+                rx->pcre.regex = vte_regex_ref(regex);
+                rx->pcre.match_flags = flags;
         }
 
-       _vte_invalidate_all (terminal);
-}
+       invalidate_all();
 
-/**
- * vte_terminal_search_get_regex:
- * @terminal: a #VteTerminal
- *
- * Returns: (transfer none): the search #VteRegex regex set in @terminal, or %NULL
- *
- * Since: 0.44
- */
-VteRegex *
-vte_terminal_search_get_regex(VteTerminal *terminal)
-{
-       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
-
-        if (G_LIKELY(terminal->pvt->search_regex.mode == VTE_REGEX_PCRE2))
-                return terminal->pvt->search_regex.pcre.regex;
-        else
-                return NULL;
+        return true;
 }
 
-/**
- * vte_terminal_search_set_gregex:
- * @terminal: a #VteTerminal
- * @gregex: (allow-none): a #GRegex, or %NULL
+#endif /* WITH_PCRE2 */
+
+/*
+ * VteTerminalPrivate::search_set_gregex:
+ * @gregex: (allow-none): a #GRegex, or %nullptr
  * @gflags: flags from #GRegexMatchFlags
  *
- * Sets the #GRegex regex to search for. Unsets the search regex when passed %NULL.
- *
- * Deprecated: 0.44: use vte_terminal_search_set_regex() instead.
+ * Sets the #GRegex regex to search for. Unsets the search regex when passed %nullptr.
  */
-void
-vte_terminal_search_set_gregex (VteTerminal *terminal,
-                               GRegex      *gregex,
-                                GRegexMatchFlags gflags)
+bool
+VteTerminalPrivate::search_set_gregex(GRegex *gregex,
+                                      GRegexMatchFlags gflags)
 {
-        struct vte_regex_and_flags *search_regex;
-
-        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+        struct vte_regex_and_flags *rx = &m_search_regex;
 
-        search_regex = &terminal->pvt->search_regex;
-
-        if (search_regex->mode == VTE_REGEX_GREGEX &&
-            search_regex->gregex.regex == gregex &&
-            search_regex->gregex.match_flags == gflags)
-                return;
+        if (rx->mode == VTE_REGEX_GREGEX &&
+            rx->gregex.regex == gregex &&
+            rx->gregex.match_flags == gflags)
+                return false;
 
-        regex_and_flags_clear(search_regex);
+        regex_and_flags_clear(rx);
 
         if (gregex != NULL) {
-                search_regex->mode = VTE_REGEX_GREGEX;
-                search_regex->gregex.regex = g_regex_ref(gregex);
-                search_regex->gregex.match_flags = gflags;
+                rx->mode = VTE_REGEX_GREGEX;
+                rx->gregex.regex = g_regex_ref(gregex);
+                rx->gregex.match_flags = gflags;
         }
 
-       _vte_invalidate_all (terminal);
-}
+       invalidate_all();
 
-/**
- * vte_terminal_search_get_gregex:
- * @terminal: a #VteTerminal
- *
- * Returns: (transfer none): the search #GRegex regex set in @terminal, or %NULL
- *
- * Deprecated: 0.44: use vte_terminal_search_get_regex() instead.
- */
-GRegex *
-vte_terminal_search_get_gregex (VteTerminal *terminal)
-{
-       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
-
-        if (G_LIKELY(terminal->pvt->search_regex.mode == VTE_REGEX_GREGEX))
-                return terminal->pvt->search_regex.gregex.regex;
-        else
-                return NULL;
+        return true;
 }
 
 bool
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 5ed3d02..75cdef6 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -1545,6 +1545,84 @@ vte_terminal_search_find_next (VteTerminal *terminal)
 }
 
 /**
+ * vte_terminal_search_set_regex:
+ * @terminal: a #VteTerminal
+ * @regex: (allow-none): a #VteRegex, or %NULL
+ * @flags: PCRE2 match flags, or 0
+ *
+ * Sets the regex to search for. Unsets the search regex when passed %NULL.
+ *
+ * Since: 0.44
+ */
+void
+vte_terminal_search_set_regex (VteTerminal *terminal,
+                               VteRegex    *regex,
+                               guint32      flags)
+{
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+        terminal->pvt->search_set_regex(regex, flags);
+}
+
+/**
+ * vte_terminal_search_get_regex:
+ * @terminal: a #VteTerminal
+ *
+ * Returns: (transfer none): the search #VteRegex regex set in @terminal, or %NULL
+ *
+ * Since: 0.44
+ */
+VteRegex *
+vte_terminal_search_get_regex(VteTerminal *terminal)
+{
+       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
+
+        if (G_LIKELY(terminal->pvt->search_regex.mode == VTE_REGEX_PCRE2))
+                return terminal->pvt->search_regex.pcre.regex;
+        else
+                return NULL;
+}
+
+/**
+ * vte_terminal_search_set_gregex:
+ * @terminal: a #VteTerminal
+ * @gregex: (allow-none): a #GRegex, or %NULL
+ * @gflags: flags from #GRegexMatchFlags
+ *
+ * Sets the #GRegex regex to search for. Unsets the search regex when passed %NULL.
+ *
+ * Deprecated: 0.44: use vte_terminal_search_set_regex() instead.
+ */
+void
+vte_terminal_search_set_gregex (VteTerminal *terminal,
+                               GRegex      *gregex,
+                                GRegexMatchFlags gflags)
+{
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+        terminal->pvt->search_set_gregex(gregex, gflags);
+}
+
+/**
+ * vte_terminal_search_get_gregex:
+ * @terminal: a #VteTerminal
+ *
+ * Returns: (transfer none): the search #GRegex regex set in @terminal, or %NULL
+ *
+ * Deprecated: 0.44: use vte_terminal_search_get_regex() instead.
+ */
+GRegex *
+vte_terminal_search_get_gregex (VteTerminal *terminal)
+{
+       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
+
+        if (G_LIKELY(terminal->pvt->search_regex.mode == VTE_REGEX_GREGEX))
+                return terminal->pvt->search_regex.gregex.regex;
+        else
+                return NULL;
+}
+
+/**
  * vte_terminal_search_set_wrap_around:
  * @terminal: a #VteTerminal
  * @wrap_around: whether search should wrap
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index f982b65..7ba6b75 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -573,6 +573,13 @@ public:
         void feed_focus_event(bool in);
         void maybe_feed_focus_event(bool in);
 
+#ifdef WITH_PCRE2
+        bool search_set_regex (VteRegex *regex,
+                               guint32 flags);
+#endif
+        bool search_set_gregex (GRegex *gregex,
+                                GRegexMatchFlags gflags);
+
         bool search_rows(
 #ifdef WITH_PCRE2
                          pcre2_match_context_8 *match_context,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]