Merge pull request #401 from jelly/gregex_deprecated

Replace deprecated gregex api
This commit is contained in:
jelle van der Waa 2017-06-19 21:00:34 +02:00 committed by GitHub
commit 4c1a9a56a2
1 changed files with 16 additions and 10 deletions

View File

@ -32,6 +32,9 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <vte/vte.h> #include <vte/vte.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#endif #endif
@ -1176,10 +1179,13 @@ GtkTreeModel *create_completion_model(VteTerminal *vte) {
void search(VteTerminal *vte, const char *pattern, bool reverse) { void search(VteTerminal *vte, const char *pattern, bool reverse) {
auto terminal_search = reverse ? vte_terminal_search_find_previous : vte_terminal_search_find_next; auto terminal_search = reverse ? vte_terminal_search_find_previous : vte_terminal_search_find_next;
GRegex *regex = vte_terminal_search_get_gregex(vte); VteRegex *regex = vte_terminal_search_get_regex(vte);
if (regex) g_regex_unref(regex); if (regex) vte_regex_unref(regex);
regex = g_regex_new(pattern, (GRegexCompileFlags)0, (GRegexMatchFlags)0, nullptr); vte_terminal_search_set_regex(vte,
vte_terminal_search_set_gregex(vte, regex, (GRegexMatchFlags)0); vte_regex_new_for_search(pattern,
(gssize) strlen(pattern),
PCRE2_MULTILINE | PCRE2_CASELESS,
nullptr), 0);
if (!terminal_search(vte)) { if (!terminal_search(vte)) {
vte_terminal_unselect_all(vte); vte_terminal_unselect_all(vte);
@ -1411,12 +1417,12 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
} }
if (info->clickable_url) { if (info->clickable_url) {
info->tag = vte_terminal_match_add_gregex(vte, info->tag = vte_terminal_match_add_regex(vte,
g_regex_new(url_regex, vte_regex_new_for_match(url_regex,
(GRegexCompileFlags)(G_REGEX_CASELESS | G_REGEX_MULTILINE), (gssize) strlen(url_regex),
G_REGEX_MATCH_NOTEMPTY, PCRE2_MULTILINE | PCRE2_NOTEMPTY,
nullptr), nullptr),
(GRegexMatchFlags)0); 0);
vte_terminal_match_set_cursor_type(vte, info->tag, GDK_HAND2); vte_terminal_match_set_cursor_type(vte, info->tag, GDK_HAND2);
} else if (info->tag != -1) { } else if (info->tag != -1) {
vte_terminal_match_remove(vte, info->tag); vte_terminal_match_remove(vte, info->tag);