add support for OSC-8

This commit is contained in:
Matt Rose 2020-07-20 17:19:21 -04:00
parent 0cbdbd89a2
commit 8d783364e6
1 changed files with 13 additions and 3 deletions

View File

@ -135,6 +135,7 @@ class Terminal(Gtk.VBox):
self.pending_on_vte_size_allocate = False self.pending_on_vte_size_allocate = False
self.vte = Vte.Terminal() self.vte = Vte.Terminal()
self.vte.set_allow_hyperlink(True)
self.vte._draw_data = None self.vte._draw_data = None
if not hasattr(self.vte, "set_opacity") or \ if not hasattr(self.vte, "set_opacity") or \
not hasattr(self.vte, "is_composited"): not hasattr(self.vte, "is_composited"):
@ -143,6 +144,7 @@ class Terminal(Gtk.VBox):
self.composite_support = True self.composite_support = True
dbg('composite_support: %s' % self.composite_support) dbg('composite_support: %s' % self.composite_support)
self.vte.show() self.vte.show()
self.default_encoding = self.vte.get_encoding() self.default_encoding = self.vte.get_encoding()
@ -955,9 +957,17 @@ class Terminal(Gtk.VBox):
middle_click = [self.paste_clipboard, (True, )] middle_click = [self.paste_clipboard, (True, )]
right_click = [self.popup_menu, (widget, event)] right_click = [self.popup_menu, (widget, event)]
### Ctrl-click event here.
if event.button == self.MOUSEBUTTON_LEFT: if event.button == self.MOUSEBUTTON_LEFT:
# Ctrl+leftclick on a URL should open it # Ctrl+leftclick on a URL should open it
if event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK: if event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK:
## Check new OSC-8 method first
url = self.vte.hyperlink_check_event(event)
dbg('url: %s' % url)
if url:
self.open_url(url, prepare=False)
else:
dbg('OSC-8 URL not detected dropping back to regex match')
url = self.vte.match_check_event(event) url = self.vte.match_check_event(event)
if url[0]: if url[0]:
self.open_url(url, prepare=True) self.open_url(url, prepare=True)