diff --git a/lib/awful/prompt.lua.in b/lib/awful/prompt.lua.in index 81af01f1..6d3bb279 100644 --- a/lib/awful/prompt.lua.in +++ b/lib/awful/prompt.lua.in @@ -121,7 +121,7 @@ local function prompt_text_with_cursor(text, text_color, cursor_color, cursor_po end --- Run a prompt in a box. --- @param args A table with optional arguments: fg_cursor, bg_cursor, ul_cursor, prompt. +-- @param args A table with optional arguments: fg_cursor, bg_cursor, ul_cursor, prompt, text, selectall . -- @param textbox The textbox to use for the prompt. -- @param exe_callback The callback function to call with command as argument when finished. -- @param completion_callback The callback function to call to get completion. @@ -143,7 +143,7 @@ function run(args, textbox, exe_callback, completion_callback, history_path, his history_check_load(history_path, history_max) local history_index = history_items(history_path) + 1 -- The cursor position - local cur_pos = text:len() + 1 + local cur_pos = (args.selectall and 1) or text:len() + 1 -- The completion element to use on completion request. local ncomp = 1 if not textbox or not exe_callback then @@ -279,6 +279,7 @@ function run(args, textbox, exe_callback, completion_callback, history_path, his -- len() is UTF-8 aware but #key is not, -- so check that we have one UTF-8 char but advance the cursor of # position if key:len() == 1 then + if args.selectall and cur_pos == 1 then command = "" end command = command:sub(1, cur_pos - 1) .. key .. command:sub(cur_pos) cur_pos = cur_pos + #key end