|
Although we can get away with ignoring termcap/terminfo on the output
side by restricting ourselves to generally-supported escape sequences,
the input side is trickier because we need to support the sequences sent
by common terminals. Luckily, this isn't is as bad as it sounds because
only Home/End commonly differ. But it does mean we need a slightly
different implementation to deal with the many-to-one mapping.
Since we can't use TAGGED_ARRAY for this (without inflicting pain on all
the callers) I've also switched to OR-ing in the modifier keys, so we
have (say) KEY_UP|KEY_SHIFT rather than a separate KEY_SUP. This also
generalizes better should we ever need to support multiple modifiers at
once.
To reduce the number of #defines, I've also switched from KEY_F1,
KEY_F2, and so on to KEY_FN+1, KEY_FN+2, and so on. This isn't obviously
necessary, and easily undone if we'd rather have move #defines in return
for slightly more natural naming.
To enable all this, I've inverted scan_key and scan_key_getsize so that
scan_key_getsize is now the underlying function, and we don't waste all
the top bits encoding width and height between scan_key and
scan_key_getsize.
Tested by pressing Home and End in hexedit in all of the terminals
available to me.
|