awful: add some shortcut keys in prompt
Ctrl + b - Move back a char Ctrl + c - Cancel Ctrl + d - Delete from under the cursor Ctrl + f - Move forward a char Ctrl + j - Enter Ctrl + h - BackSpace Ctrl + k - Delete to EOL Ctrl + m - Enter Ctrl + u - Delete backward from cursor Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4f87935cd4
commit
e7b4d96ab3
|
@ -796,9 +796,13 @@ function P.prompt(args, textbox, exe_callback, completion_callback)
|
||||||
|
|
||||||
-- Get out cases
|
-- Get out cases
|
||||||
if has_ctrl then
|
if has_ctrl then
|
||||||
if key == "g" then
|
if key == "c" or key == "g" then
|
||||||
textbox.text = ""
|
textbox.text = ""
|
||||||
return false
|
return false
|
||||||
|
elseif key == "j" or key == "m" then
|
||||||
|
textbox.text = ""
|
||||||
|
exec_callback(command)
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if key == "Return" then
|
if key == "Return" then
|
||||||
|
@ -815,8 +819,30 @@ function P.prompt(args, textbox, exe_callback, completion_callback)
|
||||||
if has_ctrl then
|
if has_ctrl then
|
||||||
if key == "a" then
|
if key == "a" then
|
||||||
cur_pos = 1
|
cur_pos = 1
|
||||||
|
elseif key == "b" then
|
||||||
|
if cur_pos > 1 then
|
||||||
|
cur_pos = cur_pos - 1
|
||||||
|
end
|
||||||
|
elseif key == "d" then
|
||||||
|
if cur_pos <= #command then
|
||||||
|
command = command:sub(1, cur_pos - 1) .. command:sub(cur_pos + 1)
|
||||||
|
end
|
||||||
elseif key == "e" then
|
elseif key == "e" then
|
||||||
cur_pos = #command + 1
|
cur_pos = #command + 1
|
||||||
|
elseif key == "f" then
|
||||||
|
if cur_pos <= #command then
|
||||||
|
cur_pos = cur_pos + 1
|
||||||
|
end
|
||||||
|
elseif key == "h" then
|
||||||
|
if cur_pos > 1 then
|
||||||
|
command = command:sub(1, cur_pos - 2) .. command:sub(cur_pos)
|
||||||
|
cur_pos = cur_pos - 1
|
||||||
|
end
|
||||||
|
elseif key == "k" then
|
||||||
|
command = command:sub(1, cur_pos - 1)
|
||||||
|
elseif key == "u" then
|
||||||
|
command = command:sub(cur_pos, #command)
|
||||||
|
cur_pos = 1
|
||||||
elseif key == "w" then
|
elseif key == "w" then
|
||||||
local wstart = 1
|
local wstart = 1
|
||||||
local wend = 1
|
local wend = 1
|
||||||
|
|
Loading…
Reference in New Issue