awful.prompt: fix Shift-Tab
1. before this patch the "Shift" key(s) to get to Shift-Tab would reset ncomp already. 2. "Shift-Tab" will come in as "Tab" with mod.Shift typically. 3. cur_pos and ncomp have to get reset in case of going back to the original entry.
This commit is contained in:
parent
a6c36a4a2e
commit
5dcd5969be
|
@ -308,7 +308,7 @@ end
|
||||||
-- @callback exe_callback
|
-- @callback exe_callback
|
||||||
-- @tparam string command The command (as entered).
|
-- @tparam string command The command (as entered).
|
||||||
|
|
||||||
--- The callback function to call to get completion.
|
--- The callback function to get completions.
|
||||||
-- @usage local function my_completion_cb(command_before_comp, cur_pos_before_comp, ncomp)
|
-- @usage local function my_completion_cb(command_before_comp, cur_pos_before_comp, ncomp)
|
||||||
-- return command_before_comp.."foo", cur_pos_before_comp+3, 1
|
-- return command_before_comp.."foo", cur_pos_before_comp+3, 1
|
||||||
-- end
|
-- end
|
||||||
|
@ -316,7 +316,7 @@ end
|
||||||
-- @callback completion_callback
|
-- @callback completion_callback
|
||||||
-- @tparam string command_before_comp The current command.
|
-- @tparam string command_before_comp The current command.
|
||||||
-- @tparam number cur_pos_before_comp The current cursor position.
|
-- @tparam number cur_pos_before_comp The current cursor position.
|
||||||
-- @tparam number ncomp The number of completion elements.
|
-- @tparam number ncomp The number of the currently completed element.
|
||||||
-- @treturn string command
|
-- @treturn string command
|
||||||
-- @treturn number cur_pos
|
-- @treturn number cur_pos
|
||||||
-- @treturn number matches
|
-- @treturn number matches
|
||||||
|
@ -790,7 +790,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback,
|
||||||
else
|
else
|
||||||
if completion_callback then
|
if completion_callback then
|
||||||
if key == "Tab" or key == "ISO_Left_Tab" then
|
if key == "Tab" or key == "ISO_Left_Tab" then
|
||||||
if key == "ISO_Left_Tab" then
|
if key == "ISO_Left_Tab" or mod.Shift then
|
||||||
if ncomp == 1 then return end
|
if ncomp == 1 then return end
|
||||||
if ncomp == 2 then
|
if ncomp == 2 then
|
||||||
command = command_before_comp
|
command = command_before_comp
|
||||||
|
@ -799,6 +799,8 @@ function prompt.run(args, textbox, exe_callback, completion_callback,
|
||||||
text = command_before_comp, text_color = inv_col, cursor_color = cur_col,
|
text = command_before_comp, text_color = inv_col, cursor_color = cur_col,
|
||||||
cursor_pos = cur_pos, cursor_ul = cur_ul, selectall = selectall,
|
cursor_pos = cur_pos, cursor_ul = cur_ul, selectall = selectall,
|
||||||
prompt = prettyprompt })
|
prompt = prettyprompt })
|
||||||
|
cur_pos = cur_pos_before_comp
|
||||||
|
ncomp = 1
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -816,7 +818,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback,
|
||||||
exec(exe_callback)
|
exec(exe_callback)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
elseif key ~= "Shift_L" and key ~= "Shift_R" then
|
||||||
ncomp = 1
|
ncomp = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue