prompt: Make awful.widget.prompt themeable
Adds new optional properties to the theme: prompt_fg prompt_bg prompt_fg_cursor prompt_bg_cursor prompt_font
This commit is contained in:
parent
0be3b0712a
commit
37f0b7e3bf
|
@ -94,6 +94,21 @@
|
|||
-- @module awful.prompt
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
--- The prompt cursor foreground color.
|
||||
-- @beautiful beautiful.prompt_fg_cursor
|
||||
-- @param color
|
||||
-- @see gears.color
|
||||
|
||||
--- The prompt cursor background color.
|
||||
-- @beautiful beautiful.prompt_bg_cursor
|
||||
-- @param color
|
||||
-- @see gears.color
|
||||
|
||||
--- The prompt text font.
|
||||
-- @beautiful beautiful.prompt_font
|
||||
-- @param string
|
||||
-- @see string
|
||||
|
||||
-- Grab environment we need
|
||||
local assert = assert
|
||||
local io = io
|
||||
|
@ -449,11 +464,11 @@ function prompt.run(args, textbox, exe_callback, completion_callback,
|
|||
local command_before_comp
|
||||
local cur_pos_before_comp
|
||||
local prettyprompt = args.prompt or ""
|
||||
local inv_col = args.fg_cursor or theme.fg_focus or "black"
|
||||
local cur_col = args.bg_cursor or theme.bg_focus or "white"
|
||||
local inv_col = args.fg_cursor or theme.prompt_fg_cursor or theme.fg_focus or "black"
|
||||
local cur_col = args.bg_cursor or theme.prompt_bg_cursor or theme.bg_focus or "white"
|
||||
local cur_ul = args.ul_cursor
|
||||
local text = args.text or ""
|
||||
local font = args.font or theme.font
|
||||
local font = args.font or theme.prompt_font or theme.font
|
||||
local selectall = args.selectall
|
||||
local highlighter = args.highlighter
|
||||
local hooks = {}
|
||||
|
|
|
@ -1,17 +1,32 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- The widget version of `awful.prompt`.
|
||||
--
|
||||
-- @DOC_wibox_awidget_defaults_prompt_EXAMPLE@
|
||||
--
|
||||
-- @author Julien Danjou <julien@danjou.info>
|
||||
-- @copyright 2009 Julien Danjou
|
||||
-- @classmod awful.widget.prompt
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
--- The prompt foreground color.
|
||||
-- @beautiful beautiful.prompt_fg
|
||||
-- @param color
|
||||
-- @see gears.color
|
||||
|
||||
--- The prompt background color.
|
||||
-- @beautiful beautiful.prompt_bg
|
||||
-- @param color
|
||||
-- @see gears.color
|
||||
|
||||
local setmetatable = setmetatable
|
||||
|
||||
local completion = require("awful.completion")
|
||||
local util = require("awful.util")
|
||||
local spawn = require("awful.spawn")
|
||||
local prompt = require("awful.prompt")
|
||||
local widget_base = require("wibox.widget.base")
|
||||
local beautiful = require("beautiful")
|
||||
local textbox = require("wibox.widget.textbox")
|
||||
local background = require("wibox.container.background")
|
||||
local type = type
|
||||
|
||||
local widgetprompt = { mt = {} }
|
||||
|
@ -42,16 +57,19 @@ end
|
|||
--
|
||||
-- @param args Arguments table. "prompt" is the prompt to use.
|
||||
-- @return A launcher widget.
|
||||
-- @name awful.widget.prompt
|
||||
function widgetprompt.new(args)
|
||||
args = args or {}
|
||||
local widget = textbox()
|
||||
local promptbox = widget_base.make_widget(widget)
|
||||
local promptbox = background()
|
||||
|
||||
promptbox.widget = widget
|
||||
promptbox.widget:set_ellipsize("start")
|
||||
promptbox.run = run
|
||||
promptbox.spawn_and_handle_error = spawn_and_handle_error
|
||||
promptbox.prompt = args.prompt or "Run: "
|
||||
promptbox.fg = beautiful.prompt_fg or beautiful.fg_normal
|
||||
promptbox.bg = beautiful.prompt_bg or beautiful.bg_normal
|
||||
return promptbox
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
local parent = ... --DOC_NO_USAGE --DOC_HIDE
|
||||
local awful = { widget = { --DOC_HIDE
|
||||
prompt = require("awful.widget.prompt")}}--DOC_HIDE
|
||||
local beautiful = require( "beautiful" ) --DOC_HIDE
|
||||
|
||||
-- Fake a theme --DOC_HIDE
|
||||
beautiful.prompt_fg = "#F6F2E8" --DOC_HIDE
|
||||
beautiful.prompt_bg = "#404040" --DOC_HIDE
|
||||
beautiful.prompt_fg_cursor = "#000000" --DOC_HIDE
|
||||
beautiful.prompt_bg_cursor = "#898941" --DOC_HIDE
|
||||
beautiful.prompt_font = "DejaVu Sans Mono 8" --DOC_HIDE
|
||||
|
||||
|
||||
local myprompt = awful.widget.prompt {
|
||||
prompt = "Execute: "
|
||||
}
|
||||
|
||||
myprompt:run()
|
||||
|
||||
parent:add(myprompt) --DOC_HIDE
|
|
@ -38,6 +38,7 @@ theme.border_marked = "#91231c"
|
|||
-- titlebar_[bg|fg]_[normal|focus]
|
||||
-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color]
|
||||
-- mouse_finder_[color|timeout|animate_timeout|radius|factor]
|
||||
-- prompt_[fg|bg|fg_cursor|bg_cursor|font]
|
||||
-- Example:
|
||||
--theme.taglist_bg_focus = "#ff0000"
|
||||
|
||||
|
|
Loading…
Reference in New Issue