GNOME Bugzilla – Bug 566430
no application mode on numeric keypad
Last modified: 2018-05-17 12:22:46 UTC
Please describe the problem: vte library based terminal emulators like xfce4-terminal or gnome-terminal do not have an application mode for the numeric keypad. For example, xterm sends the following sequences (^[ is ESCAPE) when in application mode when pressing the keys on the right side numeric key block: 0 : ^[0p 1 : ^[Oq 2 : ^[Or 3 : ^[Os 4 : ^[Ot 5 : ^[Ou 6 : ^[Ov 7 : ^[Ow 8 : ^[Ox 9 : ^[Oy + : ^[Ok Enter : ^[OM These application mode control sequences were first intruduced with the DEC VT100 terminal (around 1980) and all VTxxx terminals and terminal emulators have supported them so far (e.g. xterm). I have a lot of applications which are controlled by the numeric keypad in application mode, most important emacs or jed in edt-mode. Not having application mode is a KO-qualifier for me and my users. X11 has different keysyms for the numeric keys row above the main keyboard and the numeric keypad block at the right side. For example for "0": KeyRelease event, serial 32, synthetic NO, window 0x4a00002, root 0xca, subw 0x0, time 478578919, (502,51), root:(1253,494), state 0x0, keycode 19 (keysym 0x30, 0), same_screen YES, XLookupString gives 1 bytes: (30) "0" KeyRelease event, serial 32, synthetic NO, window 0x4a00002, root 0xca, subw 0x0, time 478581878, (502,51), root:(1253,494), state 0x0, keycode 90 (keysym 0xffb0, KP_0), same_screen YES, XLookupString gives 1 bytes: (30) "0" With xfce4-terminal or gnome-terminal I cannot determine which "0" key was pressed, because both keys deliver the same string "0" to the application running in the terminal. Steps to reproduce: Within bash, pressing Ctrl-V KP_0 (this is the key 0 on the right keyboard side) Actual results: I get the string "0" Expected results: I should get the string "^[0p" Does this happen every time? always. Other information: I reported this bug first at http://bugzilla.xfce.org/show_bug.cgi?id=3558 but the Xfce people say it is a Gnome/vte problem.
I looked into this a bit, and it seems vte works like xterm does. http://www.it.freebsd.org/pub/Unix/XFree86/WWW/htdocs/current/ctlseqs.html From your description, you want to turn on vt220 emulation (in addition to application keypad mode). This works in vte with the same control sequence as in xterm, ie. CSI ? 1 0 6 1 h.
Sorry, but this is not true (at last for libvte.so.9.2.17 on my Ubuntu 8.0.4): framstag@juhu:~: printf '\033[?1061h'; cat -v 0 Same test with xterm: framstag@juhu:~: printf '\033[?1061h'; cat -v ^[Op (In both tests I pressed right keypad key "0") vte cannot distinguish between the two keys labeled "0", one on the main keyboard, the other on the numeric keyblock right.
What version of xterm? I always get '0' with both xterm and vte.
CSI ? 1 0 6 1 h only enables vt220 emulation, you also need to enable application keypad mode. Using vte (git): sh-4.1$ printf '\033[?1061h\033='; cat -v ^[Op
Does not work for me with framstag@juhu:~: gnome-terminal --version GNOME gnome-terminal 2.22.1 (on Ubuntu 8.04) Do I need a newer gnome-terminal/vtelib? My xterm is: framstag@juhu:~: xterm -version XTerm(229) With xterm I can switch on/off application keypad with (pressing right key "0" (*)) framstag@juhu:~: printf '\033[?66h'; cat -v ^[Op framstag@juhu:~: printf '\033[?66l'; cat -v 0 framstag@juhu:~: printf '\033[?66h'; cat -v ^[Op This does not work with gnome-terminal. I always get "0". application keypad mode is essential for me, for many of my applications (editor et all) need it. (*) xev says to this key: KeyPress event, serial 31, synthetic NO, window 0x3200001, root 0x5e, subw 0x0, time 4036815, (96,74), root:(758,101), state 0x0, keycode 90 (keysym 0xffb0, KP_0), same_screen YES, XLookupString gives 1 bytes: (30) "0" XmbLookupString gives 1 bytes: (30) "0"
To clarify: in order to get the unique escape sequences (such as SS3 p from KP_0), you need to enable *both* vt220 fkey emulation and application keypad mode. This is also true for xterm - perhaps you have set X resources that alter this behavior (eg. sunKeyboard: true, keyboardType: vt220). CSI?1061h enables vt220 fkey emulation. CSI?66h and ESC= both enable application keypad mode. To get your desired behavior, you need to set both, ie. printf '\033=\033[?1061h'. This is described at http://www.it.freebsd.org/pub/Unix/XFree86/WWW/htdocs/current/ctlseqs.html#VT220-Style%20Function%20Keys . I don't know about your version, but I don't think this is a bug in current vte.
I can confirm that with comment 6 I get different codes for numpad when Numlock is on/off, and the behavior is consistent with what I get from xterm. I have a considerably newer xterm and gnome-terminal/vte than Ulli's, so I'm closing this as NOTABUG. behdad:~ 0$ xterm -version X.Org 6.8.99.903(256) behdad:~ 0$ gnome-terminal --version GNOME Terminal 2.31.3git
I really hate to comment on an eight-year-old bug report, but has something changed since 2010? I'm unable to coerce gnome-terminal into producing unique escape sequences for application keypad mode, even when I send the appropriate control codes to enable VT220 emulation and smkx. Lacking a solution to this problem is the only thing keeping me from using gnome-terminal; the application keypad has to function properly for tmux and editors like vi. Have I missed something? Is there a hidden setting for gnome-terminal, or do I have to mangle my TERM environment variable? For the reporter's original case, typing keypad_0 with numlock off: % > cat -v ^[[2~ % > printf '\033[?1061h\033='; cat -v ^[[2~ % > gnome-terminal --version GNOME Terminal 3.24.2 Using VTE version 0.48.4 +GNUTLS In other words, the control codes don't seem to make any difference. For comparison, this is what I get out of xterm, without any .Xresources set to modify its behavior. keypad_0 with numlock off: % > cat -v ^[[2~ % > printf '\033[?1061h\033='; cat -v ^[Op % > xterm -version XTerm(327) This is the expected result from xterm.
My initial bug report is NINE years old and was defeated with "RESOLVED NOTABUG" which is arrogant. The bug is still there (and also in xfce4-terminal). This keeps me away from using GNOME terminal. It is a no-go. Therefore I am still using xterm.