[Xfce4-commits] [apps/xfce4-terminal] 01/01: Prepare for upcoming vte regex API change
noreply at xfce.org
noreply at xfce.org
Sun Aug 21 08:48:08 CEST 2016
This is an automated email from the git hooks/post-receive script.
f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.
commit fbae2d2f1c5a49e4f676e87bd408fe6b6f2ad993
Author: Igor <f2404 at yandex.ru>
Date: Sun Aug 21 09:48:03 2016 +0300
Prepare for upcoming vte regex API change
---
terminal/terminal-private.h | 28 ++++++++++++++++++++++++++++
terminal/terminal-screen.c | 1 -
terminal/terminal-screen.h | 1 +
terminal/terminal-search-dialog.c | 17 ++++++++++++++++-
terminal/terminal-search-dialog.h | 2 +-
terminal/terminal-widget.c | 20 +-------------------
6 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/terminal/terminal-private.h b/terminal/terminal-private.h
index 3570670..a970253 100644
--- a/terminal/terminal-private.h
+++ b/terminal/terminal-private.h
@@ -19,6 +19,34 @@
#define TERMINAL_PRIVATE_H
#include <glib-object.h>
+#include <vte/vte.h>
+
+/* Use new VTE regex API; this is to replace many ifs.
+ */
+#if VTE_CHECK_VERSION (0, 45, 90)
+
+#define PCRE2_CODE_UNIT_WIDTH 0
+#include <pcre2.h>
+
+#undef GRegex
+#define GRegex VteRegex
+
+#undef vte_terminal_match_add_gregex
+#define vte_terminal_match_add_gregex(terminal,regex,flags) vte_terminal_match_add_regex(terminal,regex,flags)
+
+#undef vte_terminal_search_get_gregex
+#define vte_terminal_search_get_gregex(terminal) vte_terminal_search_get_regex(terminal)
+
+#undef vte_terminal_search_set_gregex
+#define vte_terminal_search_set_gregex(terminal,regex,flags) vte_terminal_search_set_regex(terminal,regex,flags)
+
+#undef g_regex_ref
+#define g_regex_ref(regex) vte_regex_ref(regex)
+
+#undef g_regex_unref
+#define g_regex_unref(regex) vte_regex_unref(regex)
+
+#endif
G_BEGIN_DECLS
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index 4442bca..81eaaf5 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -44,7 +44,6 @@
#include <terminal/terminal-enum-types.h>
#include <terminal/terminal-image-loader.h>
#include <terminal/terminal-marshal.h>
-#include <terminal/terminal-private.h>
#include <terminal/terminal-screen.h>
#include <terminal/terminal-widget.h>
#include <terminal/terminal-window.h>
diff --git a/terminal/terminal-screen.h b/terminal/terminal-screen.h
index 1351b5a..d6265ec 100644
--- a/terminal/terminal-screen.h
+++ b/terminal/terminal-screen.h
@@ -21,6 +21,7 @@
#define TERMINAL_SCREEN_H
#include <gtk/gtk.h>
+#include <terminal/terminal-private.h>
G_BEGIN_DECLS
diff --git a/terminal/terminal-search-dialog.c b/terminal/terminal-search-dialog.c
index eb056ef..ee8fa01 100644
--- a/terminal/terminal-search-dialog.c
+++ b/terminal/terminal-search-dialog.c
@@ -29,7 +29,6 @@
#include <libxfce4ui/libxfce4ui.h>
#include <terminal/terminal-search-dialog.h>
-#include <terminal/terminal-private.h>
@@ -223,7 +222,11 @@ terminal_search_dialog_get_regex (TerminalSearchDialog *dialog,
GError **error)
{
const gchar *pattern;
+#if VTE_CHECK_VERSION (0, 45, 90)
+ guint32 flags = 0;
+#else
GRegexCompileFlags flags = G_REGEX_OPTIMIZE;
+#endif
gchar *pattern_escaped = NULL;
gchar *word_regex = NULL;
GRegex *regex;
@@ -241,10 +244,18 @@ terminal_search_dialog_get_regex (TerminalSearchDialog *dialog,
return NULL;
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->match_case)))
+#if VTE_CHECK_VERSION (0, 45, 90)
+ flags += PCRE2_CASELESS;
+#else
flags |= G_REGEX_CASELESS;
+#endif
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->match_regex)))
+#if VTE_CHECK_VERSION (0, 45, 90)
+ flags += PCRE2_MULTILINE;
+#else
flags |= G_REGEX_MULTILINE;
+#endif
else
{
pattern_escaped = g_regex_escape_string (pattern, -1);
@@ -257,7 +268,11 @@ terminal_search_dialog_get_regex (TerminalSearchDialog *dialog,
pattern = word_regex;
}
+#if VTE_CHECK_VERSION (0, 45, 90)
+ regex = vte_regex_new_for_search (pattern, -1, flags, error);
+#else
regex = g_regex_new (pattern, flags, 0, error);
+#endif
g_free (pattern_escaped);
g_free (word_regex);
diff --git a/terminal/terminal-search-dialog.h b/terminal/terminal-search-dialog.h
index 489ff02..01beea5 100644
--- a/terminal/terminal-search-dialog.h
+++ b/terminal/terminal-search-dialog.h
@@ -18,7 +18,7 @@
#ifndef TERMINAL_SEARCH_DIALOG_H
#define TERMINAL_SEARCH_DIALOG_H
-#include <vte/vte.h>
+#include <terminal-private.h>
G_BEGIN_DECLS
diff --git a/terminal/terminal-widget.c b/terminal/terminal-widget.c
index bc4d9d0..068fe2f 100644
--- a/terminal/terminal-widget.c
+++ b/terminal/terminal-widget.c
@@ -37,11 +37,6 @@
#include <terminal/terminal-widget.h>
#include <terminal/terminal-private.h>
-#if VTE_CHECK_VERSION (0, 46, 00)
-#define PCRE2_CODE_UNIT_WIDTH 0
-#include <pcre2.h>
-#endif
-
#define MAILTO "mailto:"
@@ -728,11 +723,7 @@ terminal_widget_update_highlight_urls (TerminalWidget *widget)
{
guint i;
gboolean highlight_urls;
-#if VTE_CHECK_VERSION (0, 46, 00)
- VteRegex *regex;
-#else
GRegex *regex;
-#endif
const TerminalRegexPattern *pattern;
GError *error;
@@ -764,7 +755,7 @@ terminal_widget_update_highlight_urls (TerminalWidget *widget)
/* build the regex */
error = NULL;
-#if VTE_CHECK_VERSION (0, 46, 00)
+#if VTE_CHECK_VERSION (0, 45, 90)
regex = vte_regex_new_for_match (pattern->pattern, -1,
PCRE2_CASELESS | PCRE2_UTF | PCRE2_NO_UTF_CHECK | PCRE2_MULTILINE,
&error);
@@ -782,21 +773,12 @@ terminal_widget_update_highlight_urls (TerminalWidget *widget)
}
/* set the new regular expression */
-#if VTE_CHECK_VERSION (0, 46, 00)
- widget->regex_tags[i] = vte_terminal_match_add_regex (VTE_TERMINAL (widget),
- regex, 0);
-#else
widget->regex_tags[i] = vte_terminal_match_add_gregex (VTE_TERMINAL (widget),
regex, 0);
-#endif
vte_terminal_match_set_cursor_type (VTE_TERMINAL (widget),
widget->regex_tags[i], GDK_HAND2);
/* release the regex owned by vte now */
-#if VTE_CHECK_VERSION (0, 46, 00)
- vte_regex_unref (regex);
-#else
g_regex_unref (regex);
-#endif
}
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list