Add buffer search API
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 27 Apr 2010 08:01:03 +0000 (04:01 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 27 Apr 2010 08:01:03 +0000 (04:01 -0400)
Not performing any actual search right now.

src/vte-private.h
src/vte.c
src/vte.h

index d605975..595ee40 100644 (file)
@@ -317,6 +317,9 @@ struct _VteTerminalPrivate {
        } match_start, match_end;
        gboolean show_match;
 
+       /* Search data. */
+       GRegex *search_regex;
+
        /* Data used when rendering the text which does not require server
         * resources and which can be kept after unrealizing. */
        PangoFontDescription *fontdesc;
index 6157c55..1417223 100644 (file)
--- a/src/vte.c
+++ b/src/vte.c
@@ -14532,3 +14532,64 @@ vte_terminal_write_contents (VteTerminal *terminal,
                                         stream, flags,
                                         cancellable, error);
 }
+
+
+/*
+ * Buffer search
+ */
+
+/* TODO Add properties & signals */
+
+void
+vte_terminal_search_set_gregex (VteTerminal *terminal,
+                               GRegex      *regex)
+{
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+       if (terminal->pvt->search_regex == regex)
+               return;
+
+       if (terminal->pvt->search_regex) {
+               g_regex_unref (terminal->pvt->search_regex);
+               terminal->pvt->search_regex = NULL;
+       }
+
+       if (regex)
+               terminal->pvt->search_regex = g_regex_ref (regex);
+
+       _vte_invalidate_all (terminal);
+}
+
+GRegex *
+vte_terminal_search_get_gregex (VteTerminal *terminal)
+{
+        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
+
+       return terminal->pvt->search_regex;
+}
+
+gboolean
+vte_terminal_search_find_previous (VteTerminal *terminal,
+                                  gboolean     wrap_around)
+{
+        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+
+       if (!terminal->pvt->search_regex)
+               return FALSE;
+
+       /* TODO */
+       return FALSE;
+}
+
+gboolean
+vte_terminal_search_find_next (VteTerminal *terminal,
+                              gboolean     wrap_around)
+{
+        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+
+       if (!terminal->pvt->search_regex)
+               return FALSE;
+
+       /* TODO */
+       return FALSE;
+}
index f2fb8b0..bed9857 100644 (file)
--- a/src/vte.h
+++ b/src/vte.h
@@ -425,6 +425,15 @@ char *vte_terminal_match_check(VteTerminal *terminal,
                               glong column, glong row,
                               int *tag);
 
+void      vte_terminal_search_set_gregex      (VteTerminal *terminal,
+                                              GRegex      *regex);
+GRegex   *vte_terminal_search_get_gregex      (VteTerminal *terminal);
+gboolean  vte_terminal_search_find_previous   (VteTerminal *terminal,
+                                              gboolean     wrap_around);
+gboolean  vte_terminal_search_find_next       (VteTerminal *terminal,
+                                              gboolean     wrap_around);
+
+
 /* Set the emulation type.  Most of the time you won't need this. */
 void vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation);
 const char *vte_terminal_get_emulation(VteTerminal *terminal);