awful: add some control with modkeys
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
975eba0049
commit
6d2fc20038
25
awful.lua
25
awful.lua
|
@ -474,6 +474,14 @@ local function menu(args, textbox, exe_callback)
|
|||
textbox:set("text", prompt .. menu_text_with_cursor(text, inv_col, cur_col, cur_pos))
|
||||
keygrabber.run(
|
||||
function (mod, key)
|
||||
local has_ctrl = false
|
||||
|
||||
-- Compute modifiers keys
|
||||
for k, v in ipairs(mod) do
|
||||
if v == "Control" then has_ctrl = true end
|
||||
end
|
||||
|
||||
-- Get out cases
|
||||
if key == "Return" then
|
||||
textbox:set("text", "")
|
||||
exe_callback(command)
|
||||
|
@ -481,7 +489,18 @@ local function menu(args, textbox, exe_callback)
|
|||
elseif key == "Escape" then
|
||||
textbox:set("text", "")
|
||||
return false
|
||||
elseif key == "BackSpace" then
|
||||
end
|
||||
|
||||
-- Control cases
|
||||
if has_ctrl then
|
||||
if key == "a" then
|
||||
cur_pos = 1
|
||||
elseif key == "e" then
|
||||
cur_pos = #command + 1
|
||||
end
|
||||
else
|
||||
-- Typin cases
|
||||
if key == "BackSpace" then
|
||||
command = command:sub(1, cur_pos - 2) .. command:sub(cur_pos)
|
||||
cur_pos = cur_pos - 1
|
||||
-- That's DEL
|
||||
|
@ -500,7 +519,11 @@ local function menu(args, textbox, exe_callback)
|
|||
elseif cur_pos > #command + 1 then
|
||||
cur_pos = #command + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Update textbox
|
||||
textbox:set("text", prompt .. menu_text_with_cursor(command, inv_col, cur_col, cur_pos))
|
||||
|
||||
return true
|
||||
end)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue