0

I'm trying to revive a pretty old MUD client to run under OS X Mojave (pretty much a telnet client that supports aliases, key bindings and triggers). The code can be found here https://github.com/olostan/mmc

I was successfully able to run it, however it didn't correctly handle the numpad keys. As I figured out that happened because these keys weren't defined in https://github.com/olostan/mmc/blob/master/src/output.c Once I added the following block to "keypad keys" section, it started working properly.

  { "k0",   "\033Op",   NULL    },
  { "k1",   "\033Oq",   NULL    },
  { "k2",   "\033Or",   NULL    },
  { "k3",   "\033Os",   NULL    },
  { "k4",   "\033Ot",   NULL    },
  { "k5",   "\033Ou",   NULL    },
  { "k6",   "\033Ov",   NULL    },
  { "k7",   "\033Ow",   NULL    },
  { "k8",   "\033Ox",   NULL    },
  { "k9",   "\033Oy",   NULL    },  

Now I want to do the same for numpad keys with different modifiers (ctrl, alt, shift), for example C-k1, M-k1, S-k1, but I can't find anywhere how to correctly define escape codes for such sequence. I got the codes above from this page - https://www.gnu.org/software/screen/manual/html_node/Input-Translation.html But unfortunately it doesn't describe any combinations with modifiers.

So the question - how do I define escape codes in VT100 format for keypad combinations with modifier keys (shift, alt, ctrl)? I tried setting something like this "\033[1;5Ot" for S-k4 key combination, but none of that worked.

afansky
  • 113
  • 2
  • 7
  • There were many dialects of VT100. Try to get your hands on an annotated copy of a termcap file to get a grip on them. (and I dont think that alt keys existed at the time) – wildplasser Nov 06 '19 at 19:50
  • https://invisible-island.net/xterm/ctlseqs/ctlseqs.html The code sent depends on the terminal emulator and the mode set by the application. As an example, you can try `tput smkx; cat` and press some keys to see the codes sent by your terminal emulator in application mode. – ninjalj Nov 06 '19 at 22:22

1 Answers1

0

The question is

how do I define escape codes in VT100 format for keypad combinations with modifier keys (shift, alt, ctrl)?

The answer is that you probably can't, because terminals are unlikely to provide distinct escape codes for the numeric keypad:

  • VT100s never did anything like that.
  • xterm imitates VT100's keypad, taking into account normal and application modes (application mode sends the escape sequences you listed)
  • most other terminal emulators don't bother doing even that.

  • xterm has a feature which lets you configure it to send modified keypad keys, the modifyKeyboard resource setting: modifyKeyboard (class ModifyKeyboard) Normally xterm makes a special case regarding modifiers (shift, control, etc.) to handle special keyboard layouts (legacy and vt220). This is done to provide compatible keyboards for DEC VT220 and related terminals that implement user-defined keys (UDK).

           The bits of the resource value selectively enable modification
           of the given category when these keyboards are selected.  The
           default is "0":
    
           0    The legacy/vt220 keyboards interpret only the Control-
                modifier when constructing numbered function-keys.  Other
                special keys are not modified.
    
           1    allows modification of the numeric keypad
    
           2    allows modification of the editing keypad
    
           4    allows modification of function-keys, overrides use of
                Shift-modifier for UDK.
    
           8    allows modification of other special keys
    
  • other terminals don't do that at all (a few may let you customize the keys sent, but none will have this predefined, which is what your mud client would need).
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105