Re: [dev] [st] Terminal abnormal key codes

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Wed, 2 Sep 2015 16:13:25 +0200

Hi,

> Our question is probably better stated as the following:
>
> st seems to e.g. send "[P" for delete instead of the '\E[3;2~' in
> terminfo (which fish does use), unless we explicitly do the equivalent
> of "tput smkx". This not only applies to delete, but a few other key
> combinations as well, like insert or ctrl-up.
>
> Of course this is stated in the FAQ, but the question is _why_ is it
> this way and is it possible to change that?

Because there are two ways of using the terminal, in ASCII mode and in
application mode. Maybe you only use the terminal in application mode,
but some of us (mainly me) use the terminal for other kind of things,
connecting to non POSIX machines, over serial lines, and in these cases
we use this mode. St is not only a Unix place where ppl can write unix
commands (take a look to -l switch of st).

> From our perspective st is the only terminal (we've found at least) that
> behaves this way - every other term (like xterm, konsole or linux VTs)
> seems to not need this and just always sends the sequences specified in
> terminfo.

You are wrong:

$ curl http://www.catb.org/esr/terminfo/termtypes.ti.gz 2>/dev/null |
 gunzip |
 sed 's/#.*//g' |
 grep -c smkx
111

There are 111 definitions in the official terminfo definition which
use smkx. Maybe you don't use any of them, but some of use use
some of them. For example I have a physical vt500 that I use as
console in several of my servers, and it has smkx sequence. Are
you saying me that I am going to be able to use fish in this
terminal? and only because you are too lazy to follow the terminfo
standard?

> There's two things we can do on our side - do "tput smkx" and "tput
> rmkx" either only in st or always (which I don't know if it'll break
> stuff elsewhere) or bind both kinds of sequences st sends, neither
> solution being _great_.

It should not break anything. If the terminal does not define smkx
you will not print anything, and if the terminal define it is because
it needs the sequence. All the application which use curses work
without problems in st when they try to match any key. mainly because
curses follows the terminfo specification perfectly.

> So: Is there a rationale for that decision and would you consider
> changing it?

Changing the key assignation is st is very simple, all the table
is in config.h file. In the past we have changed the key assignation
(we transformed backspace key in a delete key), and it is something
we can do again, although it is going to be a pain in the ass
because we already updated the definition of st in the official
terminfo definition. I will admit a patch like this if all the
another suckless developer agree, which I don't think will happen
(I will continue with my custom key assignation), but even in this
case you must fix your shell, because if you don't follow the
terminfo rules it will not be able to run in a lot of different
terminals.

The question here is, why do you want to write a shell knowing
it has bugs and it will not be able of running in all the possible
(current or future) terminals?

Regards,
Received on Wed Sep 02 2015 - 16:13:25 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 02 2015 - 16:24:10 CEST