diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2011-04-11 15:41:26 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-04-11 15:41:26 -0700 |
commit | eb27a41b4ad733a53efd576534426334b389d2ae (patch) | |
tree | 123a7d6381112cff2a487486f809fa9c52533188 /com32/libutil | |
parent | b51b322e9fa9b55ed0b181f3d5e5a1f1c8ed6342 (diff) | |
download | syslinux-eb27a41b4ad733a53efd576534426334b389d2ae.tar.gz |
keyname: better handling of named control characters
Named control character (Tab, Enter, Backspace etc.) should use those
names rather than caret sequences.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'com32/libutil')
-rw-r--r-- | com32/libutil/keyname.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/com32/libutil/keyname.c b/com32/libutil/keyname.c index 6aebbd59..3b9e6581 100644 --- a/com32/libutil/keyname.c +++ b/com32/libutil/keyname.c @@ -110,10 +110,8 @@ const char *key_code_to_name(int key) if (key < 0) return NULL; - if (key < 0x100 && key != ' ') { - if (key == 0x7f) { - return "^?"; - } else if (key & 0x60) { + if (key > ' ' && key < 0x100) { + if (key & 0x60) { buf[0] = key; buf[1] = '\0'; } else { @@ -129,5 +127,12 @@ const char *key_code_to_name(int key) return name->string; } + if (key < ' ') { + buf[0] = '^'; + buf[1] = key | 0x40; + buf[2] = '\0'; + return buf; + } + return NULL; } |