diff options
author | 2010-06-06 19:00:13 +0000 | |
---|---|---|
committer | 2010-06-06 19:00:13 +0000 | |
commit | 3355cabe34b7412e9cbfa2f2950c53d8b2ef524e (patch) | |
tree | 3a7270d732aaed8376e0ba5709f65a3164cbec43 /usr.bin/tmux/key-string.c | |
parent | Merge bsd.lv release 1.10.0, (diff) | |
download | wireguard-openbsd-3355cabe34b7412e9cbfa2f2950c53d8b2ef524e.tar.xz wireguard-openbsd-3355cabe34b7412e9cbfa2f2950c53d8b2ef524e.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 'usr.bin/tmux/key-string.c')
-rw-r--r-- | usr.bin/tmux/key-string.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c index 07ebb20cf11..79736f1312b 100644 --- a/usr.bin/tmux/key-string.c +++ b/usr.bin/tmux/key-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-string.c,v 1.17 2010/06/05 15:51:53 nicm Exp $ */ +/* $OpenBSD: key-string.c,v 1.18 2010/06/06 19:00:13 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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++) { |