bug-ncurses
[Top][All Lists]
Advanced

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

Re: Question about triggering KEY_MOUSE


From: Bryan Christ
Subject: Re: Question about triggering KEY_MOUSE
Date: Wed, 2 Jan 2019 09:54:12 -0600

Timothy,

Thanks for the explanation.  I went down that route yesterday and added some extra flags so that my emulator would
announce as "xterm" instead of "rxvt" via TERM.  Some stuff did break but it was way less than I expected--of course
that's just surface level testing.

But I still have a nagging question.

If xfce is really vte masquerading as xterm (via TERM) and the vanilla terminfo entry for xterm doesn't have XM
defined, how does ncurses know that it can do some mode better than X10?  Empirically, I know that ncurses under
xfce must be supporting something better than X10 because mouse tracking and events work even when the term
is sized way beyond 233 columns.


On Tue, Jan 1, 2019 at 11:30 PM Timothy Allen <address@hidden> wrote:
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
ecosystem.

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
https://invisible-island.net/ncurses/ncurses.faq.html#xterm_generic



--
Bryan
<><

reply via email to

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