From b2a47a50fdcd867335960d35966dc4cebe4c33c0 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 30 Mar 2020 18:21:43 -0300 Subject: [PATCH] Fix URLs are not clickable Improve integration with current VTE --- terminatorlib/terminal.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 6b0002da..46ee6cd7 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -142,8 +142,7 @@ class Terminal(Gtk.VBox): self.vte.show() self.default_encoding = self.vte.get_encoding() - self.regex_flags = (GLib.RegexCompileFlags.OPTIMIZE | \ - GLib.RegexCompileFlags.MULTILINE) + self.regex_flags = Vte.REGEX_FLAGS_DEFAULT self.update_url_matches() self.terminalbox = self.create_terminalbox() @@ -270,34 +269,34 @@ class Terminal(Gtk.VBox): re = (lboundry + schemes + "//(" + user + "@)?[" + hostchars +".]+(:[0-9]+)?(" + urlpath + ")?" + rboundry + "/?") - reg = GLib.Regex.new(re, self.regex_flags, 0) - self.matches['full_uri'] = self.vte.match_add_gregex(reg, 0) + reg = Vte.Regex.new_for_match(re, len(re), self.regex_flags) + self.matches['full_uri'] = self.vte.match_add_regex(reg, 0) if self.matches['full_uri'] == -1: err ('Terminal::update_url_matches: Failed adding URL matches') else: re = (lboundry + - '(callto:|h323:|sip:)' + "[" + userchars + "+][" + - userchars + ".]*(:[0-9]+)?@?[" + pathchars + "]+" + + '(callto:|h323:|sip:)' + "[" + userchars + "+][" + + userchars + ".]*(:[0-9]+)?@?[" + pathchars + "]+" + rboundry) - reg = GLib.Regex.new(re, self.regex_flags, 0) - self.matches['voip'] = self.vte.match_add_gregex(reg, 0) + reg = Vte.Regex.new_for_match(re, len(re), self.regex_flags) + self.matches['voip'] = self.vte.match_add_regex(reg, 0) re = (lboundry + - "(www|ftp)[" + hostchars + "]*\.[" + hostchars + + "(www|ftp)[" + hostchars + "]*\.[" + hostchars + ".]+(:[0-9]+)?(" + urlpath + ")?" + rboundry + "/?") - reg = GLib.Regex.new(re, self.regex_flags, 0) - self.matches['addr_only'] = self.vte.match_add_gregex(reg, 0) + reg = Vte.Regex.new_for_match(re, len(re), self.regex_flags) + self.matches['addr_only'] = self.vte.match_add_regex(reg, 0) re = (lboundry + "(mailto:)?[a-zA-Z0-9][a-zA-Z0-9.+-]*@[a-zA-Z0-9]" + "[a-zA-Z0-9-]*\.[a-zA-Z0-9][a-zA-Z0-9-]+" + "[.a-zA-Z0-9-]*" + rboundry) - reg = GLib.Regex.new(re, self.regex_flags, 0) - self.matches['email'] = self.vte.match_add_gregex(reg, 0) + reg = Vte.Regex.new_for_match(re, len(re), self.regex_flags) + self.matches['email'] = self.vte.match_add_regex(reg, 0) re = (lboundry + """news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@""" + "[-A-Za-z0-9.]+(:[0-9]+)?" + rboundry) - reg = GLib.Regex.new(re, self.regex_flags, 0) - self.matches['nntp'] = self.vte.match_add_gregex(reg, 0) + reg = Vte.Regex.new_for_match(re, len(re), self.regex_flags) + self.matches['nntp'] = self.vte.match_add_regex(reg, 0) # Now add any matches from plugins try: @@ -311,9 +310,9 @@ class Terminal(Gtk.VBox): if name in self.matches: dbg('refusing to add duplicate match %s' % name) continue - reg = GLib.Regex.new(match, self.regex_flags, 0) - self.matches[name] = self.vte.match_add_gregex(reg, 0) - dbg('added plugin URL handler for %s (%s) as %d' % + reg = Vte.Regex.new_for_match(match, len(match), self.regex_flags) + self.matches[name] = self.vte.match_add_regex(reg, 0) + dbg('added plugin URL handler for %s (%s) as %d' % (name, urlplugin.__class__.__name__, self.matches[name])) except Exception as ex: @@ -324,8 +323,8 @@ class Terminal(Gtk.VBox): if name in self.matches: err('Terminal::match_add: Refusing to create duplicate match %s' % name) return - reg = GLib.Regex.new(match, self.regex_flags, 0) - self.matches[name] = self.vte.match_add_gregex(reg, 0) + reg = Vte.Regex.new_for_match(match, len(match), self.regex_flags) + self.matches[name] = self.vte.match_add_regex(reg, 0) def match_remove(self, name): """Remove a previously registered URL match"""