[vte/search: 1/2] Add buffer search API



commit 812fa94985488dda7d14992895c20ea632c04147
Author: Behdad Esfahbod <behdad behdad org>
Date:   Tue Apr 27 04:01:03 2010 -0400

    Add buffer search API
    
    Not performing any actual search right now.

 src/vte-private.h |    3 ++
 src/vte.c         |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/vte.h         |    9 +++++++
 3 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index d605975..595ee40 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -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;
diff --git a/src/vte.c b/src/vte.c
index 6157c55..1417223 100644
--- 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;
+}
diff --git a/src/vte.h b/src/vte.h
index f2fb8b0..bed9857 100644
--- 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);



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