Skip to content

Commit

Permalink
Merge pull request thestinger#401 from jelly/gregex_deprecated
Browse files Browse the repository at this point in the history
Replace deprecated gregex api
  • Loading branch information
jelly authored Jun 19, 2017
2 parents 909b803 + c1890ae commit 4c1a9a5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions termite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include <gtk/gtk.h>
#include <vte/vte.h>

#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>

#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
Expand Down Expand Up @@ -1176,10 +1179,13 @@ GtkTreeModel *create_completion_model(VteTerminal *vte) {
void search(VteTerminal *vte, const char *pattern, bool reverse) {
auto terminal_search = reverse ? vte_terminal_search_find_previous : vte_terminal_search_find_next;

GRegex *regex = vte_terminal_search_get_gregex(vte);
if (regex) g_regex_unref(regex);
regex = g_regex_new(pattern, (GRegexCompileFlags)0, (GRegexMatchFlags)0, nullptr);
vte_terminal_search_set_gregex(vte, regex, (GRegexMatchFlags)0);
VteRegex *regex = vte_terminal_search_get_regex(vte);
if (regex) vte_regex_unref(regex);
vte_terminal_search_set_regex(vte,
vte_regex_new_for_search(pattern,
(gssize) strlen(pattern),
PCRE2_MULTILINE | PCRE2_CASELESS,
nullptr), 0);

if (!terminal_search(vte)) {
vte_terminal_unselect_all(vte);
Expand Down Expand Up @@ -1411,12 +1417,12 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
}

if (info->clickable_url) {
info->tag = vte_terminal_match_add_gregex(vte,
g_regex_new(url_regex,
(GRegexCompileFlags)(G_REGEX_CASELESS | G_REGEX_MULTILINE),
G_REGEX_MATCH_NOTEMPTY,
nullptr),
(GRegexMatchFlags)0);
info->tag = vte_terminal_match_add_regex(vte,
vte_regex_new_for_match(url_regex,
(gssize) strlen(url_regex),
PCRE2_MULTILINE | PCRE2_NOTEMPTY,
nullptr),
0);
vte_terminal_match_set_cursor_type(vte, info->tag, GDK_HAND2);
} else if (info->tag != -1) {
vte_terminal_match_remove(vte, info->tag);
Expand Down

0 comments on commit 4c1a9a5

Please sign in to comment.