diff --git a/lib/awful/prompt.lua b/lib/awful/prompt.lua index 6fbefc8a..65c36f48 100644 --- a/lib/awful/prompt.lua +++ b/lib/awful/prompt.lua @@ -1,25 +1,17 @@ --------------------------------------------------------------------------- --- Prompt module for awful. -- +-- **Basic usage**: +-- -- By default, `rc.lua` will create one `awful.widget.prompt` per screen called -- `mypromptbox`. It is used for both the command execution (`mod4+r`) and -- Lua prompt (`mod4+x`). It can be re-used for random inputs using: -- --- -- Create a shortcut function --- local function echo_test() --- awful.prompt.run { --- prompt = "Echo: ", --- textbox = mouse.screen.mypromptbox.widget, --- exe_callback = function(input) --- if not input or #input == 0 then return end --- naughty.notify{ text = "The input was: "..input } --- end --- } --- end +-- @DOC_wibox_awidget_prompt_simple_EXAMPLE@ -- --- -- Then **IN THE globalkeys TABLE** add a new shortcut --- awful.key({ modkey }, "e", echo_test, --- {description = "Echo a string", group = "custom"}), +-- -- Then **IN THE globalkeys TABLE** add a new shortcut +-- awful.key({ modkey }, "e", echo_test, +-- {description = "Echo a string", group = "custom"}), -- -- Note that this assumes an `rc.lua` file based on the default one. The way -- to access the screen prompt may vary. diff --git a/tests/examples/wibox/awidget/prompt/simple.lua b/tests/examples/wibox/awidget/prompt/simple.lua new file mode 100644 index 00000000..f2bb0b01 --- /dev/null +++ b/tests/examples/wibox/awidget/prompt/simple.lua @@ -0,0 +1,31 @@ +local parent = ... --DOC_NO_USAGE --DOC_HIDE +local wibox = require( "wibox" ) --DOC_HIDE +local awful = { prompt = require("awful.prompt") }--DOC_HIDE +local beautiful = require( "beautiful" ) --DOC_HIDE +local naughty = {} --DOC_HIDE + + local atextbox = wibox.widget.textbox() + + -- Create a shortcut function + local function echo_test() + awful.prompt.run { + prompt = "Echo: ", + text = "default command", + bg_cursor = "#ff0000", + -- To use the default `rc.lua` prompt: + --textbox = mouse.screen.mypromptbox.widget, + textbox = atextbox, + exe_callback = function(input) + if not input or #input == 0 then return end + naughty.notify{ text = "The input was: "..input } + end + } + end + +echo_test() --DOC_HIDE + +parent:add( wibox.widget { --DOC_HIDE + atextbox, --DOC_HIDE + bg = beautiful.bg_normal, --DOC_HIDE + widget = wibox.container.background --DOC_HIDE +}) --DOC_HIDE