inz.fi

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 3c6dc8bae866281c0d2cc9110b1f089dcf45d91e
parent ea4497e82f89ae7ab610ea0720450458b35c9664
Author: Santtu Lakkala <inz@inz.fi>
Date:   Thu, 11 Dec 2014 06:06:42 +0000

Keyboard URL launching in gnome-terminal

Diffstat:
Aposts/keyboard-url-launching-in-gnome-terminal.md | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/posts/keyboard-url-launching-in-gnome-terminal.md b/posts/keyboard-url-launching-in-gnome-terminal.md @@ -0,0 +1,15 @@ +# Keyboard URL launching in gnome-terminal + + While I have been trying to make my desktop experience lighter, I somehow keep grabbing onto gnome-terminal; I guess it's what I've used to use and that I know how to configure with anti-aliased fonts etc. However, the fact that it is missing the ability to launch URIs from command line was hindering my dwm workflow, so I decided to do something about it. + + First I tried to use different terminal, namely rxvt-unicode, which has the functionality, but couldn't configure it to my liking in reasonable time (freetype font spacing, mostly), I decided to see if I could hack gnome-terminal to do what I wanted. + + At first I used a quite naïve method, just going the characters one by one (from end to start) and calling the VTE check method for each; and while it worked reasonably well it turned out to be terribly slow in some scenarios, with a single scan taking more than a second on a reasonably powerful laptop. + + Since gnome-terminal stores the regexes also internally, it seemed like a good idea to try out if I could grab the whole contents of the terminal and run the regexes on it, and see if the results are faster. And indeed they were, but it yielded a slight bug with some uris being reported twice if they overlap. Lazy as I am, I chose to ignore this, and just go with it. + + After finding the URIs, it was just a matter of drawing them somehow and handling the keypresses to launch them. I chose a very simple launching mechanism, resembling that of the vimperator/pentadactyl hints mode. Each hint is allocated a character from a set (after the set runs out, the URIs are ignored). Then I drew these hints over the terminal like they were tooltips, and voilà . + + ![urilaunch](urilaunch.png)<p> +<p> + The resulting patch is 342 lines (226 lines added) and can be found from [here](http://inz.fi/p/gnome-terminal-uri-launch.patch). It should apply cleanly on top of gnome-terminal 3.6.2-0ubuntu1 (Ubuntu 14.10) and with fuzz on vanilla 3.6.2. Applying on top of master takes some handyman work. +\ No newline at end of file