The shift-selection trick in X terminal programs

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.)