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.

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, Add Comment.
Search:
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.