From 11c6534e70cc71978343a69d86a69df2e30e0fc9 Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Sun, 26 Sep 2004 00:58:47 +0000 Subject: [PATCH] * key.c (qansi_key_defines[]): Add support for qansi-m terminals. Needed on QNX Neutrino. (correct_key_code): Likewise. --- src/ChangeLog | 5 +++ src/key.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index c57306445..d8ea2df37 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-09-26 Mike Gorchak + + * key.c (qansi_key_defines[]): Add support for qansi-m terminals. + Needed on QNX Neutrino. (correct_key_code): Likewise. + 2004-09-25 Roland Illig * pipethrough.c: Added pipethrough, a function to execute child diff --git a/src/key.c b/src/key.c index 7e7afd8f3..5f00485fe 100644 --- a/src/key.c +++ b/src/key.c @@ -316,6 +316,78 @@ static key_define_t xterm_key_defines [] = { { 0, 0, MCKEY_NOACTION }, }; +/* qansi-m terminals have a much more key combinatios, + which are undefined in termcap/terminfo */ +static key_define_t qansi_key_defines[] = +{ + /* qansi-m terminal */ + {KEY_M_CTRL | KEY_NPAGE, ESC_STR "[u", MCKEY_NOACTION}, /* Ctrl-PgDown */ + {KEY_M_CTRL | KEY_PPAGE, ESC_STR "[v", MCKEY_NOACTION}, /* Ctrl-PgUp */ + {KEY_M_CTRL | KEY_HOME, ESC_STR "[h", MCKEY_NOACTION}, /* Ctrl-Home */ + {KEY_M_CTRL | KEY_END, ESC_STR "[y", MCKEY_NOACTION}, /* Ctrl-End */ + {KEY_M_CTRL | KEY_IC, ESC_STR "[`", MCKEY_NOACTION}, /* Ctrl-Insert */ + {KEY_M_CTRL | KEY_DC, ESC_STR "[p", MCKEY_NOACTION}, /* Ctrl-Delete */ + {KEY_M_CTRL | KEY_LEFT, ESC_STR "[d", MCKEY_NOACTION}, /* Ctrl-Left */ + {KEY_M_CTRL | KEY_RIGHT, ESC_STR "[c", MCKEY_NOACTION}, /* Ctrl-Right */ + {KEY_M_CTRL | KEY_DOWN, ESC_STR "[b", MCKEY_NOACTION}, /* Ctrl-Down */ + {KEY_M_CTRL | KEY_UP, ESC_STR "[a", MCKEY_NOACTION}, /* Ctrl-Up */ + {KEY_M_CTRL | KEY_KP_ADD, ESC_STR "[s", MCKEY_NOACTION}, /* Ctrl-Gr-Plus */ + {KEY_M_CTRL | KEY_KP_SUBTRACT, ESC_STR "[t", MCKEY_NOACTION}, /* Ctrl-Gr-Minus */ + {KEY_M_CTRL | '\t', ESC_STR "[z", MCKEY_NOACTION}, /* Ctrl-Tab */ + {KEY_M_SHIFT | '\t', ESC_STR "[Z", MCKEY_NOACTION}, /* Shift-Tab */ + {KEY_M_CTRL | KEY_F(1), ESC_STR "[1~", MCKEY_NOACTION}, /* Ctrl-F1 */ + {KEY_M_CTRL | KEY_F(2), ESC_STR "[2~", MCKEY_NOACTION}, /* Ctrl-F2 */ + {KEY_M_CTRL | KEY_F(3), ESC_STR "[3~", MCKEY_NOACTION}, /* Ctrl-F3 */ + {KEY_M_CTRL | KEY_F(4), ESC_STR "[4~", MCKEY_NOACTION}, /* Ctrl-F4 */ + {KEY_M_CTRL | KEY_F(5), ESC_STR "[5~", MCKEY_NOACTION}, /* Ctrl-F5 */ + {KEY_M_CTRL | KEY_F(6), ESC_STR "[6~", MCKEY_NOACTION}, /* Ctrl-F6 */ + {KEY_M_CTRL | KEY_F(7), ESC_STR "[7~", MCKEY_NOACTION}, /* Ctrl-F7 */ + {KEY_M_CTRL | KEY_F(8), ESC_STR "[8~", MCKEY_NOACTION}, /* Ctrl-F8 */ + {KEY_M_CTRL | KEY_F(9), ESC_STR "[9~", MCKEY_NOACTION}, /* Ctrl-F9 */ + {KEY_M_CTRL | KEY_F(10), ESC_STR "[10~", MCKEY_NOACTION}, /* Ctrl-F10 */ + {KEY_M_CTRL | KEY_F(11), ESC_STR "[11~", MCKEY_NOACTION}, /* Ctrl-F11 */ + {KEY_M_CTRL | KEY_F(12), ESC_STR "[12~", MCKEY_NOACTION}, /* Ctrl-F12 */ + {KEY_M_ALT | KEY_F(1), ESC_STR "[17~", MCKEY_NOACTION}, /* Alt-F1 */ + {KEY_M_ALT | KEY_F(2), ESC_STR "[18~", MCKEY_NOACTION}, /* Alt-F2 */ + {KEY_M_ALT | KEY_F(3), ESC_STR "[19~", MCKEY_NOACTION}, /* Alt-F3 */ + {KEY_M_ALT | KEY_F(4), ESC_STR "[20~", MCKEY_NOACTION}, /* Alt-F4 */ + {KEY_M_ALT | KEY_F(5), ESC_STR "[21~", MCKEY_NOACTION}, /* Alt-F5 */ + {KEY_M_ALT | KEY_F(6), ESC_STR "[22~", MCKEY_NOACTION}, /* Alt-F6 */ + {KEY_M_ALT | KEY_F(7), ESC_STR "[23~", MCKEY_NOACTION}, /* Alt-F7 */ + {KEY_M_ALT | KEY_F(8), ESC_STR "[24~", MCKEY_NOACTION}, /* Alt-F8 */ + {KEY_M_ALT | KEY_F(9), ESC_STR "[25~", MCKEY_NOACTION}, /* Alt-F9 */ + {KEY_M_ALT | KEY_F(10), ESC_STR "[26~", MCKEY_NOACTION}, /* Alt-F10 */ + {KEY_M_ALT | KEY_F(11), ESC_STR "[27~", MCKEY_NOACTION}, /* Alt-F11 */ + {KEY_M_ALT | KEY_F(12), ESC_STR "[28~", MCKEY_NOACTION}, /* Alt-F12 */ + {KEY_M_ALT | 'a', ESC_STR "Na", MCKEY_NOACTION}, /* Alt-a */ + {KEY_M_ALT | 'b', ESC_STR "Nb", MCKEY_NOACTION}, /* Alt-b */ + {KEY_M_ALT | 'c', ESC_STR "Nc", MCKEY_NOACTION}, /* Alt-c */ + {KEY_M_ALT | 'd', ESC_STR "Nd", MCKEY_NOACTION}, /* Alt-d */ + {KEY_M_ALT | 'e', ESC_STR "Ne", MCKEY_NOACTION}, /* Alt-e */ + {KEY_M_ALT | 'f', ESC_STR "Nf", MCKEY_NOACTION}, /* Alt-f */ + {KEY_M_ALT | 'g', ESC_STR "Ng", MCKEY_NOACTION}, /* Alt-g */ + {KEY_M_ALT | 'i', ESC_STR "Ni", MCKEY_NOACTION}, /* Alt-i */ + {KEY_M_ALT | 'j', ESC_STR "Nj", MCKEY_NOACTION}, /* Alt-j */ + {KEY_M_ALT | 'k', ESC_STR "Nk", MCKEY_NOACTION}, /* Alt-k */ + {KEY_M_ALT | 'l', ESC_STR "Nl", MCKEY_NOACTION}, /* Alt-l */ + {KEY_M_ALT | 'm', ESC_STR "Nm", MCKEY_NOACTION}, /* Alt-m */ + {KEY_M_ALT | 'n', ESC_STR "Nn", MCKEY_NOACTION}, /* Alt-n */ + {KEY_M_ALT | 'o', ESC_STR "No", MCKEY_NOACTION}, /* Alt-o */ + {KEY_M_ALT | 'p', ESC_STR "Np", MCKEY_NOACTION}, /* Alt-p */ + {KEY_M_ALT | 'q', ESC_STR "Nq", MCKEY_NOACTION}, /* Alt-r */ + {KEY_M_ALT | 's', ESC_STR "Ns", MCKEY_NOACTION}, /* Alt-s */ + {KEY_M_ALT | 't', ESC_STR "Nt", MCKEY_NOACTION}, /* Alt-t */ + {KEY_M_ALT | 'u', ESC_STR "Nu", MCKEY_NOACTION}, /* Alt-u */ + {KEY_M_ALT | 'v', ESC_STR "Nv", MCKEY_NOACTION}, /* Alt-v */ + {KEY_M_ALT | 'w', ESC_STR "Nw", MCKEY_NOACTION}, /* Alt-w */ + {KEY_M_ALT | 'x', ESC_STR "Nx", MCKEY_NOACTION}, /* Alt-x */ + {KEY_M_ALT | 'y', ESC_STR "Ny", MCKEY_NOACTION}, /* Alt-y */ + {KEY_M_ALT | 'z', ESC_STR "Nz", MCKEY_NOACTION}, /* Alt-z */ + {KEY_KP_ADD, ESC_STR "[S", MCKEY_NOACTION}, /* Gr-Plus */ + {KEY_KP_SUBTRACT, ESC_STR "[T", MCKEY_NOACTION}, /* Gr-Minus */ + {0, 0, MCKEY_NOACTION}, +}; + static key_define_t mc_default_keys [] = { { ESC_CHAR, ESC_STR, MCKEY_ESCAPE }, { ESC_CHAR, ESC_STR ESC_STR, MCKEY_NOACTION }, @@ -426,6 +498,13 @@ void init_key (void) #ifdef HAVE_TEXTMODE_X11_SUPPORT init_key_x11 (); #endif /* HAVE_TEXTMODE_X11_SUPPORT */ + + /* Load the qansi-m key definitions + if we are running under the qansi-m terminal */ + if ((term) && (strncmp (term, "qansi-m", 7) == 0)) + { + define_sequences(qansi_key_defines); + } } /* This has to be called after SLang_init_tty/slint_init */ @@ -597,6 +676,10 @@ correct_key_code (int code) { unsigned int c = code & ~KEY_M_MASK; /* code without modifier */ unsigned int mod = code & KEY_M_MASK; /* modifier */ + #ifdef __QNXNTO__ + unsigned int qmod; /* bunch of the QNX console + modifiers needs unchanged */ + #endif /* __QNXNTO__ */ /* * Add key modifiers directly from X11 or OS. @@ -634,6 +717,34 @@ correct_key_code (int code) mod |= KEY_M_CTRL; } +#ifdef __QNXNTO__ + qmod=get_modifier(); + + if ((c == 127) && (mod==0)) /* Add Ctrl/Alt/Shift-BackSpace */ + { + mod |= get_modifier(); + c = KEY_BACKSPACE; + } + + if ((c=='0') && (mod==0)) /* Add Shift-Insert on key pad */ + { + if ((qmod & KEY_M_SHIFT) == KEY_M_SHIFT) + { + mod = KEY_M_SHIFT; + c = KEY_IC; + } + } + + if ((c=='.') && (mod==0)) /* Add Shift-Del on key pad */ + { + if ((qmod & KEY_M_SHIFT) == KEY_M_SHIFT) + { + mod = KEY_M_SHIFT; + c = KEY_DC; + } + } +#endif /* __QNXNTO__ */ + /* Unrecognized 0177 is delete (preserve Ctrl) */ if (c == 0177) { c = KEY_BACKSPACE; @@ -1280,7 +1391,8 @@ get_modifier (void) if (cursor_info.key_mods & 0x01) result |= KEY_M_SHIFT; } -#endif /* __QNXNTO__ */ +#endif /* __QNXNTO__ */ + #if defined __linux__ || (defined __CYGWIN__ && defined TIOCLINUX) { unsigned char modifiers = 6;