diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-06-06 19:00:13 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-06-06 19:00:13 +0000 |
commit | dcc100f165d2d710174db61e54d97610843578fb (patch) | |
tree | d28e5cfb78ea328a928062a9ab7292c56672bb0c /key-string.c | |
parent | 4e3bed20351e0b2293d1445d829795578321e069 (diff) | |
download | rtmux-dcc100f165d2d710174db61e54d97610843578fb.tar.gz rtmux-dcc100f165d2d710174db61e54d97610843578fb.tar.bz2 rtmux-dcc100f165d2d710174db61e54d97610843578fb.zip |
Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.
Diffstat (limited to 'key-string.c')
-rw-r--r-- | key-string.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/key-string.c b/key-string.c index 62717b2f..20240407 100644 --- a/key-string.c +++ b/key-string.c @@ -184,6 +184,15 @@ key_string_lookup_key(int key) *out = '\0'; + /* + * Special case: display C-@ as C-Space. Could do this below in + * the (key >= 0 && key <= 32), but this way we let it be found + * in key_string_table, for the unlikely chance that we might + * change its name. + */ + if ((key & KEYC_MASK_KEY) == 0) + key = ' ' | KEYC_CTRL | (key & KEYC_MASK_MOD); + /* Fill in the modifiers. */ if (key & KEYC_CTRL) strlcat(out, "C-", sizeof out); @@ -191,7 +200,7 @@ key_string_lookup_key(int key) strlcat(out, "M-", sizeof out); if (key & KEYC_SHIFT) strlcat(out, "S-", sizeof out); - key &= ~(KEYC_CTRL|KEYC_ESCAPE|KEYC_SHIFT); + key &= KEYC_MASK_KEY; /* Try the key against the string table. */ for (i = 0; i < nitems(key_string_table); i++) { |