[Toybox] [PATCH] scan_key: support more terminals.
enh
enh at google.com
Sat Mar 23 12:44:49 PDT 2019
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.
---
lib/lib.h | 18 ++++++++--
lib/tty.c | 99 +++++++++++++++++++++++++++++--------------------------
2 files changed, 68 insertions(+), 49 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-scan_key-support-more-terminals.patch
Type: text/x-patch
Size: 7772 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190323/ed964184/attachment-0002.bin>
More information about the Toybox
mailing list