neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

keycodes.h (20100B)


      1 #pragma once
      2 
      3 #include "nvim/ascii_defs.h"
      4 #include "nvim/eval/typval_defs.h"  // IWYU pragma: keep
      5 
      6 // Keycode definitions for special keys.
      7 //
      8 // Any special key code sequences are replaced by these codes.
      9 
     10 /// For MS-DOS some keys produce codes larger than 0xff. They are split into two
     11 /// chars, the first one is K_NUL.
     12 #define K_NUL                   (0xce)  // for MS-DOS: special key follows
     13 
     14 /// K_SPECIAL is the first byte of a special key code and is always followed by
     15 /// two bytes.
     16 /// The second byte can have any value. ASCII is used for normal termcap
     17 /// entries, 0x80 and higher for special keys, see below.
     18 /// The third byte is guaranteed to be between 0x02 and 0x7f.
     19 #define K_SPECIAL               (0x80)
     20 
     21 /// Positive characters are "normal" characters.
     22 /// Negative characters are special key codes.  Only characters below -0x200
     23 /// are used to so that the absolute value can't be mistaken for a single-byte
     24 /// character.
     25 #define IS_SPECIAL(c)           ((c) < 0)
     26 
     27 /// Characters 0x0100 - 0x01ff have a special meaning for abbreviations.
     28 /// Multi-byte characters also have ABBR_OFF added, thus are above 0x0200.
     29 #define ABBR_OFF                0x100
     30 
     31 /// NUL cannot be in the input string, therefore it is replaced by
     32 ///      K_SPECIAL   KS_ZERO     KE_FILLER
     33 #define KS_ZERO                 255
     34 
     35 /// K_SPECIAL cannot be in the input string, therefore it is replaced by
     36 ///      K_SPECIAL   KS_SPECIAL  KE_FILLER
     37 #define KS_SPECIAL              254
     38 
     39 /// KS_EXTRA is used for keys that have no termcap name
     40 ///      K_SPECIAL   KS_EXTRA    KE_xxx
     41 #define KS_EXTRA                253
     42 
     43 /// KS_MODIFIER is used when a modifier is given for a (special) key
     44 ///      K_SPECIAL   KS_MODIFIER bitmask
     45 #define KS_MODIFIER             252
     46 
     47 // These are used for the GUI
     48 //      K_SPECIAL   KS_xxx      KE_FILLER
     49 
     50 #define KS_MOUSE                251
     51 #define KS_MENU                 250
     52 #define KS_VER_SCROLLBAR        249
     53 #define KS_HOR_SCROLLBAR        248
     54 
     55 // Used for switching Select mode back on after a mapping or menu.
     56 
     57 #define KS_SELECT               245
     58 #define K_SELECT_STRING         "\200\365X"
     59 
     60 /// Used a termcap entry that produces a normal character.
     61 #define KS_KEY                  242
     62 
     63 /// Used for click in a tab pages label.
     64 #define KS_TABLINE              240
     65 
     66 /// Used for menu in a tab pages line.
     67 #define KS_TABMENU              239
     68 
     69 /// Filler used after KS_SPECIAL and others
     70 #define KE_FILLER               ('X')
     71 
     72 // translation of three byte code "K_SPECIAL a b" into int "K_xxx" and back
     73 
     74 #define TERMCAP2KEY(a, b)       (-((a) + ((int)(b) << 8)))
     75 #define KEY2TERMCAP0(x)         ((-(x)) & 0xff)
     76 #define KEY2TERMCAP1(x)         (((unsigned)(-(x)) >> 8) & 0xff)
     77 
     78 // get second or third byte when translating special key code into three bytes
     79 
     80 #define K_SECOND(c)     ((c) == K_SPECIAL ? KS_SPECIAL : (c) == \
     81                         NUL ? KS_ZERO : KEY2TERMCAP0(c))
     82 
     83 #define K_THIRD(c)      (((c) == K_SPECIAL || (c) == \
     84                          NUL) ? KE_FILLER : KEY2TERMCAP1(c))
     85 
     86 /// get single int code from second byte after K_SPECIAL
     87 #define TO_SPECIAL(a, b)    ((a) == KS_SPECIAL ? K_SPECIAL : (a) == \
     88                             KS_ZERO ? K_ZERO : TERMCAP2KEY(a, b))
     89 
     90 /// Codes for keys that do not have a termcap name.
     91 /// The numbers are fixed to make sure that recorded key sequences remain valid.
     92 /// Add new entries at the end, not halfway.
     93 ///
     94 /// K_SPECIAL KS_EXTRA KE_xxx
     95 ///
     96 /// Entries must be in the range 0x02-0x7f (see comment at K_SPECIAL).
     97 enum key_extra {
     98  KE_S_UP = 4,              // shift-up
     99  KE_S_DOWN = 5,            // shift-down
    100 
    101  // shifted function keys
    102  KE_S_F1 = 6,
    103  KE_S_F2 = 7,
    104  KE_S_F3 = 8,
    105  KE_S_F4 = 9,
    106  KE_S_F5 = 10,
    107  KE_S_F6 = 11,
    108  KE_S_F7 = 12,
    109  KE_S_F8 = 13,
    110  KE_S_F9 = 14,
    111  KE_S_F10 = 15,
    112 
    113  KE_S_F11 = 16,
    114  KE_S_F12 = 17,
    115  KE_S_F13 = 18,
    116  KE_S_F14 = 19,
    117  KE_S_F15 = 20,
    118  KE_S_F16 = 21,
    119  KE_S_F17 = 22,
    120  KE_S_F18 = 23,
    121  KE_S_F19 = 24,
    122  KE_S_F20 = 25,
    123 
    124  KE_S_F21 = 26,
    125  KE_S_F22 = 27,
    126  KE_S_F23 = 28,
    127  KE_S_F24 = 29,
    128  KE_S_F25 = 30,
    129  KE_S_F26 = 31,
    130  KE_S_F27 = 32,
    131  KE_S_F28 = 33,
    132  KE_S_F29 = 34,
    133  KE_S_F30 = 35,
    134 
    135  KE_S_F31 = 36,
    136  KE_S_F32 = 37,
    137  KE_S_F33 = 38,
    138  KE_S_F34 = 39,
    139  KE_S_F35 = 40,
    140  KE_S_F36 = 41,
    141  KE_S_F37 = 42,
    142 
    143  KE_MOUSE = 43,            // mouse event start
    144 
    145  // Symbols for pseudo keys which are translated from the real key symbols
    146  // above.
    147  KE_LEFTMOUSE = 44,        // Left mouse button click
    148  KE_LEFTDRAG = 45,         // Drag with left mouse button down
    149  KE_LEFTRELEASE = 46,      // Left mouse button release
    150  KE_MIDDLEMOUSE = 47,      // Middle mouse button click
    151  KE_MIDDLEDRAG = 48,       // Drag with middle mouse button down
    152  KE_MIDDLERELEASE = 49,    // Middle mouse button release
    153  KE_RIGHTMOUSE = 50,       // Right mouse button click
    154  KE_RIGHTDRAG = 51,        // Drag with right mouse button down
    155  KE_RIGHTRELEASE = 52,     // Right mouse button release
    156 
    157  KE_IGNORE = 53,           // Ignored mouse drag/release
    158 
    159  KE_TAB = 54,              // unshifted TAB key
    160  KE_S_TAB_OLD = 55,        // shifted TAB key (no longer used)
    161 
    162  // KE_SNIFF_UNUSED = 56,  // obsolete
    163  KE_XF1 = 57,              // extra vt100 function keys for xterm
    164  KE_XF2 = 58,
    165  KE_XF3 = 59,
    166  KE_XF4 = 60,
    167  KE_XEND = 61,             // extra (vt100) end key for xterm
    168  KE_ZEND = 62,             // extra (vt100) end key for xterm
    169  KE_XHOME = 63,            // extra (vt100) home key for xterm
    170  KE_ZHOME = 64,            // extra (vt100) home key for xterm
    171  KE_XUP = 65,              // extra vt100 cursor keys for xterm
    172  KE_XDOWN = 66,
    173  KE_XLEFT = 67,
    174  KE_XRIGHT = 68,
    175 
    176  KE_LEFTMOUSE_NM = 69,     // non-mappable Left mouse button click
    177  KE_LEFTRELEASE_NM = 70,   // non-mappable left mouse button release
    178 
    179  KE_S_XF1 = 71,            // vt100 shifted function keys for xterm
    180  KE_S_XF2 = 72,
    181  KE_S_XF3 = 73,
    182  KE_S_XF4 = 74,
    183 
    184  // NOTE: The scroll wheel events are inverted: i.e. UP is the same as
    185  // moving the actual scroll wheel down, LEFT is the same as moving the
    186  // scroll wheel right.
    187  KE_MOUSEDOWN = 75,        // scroll wheel pseudo-button Down
    188  KE_MOUSEUP = 76,          // scroll wheel pseudo-button Up
    189  KE_MOUSELEFT = 77,        // scroll wheel pseudo-button Left
    190  KE_MOUSERIGHT = 78,       // scroll wheel pseudo-button Right
    191 
    192  KE_KINS = 79,             // keypad Insert key
    193  KE_KDEL = 80,             // keypad Delete key
    194 
    195  // KE_CSI = 81,           // Nvim doesn't need escaping CSI
    196  KE_SNR = 82,              // <SNR>
    197  KE_PLUG = 83,             // <Plug>
    198  KE_CMDWIN = 84,           // open command-line window from Command-line Mode
    199 
    200  KE_C_LEFT = 85,           // control-left
    201  KE_C_RIGHT = 86,          // control-right
    202  KE_C_HOME = 87,           // control-home
    203  KE_C_END = 88,            // control-end
    204 
    205  KE_X1MOUSE = 89,          // X1/X2 mouse-buttons
    206  KE_X1DRAG = 90,
    207  KE_X1RELEASE = 91,
    208  KE_X2MOUSE = 92,
    209  KE_X2DRAG = 93,
    210  KE_X2RELEASE = 94,
    211 
    212  KE_DROP = 95,             // DnD data is available
    213  // KE_CURSORHOLD = 96,    // CursorHold event
    214  KE_NOP = 97,              // no-op: does nothing
    215  // KE_FOCUSGAINED = 98,   // focus gained
    216  // KE_FOCUSLOST = 99,     // focus lost
    217  KE_MOUSEMOVE = 100,       // mouse moved with no button down
    218  // KE_MOUSEMOVE_XY = 101,
    219  // KE_CANCEL = 102,       // return from vgetc()
    220  KE_EVENT = 102,           // event
    221  KE_LUA = 103,             // Lua special key
    222  KE_COMMAND = 104,         // <Cmd> special key
    223  // KE_S_BS = 105,
    224  // KE_SID = 106,
    225  // KE_ESC = 107,
    226  KE_WILD = 108,            // triggers wildmode completion
    227 };
    228 
    229 // the three byte codes are replaced with the following int when using vgetc()
    230 
    231 #define K_ZERO          TERMCAP2KEY(KS_ZERO, KE_FILLER)
    232 
    233 #define K_UP            TERMCAP2KEY('k', 'u')
    234 #define K_KUP           TERMCAP2KEY('K', 'u')   // keypad up
    235 #define K_DOWN          TERMCAP2KEY('k', 'd')
    236 #define K_KDOWN         TERMCAP2KEY('K', 'd')   // keypad down
    237 #define K_LEFT          TERMCAP2KEY('k', 'l')
    238 #define K_KLEFT         TERMCAP2KEY('K', 'l')   // keypad left
    239 #define K_RIGHT         TERMCAP2KEY('k', 'r')
    240 #define K_KRIGHT        TERMCAP2KEY('K', 'r')   // keypad right
    241 #define K_S_UP          TERMCAP2KEY(KS_EXTRA, KE_S_UP)
    242 #define K_S_DOWN        TERMCAP2KEY(KS_EXTRA, KE_S_DOWN)
    243 #define K_S_LEFT        TERMCAP2KEY('#', '4')
    244 #define K_C_LEFT        TERMCAP2KEY(KS_EXTRA, KE_C_LEFT)
    245 #define K_S_RIGHT       TERMCAP2KEY('%', 'i')
    246 #define K_C_RIGHT       TERMCAP2KEY(KS_EXTRA, KE_C_RIGHT)
    247 #define K_S_HOME        TERMCAP2KEY('#', '2')
    248 #define K_C_HOME        TERMCAP2KEY(KS_EXTRA, KE_C_HOME)
    249 #define K_S_END         TERMCAP2KEY('*', '7')
    250 #define K_C_END         TERMCAP2KEY(KS_EXTRA, KE_C_END)
    251 #define K_TAB           TERMCAP2KEY(KS_EXTRA, KE_TAB)
    252 #define K_S_TAB         TERMCAP2KEY('k', 'B')
    253 
    254 // extra set of function keys F1-F4, for vt100 compatible xterm
    255 #define K_XF1           TERMCAP2KEY(KS_EXTRA, KE_XF1)
    256 #define K_XF2           TERMCAP2KEY(KS_EXTRA, KE_XF2)
    257 #define K_XF3           TERMCAP2KEY(KS_EXTRA, KE_XF3)
    258 #define K_XF4           TERMCAP2KEY(KS_EXTRA, KE_XF4)
    259 
    260 // extra set of cursor keys for vt100 compatible xterm
    261 #define K_XUP           TERMCAP2KEY(KS_EXTRA, KE_XUP)
    262 #define K_XDOWN         TERMCAP2KEY(KS_EXTRA, KE_XDOWN)
    263 #define K_XLEFT         TERMCAP2KEY(KS_EXTRA, KE_XLEFT)
    264 #define K_XRIGHT        TERMCAP2KEY(KS_EXTRA, KE_XRIGHT)
    265 
    266 // function keys
    267 #define K_F1            TERMCAP2KEY('k', '1')
    268 #define K_F2            TERMCAP2KEY('k', '2')
    269 #define K_F3            TERMCAP2KEY('k', '3')
    270 #define K_F4            TERMCAP2KEY('k', '4')
    271 #define K_F5            TERMCAP2KEY('k', '5')
    272 #define K_F6            TERMCAP2KEY('k', '6')
    273 #define K_F7            TERMCAP2KEY('k', '7')
    274 #define K_F8            TERMCAP2KEY('k', '8')
    275 #define K_F9            TERMCAP2KEY('k', '9')
    276 #define K_F10           TERMCAP2KEY('k', ';')
    277 
    278 #define K_F11           TERMCAP2KEY('F', '1')
    279 #define K_F12           TERMCAP2KEY('F', '2')
    280 #define K_F13           TERMCAP2KEY('F', '3')
    281 #define K_F14           TERMCAP2KEY('F', '4')
    282 #define K_F15           TERMCAP2KEY('F', '5')
    283 #define K_F16           TERMCAP2KEY('F', '6')
    284 #define K_F17           TERMCAP2KEY('F', '7')
    285 #define K_F18           TERMCAP2KEY('F', '8')
    286 #define K_F19           TERMCAP2KEY('F', '9')
    287 #define K_F20           TERMCAP2KEY('F', 'A')
    288 
    289 #define K_F21           TERMCAP2KEY('F', 'B')
    290 #define K_F22           TERMCAP2KEY('F', 'C')
    291 #define K_F23           TERMCAP2KEY('F', 'D')
    292 #define K_F24           TERMCAP2KEY('F', 'E')
    293 #define K_F25           TERMCAP2KEY('F', 'F')
    294 #define K_F26           TERMCAP2KEY('F', 'G')
    295 #define K_F27           TERMCAP2KEY('F', 'H')
    296 #define K_F28           TERMCAP2KEY('F', 'I')
    297 #define K_F29           TERMCAP2KEY('F', 'J')
    298 #define K_F30           TERMCAP2KEY('F', 'K')
    299 
    300 #define K_F31           TERMCAP2KEY('F', 'L')
    301 #define K_F32           TERMCAP2KEY('F', 'M')
    302 #define K_F33           TERMCAP2KEY('F', 'N')
    303 #define K_F34           TERMCAP2KEY('F', 'O')
    304 #define K_F35           TERMCAP2KEY('F', 'P')
    305 #define K_F36           TERMCAP2KEY('F', 'Q')
    306 #define K_F37           TERMCAP2KEY('F', 'R')
    307 #define K_F38           TERMCAP2KEY('F', 'S')
    308 #define K_F39           TERMCAP2KEY('F', 'T')
    309 #define K_F40           TERMCAP2KEY('F', 'U')
    310 
    311 #define K_F41           TERMCAP2KEY('F', 'V')
    312 #define K_F42           TERMCAP2KEY('F', 'W')
    313 #define K_F43           TERMCAP2KEY('F', 'X')
    314 #define K_F44           TERMCAP2KEY('F', 'Y')
    315 #define K_F45           TERMCAP2KEY('F', 'Z')
    316 #define K_F46           TERMCAP2KEY('F', 'a')
    317 #define K_F47           TERMCAP2KEY('F', 'b')
    318 #define K_F48           TERMCAP2KEY('F', 'c')
    319 #define K_F49           TERMCAP2KEY('F', 'd')
    320 #define K_F50           TERMCAP2KEY('F', 'e')
    321 
    322 #define K_F51           TERMCAP2KEY('F', 'f')
    323 #define K_F52           TERMCAP2KEY('F', 'g')
    324 #define K_F53           TERMCAP2KEY('F', 'h')
    325 #define K_F54           TERMCAP2KEY('F', 'i')
    326 #define K_F55           TERMCAP2KEY('F', 'j')
    327 #define K_F56           TERMCAP2KEY('F', 'k')
    328 #define K_F57           TERMCAP2KEY('F', 'l')
    329 #define K_F58           TERMCAP2KEY('F', 'm')
    330 #define K_F59           TERMCAP2KEY('F', 'n')
    331 #define K_F60           TERMCAP2KEY('F', 'o')
    332 
    333 #define K_F61           TERMCAP2KEY('F', 'p')
    334 #define K_F62           TERMCAP2KEY('F', 'q')
    335 #define K_F63           TERMCAP2KEY('F', 'r')
    336 
    337 // extra set of shifted function keys F1-F4, for vt100 compatible xterm
    338 #define K_S_XF1         TERMCAP2KEY(KS_EXTRA, KE_S_XF1)
    339 #define K_S_XF2         TERMCAP2KEY(KS_EXTRA, KE_S_XF2)
    340 #define K_S_XF3         TERMCAP2KEY(KS_EXTRA, KE_S_XF3)
    341 #define K_S_XF4         TERMCAP2KEY(KS_EXTRA, KE_S_XF4)
    342 
    343 #define K_S_F1          TERMCAP2KEY(KS_EXTRA, KE_S_F1)  // shifted func. keys
    344 #define K_S_F2          TERMCAP2KEY(KS_EXTRA, KE_S_F2)
    345 #define K_S_F3          TERMCAP2KEY(KS_EXTRA, KE_S_F3)
    346 #define K_S_F4          TERMCAP2KEY(KS_EXTRA, KE_S_F4)
    347 #define K_S_F5          TERMCAP2KEY(KS_EXTRA, KE_S_F5)
    348 #define K_S_F6          TERMCAP2KEY(KS_EXTRA, KE_S_F6)
    349 #define K_S_F7          TERMCAP2KEY(KS_EXTRA, KE_S_F7)
    350 #define K_S_F8          TERMCAP2KEY(KS_EXTRA, KE_S_F8)
    351 #define K_S_F9          TERMCAP2KEY(KS_EXTRA, KE_S_F9)
    352 #define K_S_F10         TERMCAP2KEY(KS_EXTRA, KE_S_F10)
    353 
    354 #define K_S_F11         TERMCAP2KEY(KS_EXTRA, KE_S_F11)
    355 #define K_S_F12         TERMCAP2KEY(KS_EXTRA, KE_S_F12)
    356 // K_S_F13 to K_S_F37  are currently not used
    357 
    358 #define K_HELP          TERMCAP2KEY('%', '1')
    359 #define K_UNDO          TERMCAP2KEY('&', '8')
    360 #define K_FIND          TERMCAP2KEY('@', '0')   // DEC key, often used as Home
    361 #define K_KSELECT       TERMCAP2KEY('*', '6')   // DEC key, often used as End
    362 
    363 #define K_BS            TERMCAP2KEY('k', 'b')
    364 
    365 #define K_INS           TERMCAP2KEY('k', 'I')
    366 #define K_KINS          TERMCAP2KEY(KS_EXTRA, KE_KINS)
    367 #define K_DEL           TERMCAP2KEY('k', 'D')
    368 #define K_KDEL          TERMCAP2KEY(KS_EXTRA, KE_KDEL)
    369 #define K_HOME          TERMCAP2KEY('k', 'h')
    370 #define K_KHOME         TERMCAP2KEY('K', '1')   // keypad home (upper left)
    371 #define K_XHOME         TERMCAP2KEY(KS_EXTRA, KE_XHOME)
    372 #define K_ZHOME         TERMCAP2KEY(KS_EXTRA, KE_ZHOME)
    373 #define K_END           TERMCAP2KEY('@', '7')
    374 #define K_KEND          TERMCAP2KEY('K', '4')   // keypad end (lower left)
    375 #define K_XEND          TERMCAP2KEY(KS_EXTRA, KE_XEND)
    376 #define K_ZEND          TERMCAP2KEY(KS_EXTRA, KE_ZEND)
    377 #define K_PAGEUP        TERMCAP2KEY('k', 'P')
    378 #define K_PAGEDOWN      TERMCAP2KEY('k', 'N')
    379 #define K_KPAGEUP       TERMCAP2KEY('K', '3')   // keypad pageup (upper R.)
    380 #define K_KPAGEDOWN     TERMCAP2KEY('K', '5')   // keypad pagedown (lower R.)
    381 #define K_KORIGIN       TERMCAP2KEY('K', '2')   // keypad center
    382 
    383 #define K_KPLUS         TERMCAP2KEY('K', '6')   // keypad plus
    384 #define K_KMINUS        TERMCAP2KEY('K', '7')   // keypad minus
    385 #define K_KDIVIDE       TERMCAP2KEY('K', '8')   // keypad /
    386 #define K_KMULTIPLY     TERMCAP2KEY('K', '9')   // keypad *
    387 #define K_KENTER        TERMCAP2KEY('K', 'A')   // keypad Enter
    388 #define K_KPOINT        TERMCAP2KEY('K', 'B')   // keypad . or ,
    389 
    390 // Delimits pasted text (to repeat nvim_paste). Internal-only, not sent by UIs.
    391 #define K_PASTE_START   TERMCAP2KEY('P', 'S')   // paste start
    392 #define K_PASTE_END     TERMCAP2KEY('P', 'E')   // paste end
    393 
    394 #define K_K0            TERMCAP2KEY('K', 'C')   // keypad 0
    395 #define K_K1            TERMCAP2KEY('K', 'D')   // keypad 1
    396 #define K_K2            TERMCAP2KEY('K', 'E')   // keypad 2
    397 #define K_K3            TERMCAP2KEY('K', 'F')   // keypad 3
    398 #define K_K4            TERMCAP2KEY('K', 'G')   // keypad 4
    399 #define K_K5            TERMCAP2KEY('K', 'H')   // keypad 5
    400 #define K_K6            TERMCAP2KEY('K', 'I')   // keypad 6
    401 #define K_K7            TERMCAP2KEY('K', 'J')   // keypad 7
    402 #define K_K8            TERMCAP2KEY('K', 'K')   // keypad 8
    403 #define K_K9            TERMCAP2KEY('K', 'L')   // keypad 9
    404 
    405 #define K_KCOMMA        TERMCAP2KEY('K', 'M')   // keypad comma
    406 #define K_KEQUAL        TERMCAP2KEY('K', 'N')   // keypad equal
    407 
    408 #define K_MOUSE         TERMCAP2KEY(KS_MOUSE, KE_FILLER)
    409 #define K_MENU          TERMCAP2KEY(KS_MENU, KE_FILLER)
    410 #define K_VER_SCROLLBAR TERMCAP2KEY(KS_VER_SCROLLBAR, KE_FILLER)
    411 #define K_HOR_SCROLLBAR   TERMCAP2KEY(KS_HOR_SCROLLBAR, KE_FILLER)
    412 
    413 #define K_SELECT        TERMCAP2KEY(KS_SELECT, KE_FILLER)
    414 
    415 #define K_TABLINE       TERMCAP2KEY(KS_TABLINE, KE_FILLER)
    416 #define K_TABMENU       TERMCAP2KEY(KS_TABMENU, KE_FILLER)
    417 
    418 // Symbols for pseudo keys which are translated from the real key symbols
    419 // above.
    420 
    421 #define K_LEFTMOUSE     TERMCAP2KEY(KS_EXTRA, KE_LEFTMOUSE)
    422 #define K_LEFTMOUSE_NM  TERMCAP2KEY(KS_EXTRA, KE_LEFTMOUSE_NM)
    423 #define K_LEFTDRAG      TERMCAP2KEY(KS_EXTRA, KE_LEFTDRAG)
    424 #define K_LEFTRELEASE   TERMCAP2KEY(KS_EXTRA, KE_LEFTRELEASE)
    425 #define K_LEFTRELEASE_NM TERMCAP2KEY(KS_EXTRA, KE_LEFTRELEASE_NM)
    426 #define K_MOUSEMOVE     TERMCAP2KEY(KS_EXTRA, KE_MOUSEMOVE)
    427 #define K_MIDDLEMOUSE   TERMCAP2KEY(KS_EXTRA, KE_MIDDLEMOUSE)
    428 #define K_MIDDLEDRAG    TERMCAP2KEY(KS_EXTRA, KE_MIDDLEDRAG)
    429 #define K_MIDDLERELEASE TERMCAP2KEY(KS_EXTRA, KE_MIDDLERELEASE)
    430 #define K_RIGHTMOUSE    TERMCAP2KEY(KS_EXTRA, KE_RIGHTMOUSE)
    431 #define K_RIGHTDRAG     TERMCAP2KEY(KS_EXTRA, KE_RIGHTDRAG)
    432 #define K_RIGHTRELEASE  TERMCAP2KEY(KS_EXTRA, KE_RIGHTRELEASE)
    433 #define K_X1MOUSE       TERMCAP2KEY(KS_EXTRA, KE_X1MOUSE)
    434 #define K_X1MOUSE       TERMCAP2KEY(KS_EXTRA, KE_X1MOUSE)
    435 #define K_X1DRAG        TERMCAP2KEY(KS_EXTRA, KE_X1DRAG)
    436 #define K_X1RELEASE     TERMCAP2KEY(KS_EXTRA, KE_X1RELEASE)
    437 #define K_X2MOUSE       TERMCAP2KEY(KS_EXTRA, KE_X2MOUSE)
    438 #define K_X2DRAG        TERMCAP2KEY(KS_EXTRA, KE_X2DRAG)
    439 #define K_X2RELEASE     TERMCAP2KEY(KS_EXTRA, KE_X2RELEASE)
    440 
    441 #define K_IGNORE        TERMCAP2KEY(KS_EXTRA, KE_IGNORE)
    442 #define K_NOP           TERMCAP2KEY(KS_EXTRA, KE_NOP)
    443 
    444 #define K_MOUSEDOWN     TERMCAP2KEY(KS_EXTRA, KE_MOUSEDOWN)
    445 #define K_MOUSEUP       TERMCAP2KEY(KS_EXTRA, KE_MOUSEUP)
    446 #define K_MOUSELEFT     TERMCAP2KEY(KS_EXTRA, KE_MOUSELEFT)
    447 #define K_MOUSERIGHT    TERMCAP2KEY(KS_EXTRA, KE_MOUSERIGHT)
    448 
    449 #define K_SNR           TERMCAP2KEY(KS_EXTRA, KE_SNR)
    450 #define K_PLUG          TERMCAP2KEY(KS_EXTRA, KE_PLUG)
    451 #define K_CMDWIN        TERMCAP2KEY(KS_EXTRA, KE_CMDWIN)
    452 
    453 #define K_DROP          TERMCAP2KEY(KS_EXTRA, KE_DROP)
    454 
    455 #define K_EVENT         TERMCAP2KEY(KS_EXTRA, KE_EVENT)
    456 #define K_COMMAND       TERMCAP2KEY(KS_EXTRA, KE_COMMAND)
    457 #define K_LUA           TERMCAP2KEY(KS_EXTRA, KE_LUA)
    458 
    459 #define K_WILD          TERMCAP2KEY(KS_EXTRA, KE_WILD)
    460 
    461 // Bits for modifier mask
    462 // 0x01 cannot be used, because the modifier must be 0x02 or higher
    463 #define MOD_MASK_SHIFT      0x02
    464 #define MOD_MASK_CTRL       0x04
    465 #define MOD_MASK_ALT        0x08        // aka META
    466 #define MOD_MASK_META       0x10        // META when it's different from ALT
    467 #define MOD_MASK_2CLICK     0x20        // use MOD_MASK_MULTI_CLICK
    468 #define MOD_MASK_3CLICK     0x40        // use MOD_MASK_MULTI_CLICK
    469 #define MOD_MASK_4CLICK     0x60        // use MOD_MASK_MULTI_CLICK
    470 #define MOD_MASK_CMD        0x80        // "super" key (macOS: command-key)
    471 
    472 #define MOD_MASK_MULTI_CLICK    (MOD_MASK_2CLICK|MOD_MASK_3CLICK| \
    473                                 MOD_MASK_4CLICK)
    474 
    475 /// The length of the longest special key name, including modifiers.
    476 /// Current longest is <M-C-S-T-D-A-4-ScrollWheelRight> (length includes '<' and '>').
    477 #define MAX_KEY_NAME_LEN    32
    478 
    479 /// Maximum length of a special key event as tokens.  This includes modifiers.
    480 /// The longest event is something like <M-C-S-T-4-LeftDrag> which would be the
    481 /// following string of tokens:
    482 ///
    483 /// <K_SPECIAL> <KS_MODIFIER> bitmask <K_SPECIAL> <KS_EXTRA> <KE_LEFTDRAG>.
    484 ///
    485 /// This is a total of 6 tokens, and is currently the longest one possible.
    486 #define MAX_KEY_CODE_LEN    6
    487 
    488 /// Flags for replace_termcodes()
    489 enum {
    490  REPTERM_FROM_PART   = 1,
    491  REPTERM_DO_LT       = 2,
    492  REPTERM_NO_SPECIAL  = 4,
    493  REPTERM_NO_SIMPLIFY = 8,
    494 };
    495 
    496 /// Flags for find_special_key()
    497 enum {
    498  FSK_KEYCODE    = 0x01,  ///< prefer key code, e.g. K_DEL in place of DEL
    499  FSK_KEEP_X_KEY = 0x02,  ///< don’t translate xHome to Home key
    500  FSK_IN_STRING  = 0x04,  ///< in string, double quote is escaped
    501  FSK_SIMPLIFY   = 0x08,  ///< simplify <C-H>, etc.
    502 };
    503 
    504 #include "keycodes.h.generated.h"