keybinding: allow individual non-alphabetic characters to be used in bindings

Don't just use XStringToKeysym to get keysyms, because then stuff like ";" doesn't work.
If XStringToKeysym fails and the string is of length 1, use it as the keysym.

Signed-off-by: Nathan Weizenbaum <nex342@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-18 10:06:47 +02:00
parent be52f5b047
commit b37110efd9
1 changed files with 10 additions and 4 deletions

View File

@ -297,12 +297,18 @@ keybinding_find(const xcb_key_press_event_t *ev)
}
static void
__luaA_keystore(keybinding_t *key, const char *str)
luaA_keystore(keybinding_t *key, const char *str, ssize_t len)
{
if(a_strlen(str))
if(len)
{
if(*str != '#')
{
key->keysym = XStringToKeysym(str);
if (!key->keysym && len == 1)
key->keysym = *str;
else
warn("there's no keysym named \"%s\"", str);
}
else
key->keycode = atoi(str + 1);
}
@ -327,13 +333,13 @@ luaA_keybinding_new(lua_State *L)
/* arg 2 is key mod table */
luaA_checktable(L, 2);
/* arg 3 is key */
key = luaL_checkstring(L, 3);
key = luaL_checklstring(L, 3, &len);
/* arg 4 is cmd to run */
luaA_checkfunction(L, 4);
/* get the last arg as function */
k = p_new(keybinding_t, 1);
__luaA_keystore(k, key);
luaA_keystore(k, key, len);
luaA_registerfct(L, &k->fct);
len = lua_objlen(L, 2);