Sync OpenBSD patchset 151:

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.
This commit is contained in:
Tiago Cunha
2009-07-22 16:24:59 +00:00
parent 94e2339842
commit a734488a4b
11 changed files with 160 additions and 176 deletions

View File

@ -1,4 +1,4 @@
/* $Id: key-string.c,v 1.18 2009-07-14 06:38:14 nicm Exp $ */
/* $Id: key-string.c,v 1.19 2009-07-22 16:24:59 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -126,7 +126,7 @@ key_string_lookup_string(const char *string)
}
key = key_string_search_table(ptr);
if (key != KEYC_NONE)
return (KEYC_ADDCTL(key));
return (key | KEYC_CTRL);
return (KEYC_NONE);
}
@ -137,11 +137,11 @@ key_string_lookup_string(const char *string)
if (ptr[1] == '\0') {
if (ptr[0] < 32 || ptr[0] > 127)
return (KEYC_NONE);
return (KEYC_ADDESC(ptr[0]));
return (ptr[0] | KEYC_ESCAPE);
}
key = key_string_lookup_string(ptr);
if (key != KEYC_NONE)
return (KEYC_ADDESC(key));
return (key | KEYC_ESCAPE);
return (KEYC_NONE);
}
@ -158,20 +158,20 @@ key_string_lookup_key(int key)
if (key == 127)
return (NULL);
if (KEYC_ISESC(key)) {
if ((s = key_string_lookup_key(KEYC_REMOVEESC(key))) == NULL)
if (key & KEYC_ESCAPE) {
if ((s = key_string_lookup_key(key & ~KEYC_ESCAPE)) == NULL)
return (NULL);
xsnprintf(tmp2, sizeof tmp2, "M-%s", s);
return (tmp2);
}
if (KEYC_ISCTL(key)) {
if ((s = key_string_lookup_key(KEYC_REMOVECTL(key))) == NULL)
if (key & KEYC_CTRL) {
if ((s = key_string_lookup_key(key & ~KEYC_CTRL)) == NULL)
return (NULL);
xsnprintf(tmp2, sizeof tmp2, "C-%s", s);
return (tmp2);
}
if (KEYC_ISSFT(key)) {
if ((s = key_string_lookup_key(KEYC_REMOVESFT(key))) == NULL)
if (key & KEYC_SHIFT) {
if ((s = key_string_lookup_key(key & ~KEYC_SHIFT)) == NULL)
return (NULL);
xsnprintf(tmp2, sizeof tmp2, "S-%s", s);
return (tmp2);