diff options
author | Micah Cowan <micah@micah.cowan.name> | 2010-06-05 20:29:11 +0000 |
---|---|---|
committer | Micah Cowan <micah@micah.cowan.name> | 2010-06-05 20:29:11 +0000 |
commit | 227e458ebbd69d1e8d22f9013de111f734608ba7 (patch) | |
tree | 8394378e8217309998e3b03e2eddf5270033d89b /key-string.c | |
parent | 89eb95265a8acf42f17f7f93b1b5206a20f842a9 (diff) |
Use a macro-based mask for obtaining a key or modifier-set from the combination.
Display C-@, etc, as C-Space, in list-keys.
Diffstat (limited to 'key-string.c')
-rw-r--r-- | key-string.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/key-string.c b/key-string.c index 715324f1..63ab4c98 100644 --- a/key-string.c +++ b/key-string.c @@ -1,4 +1,4 @@ -/* $Id: key-string.c,v 1.33 2010-06-05 06:27:19 micahcowan Exp $ */ +/* $Id: key-string.c,v 1.34 2010-06-05 20:29:11 micahcowan 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++) { |