Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terminfo smkx and Application Cursor Keys vs Application keypad

XTerm Control Sequences specifies the following key sequences:

CSI ? 1 h  → Application Cursor Keys (DECCKM)
CSI ? 1 l  → Normal Cursor Mode (DECOM)
CSI ? 66 h → Application keypad (DECNKM)
CSI ? 66 l → Numeric keypad (DECNKM)

and the Terminfo Source Format has the following entry:

Variable: keypad_xmit
Capname: smkx
Termcap: ks
Description: Put terminal in "keypad-transmit" mode

But the terminfo for xterm actually says smkx=\E[?1h\E=, which seems mixed up to me (smkx should affect the keypad, not the cursor keys, right?). What am I missing here?

like image 908
fornwall Avatar asked Jan 17 '14 00:01

fornwall


2 Answers

The line

CSI ? 1 h  → Normal Cursor Mode (DECOM)

probably should read

CSI ? 1 l  → Normal Cursor Keys (DECCKM)

There are two escape sequences in each of smkx and rmkx because these capabilities are used in curses, i.e., for the keypad function.

The manual page for ncurses (like others) does not say so explicitly, but the function applies to all of the special keys on the keyboard which have the ability to switch between normal and application mode. This is a well-known feature of smkx and rmkx, as for example in the xterm FAQ Why can't I use the cursor keys in (whatever) shell?.

Special keys on the keyboard may include these (depending on the type of terminal):

  • numeric keypad (on the extreme right of a PC keyboard)
  • editing keypad (6 keys between the main keyboard and the numeric keyboard)
  • cursor keys
  • function keys (commonly at the top of a PC keyboard)

The VT100 (which does not have function keys or editing keypad) has separate escape sequences for the other two categories. In VT220 (emulated by xterm), the editing keypad's normal/application mode is an extension of the VT100 DECCKM, (documented in XTerm Control Sequences). DEC did not define a corresponding feature for function keys; however if there were some terminal which supported this capability it would probably be used in smkx and rmkx.

like image 74
Thomas Dickey Avatar answered Oct 18 '22 11:10

Thomas Dickey


It looks like you are missing the \E= at the end of smkx.

ESC =     Application Keypad (DECKPAM).
ESC >     Normal Keypad (DECKPNM).

are listed on the XTerm Control Sequences page as well and you would expect them to affect the keypad.

I found a related question here: keyboard transmit mode in vt100 terminal emulator.

like image 30
Gavin Smith Avatar answered Oct 18 '22 10:10

Gavin Smith