Renamed describe_sym to get_keyname

This commit is contained in:
Paul LeoNerd Evans 2008-02-23 20:28:18 +00:00
parent 46e53d124d
commit 9dfd4f1116
3 changed files with 13 additions and 16 deletions

4
demo.c
View File

@ -1,6 +1,4 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "termkey.h" #include "termkey.h"
@ -16,7 +14,7 @@ int main(int argc, char *argv[]) {
key.modifiers & TERMKEY_KEYMOD_SHIFT ? "Shift-" : "", key.modifiers & TERMKEY_KEYMOD_SHIFT ? "Shift-" : "",
key.modifiers & TERMKEY_KEYMOD_ALT ? "Alt-" : "", key.modifiers & TERMKEY_KEYMOD_ALT ? "Alt-" : "",
key.modifiers & TERMKEY_KEYMOD_CTRL ? "Ctrl-" : "", key.modifiers & TERMKEY_KEYMOD_CTRL ? "Ctrl-" : "",
termkey_describe_sym(tk, key.code), termkey_get_keyname(tk, key.code),
key.code); key.code);
else else
printf("Key %s%s%s%s (U+%04X)\n", printf("Key %s%s%s%s (U+%04X)\n",

View File

@ -720,17 +720,6 @@ termkey_result termkey_advisereadable(termkey_t *tk)
} }
} }
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) termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym code, const char *name)
{ {
if(!code) if(!code)
@ -752,6 +741,17 @@ termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym code, cons
return code; 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) 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); return termkey_register_c0_full(tk, code, 0, 0, ctrl, name);

View File

@ -135,6 +135,7 @@ termkey_result termkey_advisereadable(termkey_t *tk);
// Registration of keys and names // Registration of keys and names
termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym code, const char *name); 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_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); termkey_keysym termkey_register_csi_ss3(termkey_t *tk, termkey_keysym code, unsigned char cmd, const char *name);
@ -146,6 +147,4 @@ termkey_keysym termkey_register_csi_ss3_full(termkey_t *tk, termkey_keysym code,
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_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); 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 #endif