简体   繁体   中英

escape codes VT102 and ANSI

I use minicom to communicate, via serial line, with a device that dumps the characters received in hexadecimal. I do this to see the escape codes for some keys. I tried minicom once with VT102 terminal emulation and once ANSI.

For both VT102 and ANSI, the arrow keys correspond to

Up:    Esc [ A
Down:  Esc [ B
Right: Esc [ C
Left:  Esc [ D

This is matches what I find in several websites, for example VT102 User Guide

I tried other keys for which I cannot find any reference throughout the web:

            VT102         ANSI
Home:     Esc [ 1 ~      Esc [ H
End:      Esc O F        Esc O F
Insert:   Esc [ 2 ~      Esc [ @

Are these codes standard? And what standard? where can I find a match on the internet?

If I try by command line (xfce-terminal), pressing Home, End and Insert in this order:

$ cat | hexdump -C
^[[H^[[F^[[2~00000000  1b 5b 48 1b 5b 46 1b 5b  32 7e                    |.[H.[F.[2~|

It seems that Home is equal to Minicom ANSI sequence, End change the 'O' into '[', and Insert is equal to Minicom VT102 escape sequence.
The same running GtkTerm.

I tried also with TeraTerm on Windows, with still different results.

Summarising

           Minicom VT102        Minicom ANSI    xfce-terminal & GtkTerm    TeraTerm VT100/VT102
Home:         Esc [ 1 ~           Esc [ H              Esc [ H                   Esc [ 1 ~
End:          Esc O F             Esc O F              Esc [ F                   Esc [ 4 ~
Insert:       Esc [ 2 ~           Esc [ @              Esc [ 2 ~                 Esc [ 2 ~

There's no standard for special keys . The existing standards (most recently, ECMA-48 last revised in 1991) only deal with control sequences which an application can send to the terminal (with a very small number of control sequences which elicit a response from the terminal).

Special keys (and the most commonly-used control sequences) are documented in terminal databases such as ncurses's. But in reading a terminal description, you have to keep in mind that many terminals can send different escape sequences (or none at all) depending on the mode they're set to. That would be documented by the developers of those terminal emulators , but for the given examples, the developers do not provide that information.

What's in ncurses is the only documentation: xfce terminal and gtkterm are "skins" using VTE for all of the relevant functionality. If you look at the dependencies for those, you'll see some version information which can be related to the descriptions in ncurses (start here ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM