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

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Wed, 2 Sep 2015 14:39:32 +0200

> How do you know that smkx should be '\E[?1h\E='? Is there any
> documentation about it?

http://www.vt100.net/docs/vt100-ug/chapter3.html#SM
http://www.vt100.net/docs/vt100-ug/chapter3.html#DECKPAM

There are two issues related to keyboard configuration in the terminal
world:

        - configuration of cursor keys
        - configuration of keypad

These keys have two ways of working, in ascii mode or in application mode.
In ascii mode they generate the ascii value expected by the terminal to
perform the desired functiona (for example in the case of DELETE it sends
ESC [ P which is the sequence to delete current character), and in application
mode they generate some sequence which allows one program to identify the key.
If a program needs to know if a key was pressed it has to activate the application
mode before of testing anything, or the terminal can generate the ASCII sequence
if the terminal was in ASCII mode.

> >If your program does not use terminfo(3)
> >(http://linux.die.net/man/3/setupterm), then is broken.
> >About the problems with DELETE, please take a look to
> >the FAQ (section Why doesn't the Del key work in some programs?)
>
> I had read the FAQ again and again, but I just doesn't understand why some applications
> doesn't work in st but works in other terminal, the FAQ just says that
> the applications are buggy.

Yes, because it means your program is not setting the correct mode,
and assume that DELETE is going to generate the same sequence in both
modes. Again, taken from terminfo(5):


        If the terminal has a keypad that transmits codes when the keys
        are pressed, this information can be given. Note that it is not
        possible to handle terminals where the keypad only works in
        local (this applies, for example, to the unshifted HP 2621 keys).
        If the keypad can be set to transmit or not transmit, give these
        codes as smkx and rmkx. Otherwise the keypad is assumed to
        always transmit.

Maybe is difficult to understand it, but I will say again: IF THE KEYPAD
CAN BE SET TO TRANSMIT OR NOT TRANSMIT, GIVE THESE CODES AS SMKX AND RMKX.
OTHERWISE THE KEYPAD IS ASSUMED TO ALWAYS TRANSMIT.

St gives values for smkx and rmkx, so if an application wants to read
the keypad it must print these sequences before. You can take the values
of these sequences usging the terminfo database, 'tput smkx' in the shell,
or the variable smkx after calling setupterm() if you link your C program
with terminfo.

Regards,
Received on Wed Sep 02 2015 - 14:39:32 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 02 2015 - 14:48:08 CEST