Hi,

there are terminfo caps ka1, kb2, ka3, kc1 and kc3 (numpad "cross"), which
have different meanings in various terminfos.

The documented way in terminfo(5) is:

       key_a1                      ka1      K1   upper left of keypad
       key_a3                      ka3      K3   upper right of keypad
       key_b2                      kb2      K2   center of keypad
       key_c1                      kc1      K4   lower left of keypad
       key_c3                      kc3      K5   lower right of keypad

So, they are assigned to keypad keys (in application mode) using chess-like
addressing (in vt220+keypad). Virtually every documentation, including
older ones, document these keys the same. For example, see The Single UNIX
Specification version 2 from 1997 or GNU termcap manual second edition from
1992 (
https://www.gnu.org/software/termutils/manual/termcap-1.3/html_mono/termcap.html
).

However, there are many terminfos in which they are assigned to keypad keys
1, 2, 3, 0 and decimal point (in vt100+keypad building block) instead. The
comment in terminfo.src explains that this was done as a compromise, to
allow mapping other keypad keys to termcap-enabled caps on older systems
with legacy termcap support.

But I think that nowadays this goes against the purpose of terminfo, which
is supposed to unify ambiguities rather than introduce them.

Caps with these ancient mappings (based on vt100+keypad) are inherited by
many terminfos - for example: putty, nsterm, mlterm or iterm.

Personally, I would appreciate it if at least putty definition could be
fixed. The current definition produces erroneous results, since the vast
majority of apps expect the standard cross-definition of the keys. The
error is noticeable e.g. in vim over putty, both with default
configurations (and with TERM=putty), where vim expects for example ka3 to
be 9/PgUp key, but because putty's terminfo defines it as 3/PgDn key,
3/PgDn behaves as 9/PgUp, while 9/PgUp produces nasty direct output of SS3
y. Another example is test/knight.c in ncurses, which uses KEY_A1 for the
up-left move, and so on.

I think putty should be fixed either to use=xterm+keypad, which it fully
supports in Xterm R6 mode and partially supports in default mode
(except kbeg=\EOE and kp5=\EOE, which are not documented by the latest
xterm anyway), or even better it should support default mode as:

kpZRO=\EOp, kpDOT=\EOn, kpADD=\EOl, kpCMA=\EOm, use=vt220+keypad

Currently, putty+keypad defines kp0-kp9 caps instead, but these appear to
be private to putty alone (except kp5) to this day.

And if compatibility allows, perhaps vt100+keypad should be updated instead
to correct all other terminals. But I don't know which apps, if any, still
presume ancient non-cross layout of ka1, kb2, ka3, kc1, kc3.

Best regards,

Jakub

Reply via email to