The shift-selection trick in X terminal programs

July 29, 2009

Seeing this today reminded me of a relatively obscure feature and counter-feature in xterm and similar imitators like gnome-terminal and konsole.

First, the feature (sometimes 'feature'): in order to let text mode programs still have clickable objects, xterm lets programs steal left mouse (button-1) clicks; instead of selecting text, the program gets escape sequences that tell it about the click and it can do whatever it wants with them. The most obvious application is text-mode web browsers like links, which uses it to let you click on links.

(The Xterm Control Sequences documentation calls this 'mouse tracking'.)

This spawned an immediate demand for a counter-feature, and so in xterm and its imitators shift plus left mouse button always selects text, even if a program has put xterm in this special mouse tracking mode. In xterm, all of the usual double and triple click selection tricks work when shifted; your mileage may vary in gnome-terminal et al.

This doesn't seem to be documented in the xterm manpage, so I'm not sure where I learned it; it may have been ambient X knowledge at some point back in the days, and I just picked it up. It's fortunate that it seems to have been well enough known to be copied by the people writing gnome-terminal, konsole, and so on.

(xterm has a great deal of peculiar features that are at best half-known these days, or that usually take careful study of the manpage to spot.)

Written on 29 July 2009.
« Spammers are quite dedicated in their address scraping
How we do custom NFS mount authorization on Solaris 10 »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed Jul 29 01:13:27 2009
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.