keygrabber: use luaA_pushmodifiers()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-27 21:04:15 +02:00
parent 0705fbf29d
commit e61ab85f5d
2 changed files with 6 additions and 26 deletions

View File

@ -692,31 +692,7 @@ keygrabber_handlekpress(lua_State *L, xcb_key_press_event_t *e)
if(!key_press_lookup_string(e, buf, countof(buf), &ksym))
return false;
lua_createtable(L, 0, 8);
lua_pushboolean(L, e->state & XCB_MOD_MASK_CONTROL);
lua_setfield(L, -2, "Control");
lua_pushboolean(L, e->state & XCB_MOD_MASK_LOCK);
lua_setfield(L, -2, "Lock");
lua_pushboolean(L, e->state & XCB_MOD_MASK_SHIFT);
lua_setfield(L, -2, "Shift");
lua_pushboolean(L, e->state & XCB_MOD_MASK_1);
lua_setfield(L, -2, "Mod1");
lua_pushboolean(L, e->state & XCB_MOD_MASK_2);
lua_setfield(L, -2, "Mod2");
lua_pushboolean(L, e->state & XCB_MOD_MASK_3);
lua_setfield(L, -2, "Mod3");
lua_pushboolean(L, e->state & XCB_MOD_MASK_4);
lua_setfield(L, -2, "Mod4");
lua_pushboolean(L, e->state & XCB_MOD_MASK_5);
lua_setfield(L, -2, "Mod5");
luaA_pushmodifiers(L, e->state);
lua_pushstring(L, buf);

View File

@ -9,6 +9,7 @@ local assert = assert
local io = io
local table = table
local math = math
local ipairs = ipairs
local capi =
{
keygrabber = keygrabber,
@ -161,8 +162,11 @@ function run(args, textbox, exe_callback, completion_callback, history_path, his
end
textbox.text = prettyprompt .. prompt_text_with_cursor(text, inv_col, cur_col, cur_pos, cur_ul, args.selectall)
capi.keygrabber.run(
function (mod, key, event)
function (modifiers, key, event)
if event ~= "press" then return true end
-- Convert index array to hash table
local mod = {}
for k, v in ipairs(modifiers) do mod[v] = true end
-- Get out cases
if (mod.Control and (key == "c" or key == "g"))
or (not mod.Control and key == "Escape") then