feat(awful: widget: promptbox): accepts `fg` and `bg` as arguments; improve docstring

This commit is contained in:
actionless 2017-02-11 21:43:07 +01:00 committed by Yauhen Kirylau
parent d6412b96fd
commit f8d12a855f
1 changed files with 8 additions and 7 deletions

View File

@ -55,21 +55,22 @@ end
--- Create a prompt widget which will launch a command. --- Create a prompt widget which will launch a command.
-- --
-- @param args Arguments table. "prompt" is the prompt to use. -- @tparam table args Prompt arguments.
-- @return A launcher widget. -- @tparam[opt="Run: "] string args.prompt Prompt text.
-- @tparam[opt=`beautiful.prompt_bg` or `beautiful.bg_normal`] color args.bg Prompt background color.
-- @tparam[opt=`beautiful.prompt_fg` or `beautiful.fg_normal`] color args.fg Prompt foreground color.
-- @return An instance of prompt widget, inherits from `wibox.container.background`.
-- @function awful.widget.prompt -- @function awful.widget.prompt
function widgetprompt.new(args) function widgetprompt.new(args)
args = args or {} args = args or {}
local widget = textbox()
local promptbox = background() local promptbox = background()
promptbox.widget = textbox()
promptbox.widget = widget
promptbox.widget:set_ellipsize("start") promptbox.widget:set_ellipsize("start")
promptbox.run = run promptbox.run = run
promptbox.spawn_and_handle_error = spawn_and_handle_error promptbox.spawn_and_handle_error = spawn_and_handle_error
promptbox.prompt = args.prompt or "Run: " promptbox.prompt = args.prompt or "Run: "
promptbox.fg = beautiful.prompt_fg or beautiful.fg_normal promptbox.fg = args.fg or beautiful.prompt_fg or beautiful.fg_normal
promptbox.bg = beautiful.prompt_bg or beautiful.bg_normal promptbox.bg = args.bg or beautiful.prompt_bg or beautiful.bg_normal
return promptbox return promptbox
end end