From 59800c356b7737213d80bec5d0b3f0df4b69284c Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Fri, 1 Apr 2011 10:41:44 +0100 Subject: Unicode codepoint is stored in key->code.codepoint, not code.number --- t/11strfkey.c | 6 +++--- t/12strpkey.c | 20 ++++++++++---------- termkey.c | 10 ++++------ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/t/11strfkey.c b/t/11strfkey.c index 00ed847..50cf80a 100644 --- a/t/11strfkey.c +++ b/t/11strfkey.c @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); key.type = TERMKEY_TYPE_UNICODE; - key.code.number = 'A'; + key.code.codepoint = 'A'; key.modifiers = 0; key.utf8[0] = 0; @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) is_str(buffer, "A", "buffer for unicode/A/0 wrapbracket"); key.type = TERMKEY_TYPE_UNICODE; - key.code.number = 'b'; + key.code.codepoint = 'b'; key.modifiers = TERMKEY_KEYMOD_CTRL; key.utf8[0] = 0; @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) is_str(buffer, "", "buffer for unicode/b/CTRL wrapbracket"); key.type = TERMKEY_TYPE_UNICODE; - key.code.number = 'c'; + key.code.codepoint = 'c'; key.modifiers = TERMKEY_KEYMOD_ALT; key.utf8[0] = 0; diff --git a/t/12strpkey.c b/t/12strpkey.c index 648e1c1..71c3f5d 100644 --- a/t/12strpkey.c +++ b/t/12strpkey.c @@ -7,7 +7,7 @@ int main(int argc, char *argv[]) TermKeyKey key; TermKeyResult res; -#define CLEAR_KEY do { key.type = -1; key.code.number = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0) +#define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0) plan_tests(44); @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "A", &key, 0); is_int(res, TERMKEY_RES_KEY, "result for unicode/A/0"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/A/0"); - is_int(key.code.number, 'A', "key.code.number for unicode/A/0"); + is_int(key.code.codepoint, 'A', "key.code.codepoint for unicode/A/0"); is_int(key.modifiers, 0, "key.modifiers for unicode/A/0"); is_str(key.utf8, "A", "key.utf8 for unicode/A/0"); @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "C-b", &key, 0); is_int(res, TERMKEY_RES_KEY, "result for unicode/b/CTRL"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/b/CTRL"); - is_int(key.code.number, 'b', "key.code.number for unicode/b/CTRL"); + is_int(key.code.codepoint, 'b', "key.code.codepoint for unicode/b/CTRL"); is_int(key.modifiers, TERMKEY_KEYMOD_CTRL, "key.modifiers for unicode/b/CTRL"); is_str(key.utf8, "b", "key.utf8 for unicode/b/CTRL"); @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "Ctrl-b", &key, TERMKEY_FORMAT_LONGMOD); is_int(res, TERMKEY_RES_KEY, "result for unicode/b/CTRL longmod"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/b/CTRL longmod"); - is_int(key.code.number, 'b', "key.code.number for unicode/b/CTRL longmod"); + is_int(key.code.codepoint, 'b', "key.code.codepoint for unicode/b/CTRL longmod"); is_int(key.modifiers, TERMKEY_KEYMOD_CTRL, "key.modifiers for unicode/b/CTRL longmod"); is_str(key.utf8, "b", "key.utf8 for unicode/b/CTRL longmod"); @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "^B", &key, TERMKEY_FORMAT_CARETCTRL); is_int(res, TERMKEY_RES_KEY, "result for unicode/b/CTRL caretctrl"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/b/CTRL caretctrl"); - is_int(key.code.number, 'b', "key.code.number for unicode/b/CTRL caretctrl"); + is_int(key.code.codepoint, 'b', "key.code.codepoint for unicode/b/CTRL caretctrl"); is_int(key.modifiers, TERMKEY_KEYMOD_CTRL, "key.modifiers for unicode/b/CTRL caretctrl"); is_str(key.utf8, "b", "key.utf8 for unicode/b/CTRL caretctrl"); @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "A-c", &key, 0); is_int(res, TERMKEY_RES_KEY, "result for unicode/c/ALT"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/c/ALT"); - is_int(key.code.number, 'c', "key.code.number for unicode/c/ALT"); + is_int(key.code.codepoint, 'c', "key.code.codepoint for unicode/c/ALT"); is_int(key.modifiers, TERMKEY_KEYMOD_ALT, "key.modifiers for unicode/c/ALT"); is_str(key.utf8, "c", "key.utf8 for unicode/c/ALT"); @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "Alt-c", &key, TERMKEY_FORMAT_LONGMOD); is_int(res, TERMKEY_RES_KEY, "result for unicode/c/ALT longmod"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/c/ALT longmod"); - is_int(key.code.number, 'c', "key.code.number for unicode/c/ALT longmod"); + is_int(key.code.codepoint, 'c', "key.code.codepoint for unicode/c/ALT longmod"); is_int(key.modifiers, TERMKEY_KEYMOD_ALT, "key.modifiers for unicode/c/ALT longmod"); is_str(key.utf8, "c", "key.utf8 for unicode/c/ALT longmod"); @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "M-c", &key, TERMKEY_FORMAT_ALTISMETA); is_int(res, TERMKEY_RES_KEY, "result for unicode/c/ALT altismeta"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/c/ALT altismeta"); - is_int(key.code.number, 'c', "key.code.number for unicode/c/ALT altismeta"); + is_int(key.code.codepoint, 'c', "key.code.codepoint for unicode/c/ALT altismeta"); is_int(key.modifiers, TERMKEY_KEYMOD_ALT, "key.modifiers for unicode/c/ALT altismeta"); is_str(key.utf8, "c", "key.utf8 for unicode/c/ALT altismeta"); @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "Meta-c", &key, TERMKEY_FORMAT_ALTISMETA|TERMKEY_FORMAT_LONGMOD); is_int(res, TERMKEY_RES_KEY, "result for unicode/c/ALT altismeta+longmod"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/c/ALT altismeta+longmod"); - is_int(key.code.number, 'c', "key.code.number for unicode/c/ALT altismeta+longmod"); + is_int(key.code.codepoint, 'c', "key.code.codepoint for unicode/c/ALT altismeta+longmod"); is_int(key.modifiers, TERMKEY_KEYMOD_ALT, "key.modifiers for unicode/c/ALT altismeta+longmod"); is_str(key.utf8, "c", "key.utf8 for unicode/c/ALT altismeta+longmod"); @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) res = termkey_strpkey(tk, "Up", &key, 0); is_int(res, TERMKEY_RES_KEY, "result for sym/Up/0"); is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for sym/Up/0"); - is_int(key.code.sym, TERMKEY_SYM_UP, "key.code.number for sym/Up/0"); + is_int(key.code.sym, TERMKEY_SYM_UP, "key.code.codepoint for sym/Up/0"); is_int(key.modifiers, 0, "key.modifiers for sym/Up/0"); termkey_destroy(tk); diff --git a/termkey.c b/termkey.c index b1a01ce..0900203 100644 --- a/termkey.c +++ b/termkey.c @@ -1082,13 +1082,13 @@ TermKeyResult termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, Ter return res; if(key->type != TERMKEY_TYPE_UNICODE) return TERMKEY_RES_NONE; - if(key->code.number < '@' || key->code.number > '_') + if(key->code.codepoint < '@' || key->code.codepoint > '_') return TERMKEY_RES_NONE; if(key->modifiers != 0) return TERMKEY_RES_NONE; - if(key->code.number >= 'A' && key->code.number <= 'Z') - key->code.number += 0x20; + if(key->code.codepoint >= 'A' && key->code.codepoint <= 'Z') + key->code.codepoint += 0x20; key->modifiers = TERMKEY_KEYMOD_CTRL; fill_utf8(key); return res; @@ -1112,13 +1112,11 @@ TermKeyResult termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, Ter str = hyphen + 1; } - long codepoint; size_t nbytes; - if(parse_utf8((unsigned char *)str, strlen(str), &codepoint, &nbytes) == TERMKEY_RES_KEY && + if(parse_utf8((unsigned char *)str, strlen(str), &key->code.codepoint, &nbytes) == TERMKEY_RES_KEY && nbytes == strlen(str)) { key->type = TERMKEY_TYPE_UNICODE; - key->code.number = codepoint; fill_utf8(key); } else if((key->code.sym = termkey_keyname2sym(tk, str)) != TERMKEY_SYM_UNKNOWN) { -- cgit v1.2.3-70-g09d2