- if (term->cfg.funky_type == FUNKY_VT400 ||
- ((term->cfg.funky_type == FUNKY_LINUX ||
- term->cfg.funky_type == FUNKY_TILDE) &&
- term->app_keypad_keys && !term->cfg.no_applic_k)) {
- switch (keysym) {
- case PK_PF1: xkey = 'P'; break;
- case PK_PF2: xkey = 'Q'; break;
- case PK_PF3: xkey = 'R'; break;
- case PK_PF4: xkey = 'S'; break;
- default: break; /* else gcc warns `enum value not used' */
- }
- }
- if (term->app_keypad_keys && !term->cfg.no_applic_k) {
- switch (keysym) {
- case PK_KP0: xkey = 'p'; break;
- case PK_KP1: xkey = 'q'; break;
- case PK_KP2: xkey = 'r'; break;
- case PK_KP3: xkey = 's'; break;
- case PK_KP4: xkey = 't'; break;
- case PK_KP5: xkey = 'u'; break;
- case PK_KP6: xkey = 'v'; break;
- case PK_KP7: xkey = 'w'; break;
- case PK_KP8: xkey = 'x'; break;
- case PK_KP9: xkey = 'y'; break;
- case PK_KPDECIMAL: xkey = 'n'; break;
- case PK_KPENTER: xkey = 'M'; break;
- default: break; /* else gcc warns `enum value not used' */
- }
- if (term->cfg.funky_type == FUNKY_XTERM && tlen > 0) {
- /*
- * xterm can't see the layout of the keypad, so it has
- * to rely on the X keysyms returned by the keys.
- * Hence, we look at the strings here, not the PuTTY
- * keysyms (which describe the layout).
- */
- switch (text[0]) {
- case '+':
- if (modifiers & PKM_SHIFT)
- xkey = 'l';
- else
- xkey = 'k';
- break;
- case '/': xkey = 'o'; break;
- case '*': xkey = 'j'; break;
- case '-': xkey = 'm'; break;
- }
- } else {
- /*
- * In all other modes, we try to retain the layout of
- * the DEC keypad in application mode.
- */
- switch (keysym) {
- case PK_KPBIGPLUS:
- /* This key covers the '-' and ',' keys on a VT220 */
- if (modifiers & PKM_SHIFT)
- xkey = 'm'; /* VT220 '-' */
- else
- xkey = 'l'; /* VT220 ',' */
- break;
- case PK_KPMINUS: xkey = 'm'; break;
- case PK_KPCOMMA: xkey = 'l'; break;
- default: break; /* else gcc warns `enum value not used' */
- }
- }
- }
- if (xkey) {
- if (term->vt52_mode) {
- if (xkey >= 'P' && xkey <= 'S')
- p += sprintf((char *) p, "\x1B%c", xkey);
- else
- p += sprintf((char *) p, "\x1B?%c", xkey);
- } else
- p += sprintf((char *) p, "\x1BO%c", xkey);
- goto done;
- }
- /* Not in application mode -- treat the number pad as arrow keys? */
- if ((flags & PKF_NUMLOCK) == 0) {
- switch (keysym) {
- case PK_KP0: keysym = PK_INSERT; break;
- case PK_KP1: keysym = PK_END; break;
- case PK_KP2: keysym = PK_DOWN; break;
- case PK_KP3: keysym = PK_PAGEDOWN; break;
- case PK_KP4: keysym = PK_LEFT; break;
- case PK_KP5: keysym = PK_REST; break;
- case PK_KP6: keysym = PK_RIGHT; break;
- case PK_KP7: keysym = PK_HOME; break;
- case PK_KP8: keysym = PK_UP; break;
- case PK_KP9: keysym = PK_PAGEUP; break;
- default: break; /* else gcc warns `enum value not used' */
- }
- }
- }
-
- /* Miscellaneous keys */
- switch (keysym) {
- case PK_ESCAPE:
- *p++ = 0x1b;
- goto done;
- case PK_BACKSPACE:
- if (modifiers == 0)
- *p++ = (term->cfg.bksp_is_delete ? 0x7F : 0x08);
- else if (modifiers == PKM_SHIFT)
- /* We do the opposite of what is configured */
- *p++ = (term->cfg.bksp_is_delete ? 0x08 : 0x7F);
- else break;
- goto done;
- case PK_TAB:
- if (modifiers == 0)
- *p++ = 0x09;
- else if (modifiers == PKM_SHIFT)
- *p++ = 0x1B, *p++ = '[', *p++ = 'Z';
- else break;
- goto done;
- /* XXX window.c has ctrl+shift+space sending 0xa0 */
- case PK_PAUSE:
- if (modifiers == PKM_CONTROL)
- *p++ = 26;
- else break;
- goto done;
- case PK_RETURN:
- case PK_KPENTER: /* Odd keypad modes handled above */
- if (modifiers == 0) {
- *p++ = 0x0d;
- if (term->cr_lf_return)
- *p++ = 0x0a;
- goto done;
- }
- default: break; /* else gcc warns `enum value not used' */
- }