aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2008-12-02 00:56:43 +0000
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2008-12-02 00:56:43 +0000
commit2fba93b6904e22e46de66648d5c98af7512e1e1e (patch)
tree074c1f9f991127acbdad7724d3eccfe45d055ab8 /termkey.c
parentf75bdf1516b031b0f975b77f289ea408e30cb9c9 (diff)
downloadtermo-2fba93b6904e22e46de66648d5c98af7512e1e1e.tar.gz
termo-2fba93b6904e22e46de66648d5c98af7512e1e1e.tar.xz
termo-2fba93b6904e22e46de66648d5c98af7512e1e1e.zip
Added termkey_keyname2sym() to API
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/termkey.c b/termkey.c
index b8f06e1..4e0bb5a 100644
--- a/termkey.c
+++ b/termkey.c
@@ -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);