Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions terminatorlib/terminal_popup_menu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terminator by Chris Jones <cmsj@tenshu.net>
# GPL v2 only
"""terminal_popup_menu.py - classes necessary to provide a terminal context
"""terminal_popup_menu.py - classes necessary to provide a terminal context
menu"""

from gi.repository import Gtk, Gdk
Expand Down Expand Up @@ -97,7 +97,27 @@ def show(self, widget, event=None):
self.config.set_profile(terminal.get_profile())

if event:
url = terminal.vte.match_check_event(event)
url = terminal.vte.hyperlink_check_event(event)

if url:
tag = None

for pattern, tag in terminal.matches.items():
try:
if re.search(pattern, url):
tag = tag

break
except Exception:
continue

if tag is not None:
url = [url, tag]
else:
url = terminal.vte.match_check_event(event)
else:
url = terminal.vte.match_check_event(event)

button = event.button
time = event.time
else:
Expand Down Expand Up @@ -146,11 +166,13 @@ def show(self, widget, event=None):
Gtk.IconSize.MENU)
item = Gtk.ImageMenuItem.new_with_mnemonic(nameopen)
item.set_property('image', icon)
item.set_tooltip_text(url[0])
item.connect('activate', lambda x: terminal.open_url(url, True))
menu.append(item)

item = Gtk.MenuItem.new_with_mnemonic(namecopy)
item.connect('activate',
item.set_tooltip_text(url[0])
item.connect('activate',
lambda x: terminal.clipboard.set_text(terminal.prepare_url(url), len(terminal.prepare_url(url))))
menu.append(item)

Expand All @@ -172,7 +194,7 @@ def show(self, widget, event=None):
_('Set _Window Title'))
item.connect('activate', lambda x: terminal.key_edit_window_title())
menu.append(item)

if not terminal.is_zoomed():
item = self.menu_item(Gtk.ImageMenuItem, 'split_auto',
_('Split _Auto'))
Expand Down Expand Up @@ -346,7 +368,7 @@ def show(self, widget, event=None):
plugins = registry.get_plugins_by_capability('terminal_menu')
for menuplugin in plugins:
menuplugin.callback(menuitems, menu, terminal)

if len(menuitems) > 0:
menu.append(Gtk.SeparatorMenuItem())

Expand Down
Loading