[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about triggering KEY_MOUSE

From: Timothy Allen
Subject: Re: Question about triggering KEY_MOUSE
Date: Wed, 02 Jan 2019 16:30:08 +1100
User-agent: Evolution 3.30.3-1

On Tue, 2019-01-01 at 22:33 -0600, Bryan Christ wrote:
> I also see XM defined for VTE.  But that just raises yet another
> question for me as to how ncurses knows that something like xfce is
> really VTE even though TERM is set to xterm.

Eh, that's one of the... infelicities of the terminal emulator

The way it's *supposed* to work is:

- every (hardware) terminal or (software) terminal emulator supports
some particular subset of the possible set of escape sequences
- the terminfo database has a record describing the behaviour and
capabilities of each terminal
- the terminal or terminal emulator arranges for $TERM to be set to the
correct name
- applications check $TERM, read the corresponding entry in the
terminfo database, and everything works beautifully

Unfortunately, the real world isn't quite so pretty:

- unlike hardware terminals, software terminals can be and are updated
regularly, so the proper terminfo entry for "footerm" today might be
quite different from the entry tomorrow.
- tools like SSH copy the value of $TERM to the remote host, but just
because I have a "footerm" terminfo entry on my local machine is no
guarantee that the remote host will have one, let alone one compatible
with my version of footerm.
- while mission-critical packages like timezone databases and
certificate databases get updated regularly even on stable, enterprise
OSs, terminal databases tend not to be. It's pretty frustrating if you
install a shiny new terminal emulator on your laptop, then can't get
any work done because when you connect to the server it says your
terminal doesn't exist.
- not every useful feature has a corresponding terminfo entry. For
example, many GUI-based terminals can notify the application inside
when the GUI window gains or loses keyboard focus, but there's no
terminfo string for enabling that, or for describing the notification
strings sent in response.
- some applications don't use terminfo, and just squirt escape codes at
stdout and hope they do the right thing.
- some applications try to guess whether the terminal will support a
sequence by examining $TERM, and often by checking to see if it starts
with "xterm".

Therefore, there's a lot of pressure for terminal emulator authors to
set $TERM to "xterm" or "xterm-256color" even if they aren't 100%
compatible: it's very likely that any given host will have *some*
version of xterm in its terminfo database, applications will turn on
all their fancy features, and many things will Just Work. Not
everything, by all means[1], but the failure mode for setting
TERM=xterm is generally less severe than the failure mode for setting
it to an unrecognised value.

It's a lot like the problem of web-browser user-agent strings, where a
modern browser like Chrome has to name-drop Safari, WebKit, kHTML,
Gecko and Mozilla in order to be sure websites will feed it the correct
input... except worse, because $TERM doesn't support any kind of
versioning or fallback.

So to answer your question, ncurses does *not* know that xfce is really
VTE; if $TERM is set to "xterm" then that's what ncurses will use, for
better or worse.

[1]: See 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]