2009-04-27 22:08:33 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2009 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local setmetatable = setmetatable
|
|
|
|
|
|
|
|
local capi = { widget = widget }
|
|
|
|
local completion = require("awful.completion")
|
|
|
|
local util = require("awful.util")
|
|
|
|
local prompt = require("awful.prompt")
|
2009-07-02 02:10:32 +02:00
|
|
|
local layout = require("awful.widget.layout")
|
2010-08-01 16:00:03 +02:00
|
|
|
local type = type
|
2009-04-27 22:08:33 +02:00
|
|
|
|
|
|
|
module("awful.widget.prompt")
|
|
|
|
|
|
|
|
--- Run method for promptbox.
|
|
|
|
-- @param promptbox The promptbox to run.
|
|
|
|
local function run(promptbox)
|
|
|
|
return prompt.run({ prompt = promptbox.prompt },
|
|
|
|
promptbox.widget,
|
2010-08-01 16:00:03 +02:00
|
|
|
function (...)
|
|
|
|
local result = util.spawn(...)
|
|
|
|
if type(result) == "string" then
|
|
|
|
promptbox.widget.text = result
|
|
|
|
end
|
|
|
|
end,
|
2009-04-27 22:08:33 +02:00
|
|
|
completion.shell,
|
|
|
|
util.getdir("cache") .. "/history")
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Create a prompt widget which will launch a command.
|
|
|
|
-- @param args Standard widget table arguments, with prompt to change the
|
|
|
|
-- default prompt.
|
|
|
|
-- @return A launcher widget.
|
|
|
|
function new(args)
|
|
|
|
local args = args or {}
|
|
|
|
local promptbox = {}
|
|
|
|
args.type = "textbox"
|
|
|
|
promptbox.widget = capi.widget(args)
|
2009-08-27 14:45:42 +02:00
|
|
|
promptbox.widget.ellipsize = "start"
|
2009-04-27 22:08:33 +02:00
|
|
|
promptbox.run = run
|
|
|
|
promptbox.prompt = args.prompt or "Run: "
|
2009-07-02 02:10:32 +02:00
|
|
|
promptbox.layout = args.layout or layout.horizontal.leftright
|
2009-04-27 22:08:33 +02:00
|
|
|
return promptbox
|
|
|
|
end
|
|
|
|
|
2009-05-25 11:14:08 +02:00
|
|
|
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
2009-04-27 22:08:33 +02:00
|
|
|
|
2012-03-25 17:41:12 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|