Added termkey_keyname2sym() to API

This commit is contained in:
Paul LeoNerd Evans
2008-12-02 00:56:43 +00:00
parent f75bdf1516
commit 2fba93b690
4 changed files with 39 additions and 1 deletions

View File

@@ -824,6 +824,20 @@ const char *termkey_get_keyname(termkey_t *tk, termkey_keysym sym)
return "UNKNOWN";
}
termkey_keysym termkey_keyname2sym(termkey_t *tk, const char *keyname)
{
/* We store an array, so we can't do better than a linear search. Doesn't
* matter because user won't be calling this too often */
termkey_keysym sym;
for(sym = 0; sym < tk->nkeynames; sym++)
if(tk->keynames[sym] && strcmp(keyname, tk->keynames[sym]) == 0)
return sym;
return TERMKEY_SYM_UNKNOWN;
}
static termkey_keysym register_c0(termkey_t *tk, termkey_keysym sym, unsigned char ctrl, const char *name)
{
return register_c0_full(tk, sym, 0, 0, ctrl, name);