prompt: Unit test the example
This commit is contained in:
parent
856244723c
commit
53d32d362a
|
@ -1,21 +1,13 @@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
--- Prompt module for awful.
|
--- Prompt module for awful.
|
||||||
--
|
--
|
||||||
|
-- **Basic usage**:
|
||||||
|
--
|
||||||
-- By default, `rc.lua` will create one `awful.widget.prompt` per screen called
|
-- 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
|
-- `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:
|
-- Lua prompt (`mod4+x`). It can be re-used for random inputs using:
|
||||||
--
|
--
|
||||||
-- -- Create a shortcut function
|
-- @DOC_wibox_awidget_prompt_simple_EXAMPLE@
|
||||||
-- 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
|
|
||||||
--
|
--
|
||||||
-- -- Then **IN THE globalkeys TABLE** add a new shortcut
|
-- -- Then **IN THE globalkeys TABLE** add a new shortcut
|
||||||
-- awful.key({ modkey }, "e", echo_test,
|
-- awful.key({ modkey }, "e", echo_test,
|
||||||
|
|
|
@ -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 = "<b>Echo: </b>",
|
||||||
|
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
|
Loading…
Reference in New Issue