GNOME Bugzilla – Bug 709942
Allow for opening URLs displayed in the terminal without using the mouse
Last modified: 2021-06-10 20:35:23 UTC
Currently, gnome-terminal uses a VTE match to look for URLs and other clickable links, which you can then open either by <Ctrl>+clicking them or by right-click + Open Link. But both require to use the mouse. This patch, tested on both master and v3.8.4, offers an alternative. It provides a new feature to search for URLs that are in the currently visible region of the VTE buffer, and pops up a menu with one entry per URL that, when activated, opens the corresponding link in the browser. This feature is mapped to the <Ctrl>+<Shift>+U keybinding. This allows for opening any link that the user "sees" in the terminal without having his/her hands leave the keyboard. The popup menu is positioned at the center of the terminal window to avoid loosing the focus after activating a menu item (in sloppy-focus window managers), and each entry in the menu is nicely formatted like so: <b>Domain.tld</b> <span size="small">http://the-full.url.com/path</span> Hopefully I've covered all the bases for references cleanup, etc, but I'd appreciate a double check, especially with regard to 'match', which I add as a data property to each menu item and I'm not sure if those get freed by gtk_widget_destroy() or not.
Created attachment 257059 [details] [review] Implementing patch
I would have liked to be able to re-use the already compiled (and probably more accurate) regex that matches URLs from terminal-screen.c (in url_regexes[0]), but I wasn't sure how to cleanly export those to terminal-window.c without extensive changes to header files, etc.
I don't think getting all the text from vte, then running the matchers on it, is the right way. Instead, vte should have API for getting all the (visible) matches.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/7374.