=== modified file 'demo.c' --- demo.c 2008-02-23 20:28:18 +0000 +++ demo.c 2008-02-23 20:26:04 +0000 @@ -1,4 +1,6 @@ #include +#include +#include #include "termkey.h" @@ -14,7 +16,7 @@ key.modifiers & TERMKEY_KEYMOD_SHIFT ? "Shift-" : "", key.modifiers & TERMKEY_KEYMOD_ALT ? "Alt-" : "", key.modifiers & TERMKEY_KEYMOD_CTRL ? "Ctrl-" : "", - termkey_get_keyname(tk, key.code), + termkey_describe_sym(tk, key.code), key.code); else printf("Key %s%s%s%s (U+%04X)\n", === modified file 'termkey.c' --- termkey.c 2008-02-23 20:28:18 +0000 +++ termkey.c 2008-02-23 20:26:04 +0000 @@ -720,6 +720,17 @@ } } +const char *termkey_describe_sym(termkey_t *tk, termkey_keysym code) +{ + if(code == TERMKEY_SYM_UNKNOWN) + return "UNKNOWN"; + + if(code < tk->nkeynames) + return tk->keynames[code]; + + return "UNKNOWN"; +} + termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym code, const char *name) { if(!code) @@ -741,17 +752,6 @@ return code; } -const char *termkey_get_keyname(termkey_t *tk, termkey_keysym code) -{ - if(code == TERMKEY_SYM_UNKNOWN) - return "UNKNOWN"; - - if(code < tk->nkeynames) - return tk->keynames[code]; - - return "UNKNOWN"; -} - termkey_keysym termkey_register_c0(termkey_t *tk, termkey_keysym code, unsigned char ctrl, const char *name) { return termkey_register_c0_full(tk, code, 0, 0, ctrl, name); === modified file 'termkey.h' --- termkey.h 2008-02-23 20:28:18 +0000 +++ termkey.h 2008-02-23 20:26:04 +0000 @@ -135,7 +135,6 @@ // Registration of keys and names termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym code, const char *name); -const char *termkey_get_keyname(termkey_t *tk, termkey_keysym code); termkey_keysym termkey_register_c0(termkey_t *tk, termkey_keysym code, unsigned char ctrl, const char *name); termkey_keysym termkey_register_csi_ss3(termkey_t *tk, termkey_keysym code, unsigned char cmd, const char *name); @@ -147,4 +146,6 @@ termkey_keysym termkey_register_ss3kpalt_full(termkey_t *tk, termkey_keysym code, int modifier_set, int modifier_mask, unsigned char cmd, const char *name, char kpalt); termkey_keysym termkey_register_csifunc_full(termkey_t *tk, termkey_keysym code, int modifier_set, int modifier_mask, int number, const char *name); +const char *termkey_describe_sym(termkey_t *tk, termkey_keysym code); + #endif