qulogic/libgnt

Fix arrow keys
fix-arrow-keys
2019-02-20, Petteri Pitkänen
7ac801527b0b
Fix arrow keys

The key-tree expects that for arrow keys the terminal transmits codes that
are defined in the terminfo database, but these codes are transmitted only
in application mode. To make the arrow key handling portable across
terminals, and to prevent the need for manually translating these codes, put
the terminal into application mode by calling ncurses keypad().

Fixes #12676.
  • +1 -8
    gntkeys.c
  • +1 -0
    gntmain.c
  • --- a/gntkeys.c Fri Jan 18 02:41:28 2019 +0000
    +++ b/gntkeys.c Wed Feb 20 20:10:48 2019 +0100
    @@ -166,14 +166,7 @@
    {
    while (*text == 27 && *(text + 1) == 27)
    text++;
    - if (*text == 27 && *(text + 1) == '[' &&
    - (*(text + 2) >= 'A' && *(text + 2) <= 'D')) {
    - /* Apparently this is necessary for urxvt and screen and xterm */
    - if (strstr(term, "screen") == term || strcmp(term, "rxvt-unicode") == 0 ||
    - strstr(term, "xterm") == term ||
    - strstr(term, "vt100") == term)
    - *(text + 1) = 'O';
    - } else if (g_utf8_get_char(text) == 195) {
    + if (g_utf8_get_char(text) == 195) {
    if (*(text + 2) == 0 && strstr(term, "xterm") == term) {
    *(text) = 27;
    *(text + 1) -= 64; /* Say wha? */
    --- a/gntmain.c Fri Jan 18 02:41:28 2019 +0000
    +++ b/gntmain.c Wed Feb 20 20:10:48 2019 +0100
    @@ -607,6 +607,7 @@
    typeahead(-1);
    noecho();
    curs_set(0);
    + keypad(stdscr, 1);
    gnt_init_keys();
    gnt_init_styles();