The xterm terminal emulator can do a lot more than just display text

August 8, 2021

Recently, a problem report on the fvwm mailing list caused me to discover that Vim can react to losing or gaining X keyboard focus, through automatic commands (specifically FocusGained and FocusLost). I'm sorry, did I say that Vim did that? Well, Vim does, but Vim isn't working alone; the venerable X terminal emulator xterm is a partner in this. Xterm, it turns out, can basically pass through a lot of X events to "terminal" programs running inside it, including FocusIn and FocusOut.

(Xterm also plays a role in Bash's bracketed paste mode. In fact the name for it comes from the fact that xterm will bracket pastes with special control sequences so you can recognize them.)

As you may have guessed by now, xterm (and things that copy it sufficiently completely) can do a lot more than just display text and emulate a DEC VT terminal. The XTerm Control Sequences documentation goes on at significant length, and it doesn't even fully describe everything it covers (it assumes you have a certain amount of existing knowledge about the area). These days, my impression is that XTerm is a fairly capable environment for implementing text-mode X based programs, one where you can get a lot of fairly raw X events (including focus ones) and react to them.

I've used xterm for long enough that this feels a little bit weird to me. I still think of xterm as a terminal emulator, not a general support environment for text-based programs to interact with X. But there's clearly a desire and a need for this sort of thing, both for full featured programs like Vim (which can do a lot in cooperation with xterm if you let it) and for features like Bash's bracketed paste mode.

(I may not like bracketed paste mode myself, but plenty of other people clearly do. I'm not going to stand in the way of them having that capability.)

PS: People who are interested in this in Vim might want to read the summary of the issue from the fvwm mailing list.

Comments on this page:

By SRV at 2021-08-09 20:55:38:

xterm can apparently handle graphics when run in Tektronix emulation mode:

I haven't tried this myself, but I recall seeing others using this on Irix many years ago.

By Christopher Barts at 2021-08-11 04:07:36:

XTerm does actual graphics, if it's been built to display sixels:

You can even build video players to output in sixel form:

XTerm also implements the Tektronix vector graphics terminal emulation. To see it in action, if you have gnuplot installed on your machine, run gnuplot, then at the gnuplot command-line:

set term xterm

plot sin(x)

Written on 08 August 2021.
« Some thoughts on new top-level domains being used for spam
The Firefox uMatrix addon is not quite dead (so far) »

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

Last modified: Sun Aug 8 22:47:14 2021
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.