Merge pull request #155 from silverhammermba/pango_color
Replace color_strip_alpha with check_pango_color
This commit is contained in:
commit
410a6e5bb2
|
@ -189,7 +189,12 @@ local function prompt_text_with_cursor(args)
|
||||||
text_end = util.escape(text:sub(args.cursor_pos + 1))
|
text_end = util.escape(text:sub(args.cursor_pos + 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
ret = _prompt .. text_start .. "<span background=\"" .. util.color_strip_alpha(args.cursor_color) .. "\" foreground=\"" .. util.color_strip_alpha(args.text_color) .. "\" underline=\"" .. underline .. "\">" .. char .. "</span>" .. text_end .. spacer
|
local cursor_color = util.ensure_pango_color(args.cursor_color)
|
||||||
|
local text_color = util.ensure_pango_color(args.text_color)
|
||||||
|
|
||||||
|
ret = _prompt .. text_start .. "<span background=\"" .. cursor_color ..
|
||||||
|
"\" foreground=\"" .. text_color .. "\" underline=\"" .. underline ..
|
||||||
|
"\">" .. char .. "</span>" .. text_end .. spacer
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ local type = type
|
||||||
local rtable = table
|
local rtable = table
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local string = string
|
local string = string
|
||||||
|
local lgi = require("lgi")
|
||||||
|
local Pango = lgi.Pango
|
||||||
local capi =
|
local capi =
|
||||||
{
|
{
|
||||||
awesome = awesome,
|
awesome = awesome,
|
||||||
|
@ -51,14 +53,13 @@ function util.deprecate(see)
|
||||||
io.stderr:write(".\n" .. tb .. "\n")
|
io.stderr:write(".\n" .. tb .. "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Strip alpha part of color.
|
--- Get a valid color for Pango markup
|
||||||
-- @param color The color.
|
-- @param color The color.
|
||||||
-- @return The color without alpha channel.
|
-- @tparam string fallback The color to return if the first is invalid. (default: black)
|
||||||
function util.color_strip_alpha(color)
|
-- @treturn string color if it is valid, else fallback.
|
||||||
if color:len() == 9 then
|
function util.ensure_pango_color(color, fallback)
|
||||||
color = color:sub(1, 7)
|
color = tostring(color)
|
||||||
end
|
return Pango.Color.parse(Pango.Color(), color) and color or fallback or "black"
|
||||||
return color
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Make i cycle.
|
--- Make i cycle.
|
||||||
|
|
|
@ -99,8 +99,8 @@ function taglist.taglist_label(t, args)
|
||||||
if not tag.getproperty(t, "icon_only") then
|
if not tag.getproperty(t, "icon_only") then
|
||||||
text = "<span font_desc='"..font.."'>"
|
text = "<span font_desc='"..font.."'>"
|
||||||
if fg_color then
|
if fg_color then
|
||||||
text = text .. "<span color='"..util.color_strip_alpha(fg_color).."'>" ..
|
text = text .. "<span color='" .. util.ensure_pango_color(fg_color) ..
|
||||||
(util.escape(t.name) or "") .. "</span>"
|
"'>" .. (util.escape(t.name) or "") .. "</span>"
|
||||||
else
|
else
|
||||||
text = text .. (util.escape(t.name) or "")
|
text = text .. (util.escape(t.name) or "")
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,14 +29,14 @@ tasklist.filter = {}
|
||||||
local function tasklist_label(c, args)
|
local function tasklist_label(c, args)
|
||||||
if not args then args = {} end
|
if not args then args = {} end
|
||||||
local theme = beautiful.get()
|
local theme = beautiful.get()
|
||||||
local fg_normal = args.fg_normal or theme.tasklist_fg_normal or theme.fg_normal or "#ffffff"
|
local fg_normal = util.ensure_pango_color(args.fg_normal or theme.tasklist_fg_normal or theme.fg_normal, "white")
|
||||||
local bg_normal = args.bg_normal or theme.tasklist_bg_normal or theme.bg_normal or "#000000"
|
local bg_normal = args.bg_normal or theme.tasklist_bg_normal or theme.bg_normal or "#000000"
|
||||||
local fg_focus = args.fg_focus or theme.tasklist_fg_focus or theme.fg_focus
|
local fg_focus = util.ensure_pango_color(args.fg_focus or theme.tasklist_fg_focus or theme.fg_focus, fg_normal)
|
||||||
local bg_focus = args.bg_focus or theme.tasklist_bg_focus or theme.bg_focus
|
local bg_focus = args.bg_focus or theme.tasklist_bg_focus or theme.bg_focus or bg_normal
|
||||||
local fg_urgent = args.fg_urgent or theme.tasklist_fg_urgent or theme.fg_urgent
|
local fg_urgent = util.ensure_pango_color(args.fg_urgent or theme.tasklist_fg_urgent or theme.fg_urgent, fg_normal)
|
||||||
local bg_urgent = args.bg_urgent or theme.tasklist_bg_urgent or theme.bg_urgent
|
local bg_urgent = args.bg_urgent or theme.tasklist_bg_urgent or theme.bg_urgent or bg_normal
|
||||||
local fg_minimize = args.fg_minimize or theme.tasklist_fg_minimize or theme.fg_minimize
|
local fg_minimize = util.ensure_pango_color(args.fg_minimize or theme.tasklist_fg_minimize or theme.fg_minimize, fg_normal)
|
||||||
local bg_minimize = args.bg_minimize or theme.tasklist_bg_minimize or theme.bg_minimize
|
local bg_minimize = args.bg_minimize or theme.tasklist_bg_minimize or theme.bg_minimize or bg_normal
|
||||||
local bg_image_normal = args.bg_image_normal or theme.bg_image_normal
|
local bg_image_normal = args.bg_image_normal or theme.bg_image_normal
|
||||||
local bg_image_focus = args.bg_image_focus or theme.bg_image_focus
|
local bg_image_focus = args.bg_image_focus or theme.bg_image_focus
|
||||||
local bg_image_urgent = args.bg_image_urgent or theme.bg_image_urgent
|
local bg_image_urgent = args.bg_image_urgent or theme.bg_image_urgent
|
||||||
|
@ -81,23 +81,19 @@ local function tasklist_label(c, args)
|
||||||
end
|
end
|
||||||
if capi.client.focus == c then
|
if capi.client.focus == c then
|
||||||
bg = bg_focus
|
bg = bg_focus
|
||||||
|
text = text .. "<span color='"..fg_focus.."'>"..name.."</span>"
|
||||||
bg_image = bg_image_focus
|
bg_image = bg_image_focus
|
||||||
if fg_focus then
|
elseif c.urgent then
|
||||||
text = text .. "<span color='"..util.color_strip_alpha(fg_focus).."'>"..name.."</span>"
|
|
||||||
else
|
|
||||||
text = text .. "<span color='"..util.color_strip_alpha(fg_normal).."'>"..name.."</span>"
|
|
||||||
end
|
|
||||||
elseif c.urgent and fg_urgent then
|
|
||||||
bg = bg_urgent
|
bg = bg_urgent
|
||||||
text = text .. "<span color='"..util.color_strip_alpha(fg_urgent).."'>"..name.."</span>"
|
text = text .. "<span color='"..fg_urgent.."'>"..name.."</span>"
|
||||||
bg_image = bg_image_urgent
|
bg_image = bg_image_urgent
|
||||||
elseif c.minimized and fg_minimize and bg_minimize then
|
elseif c.minimized then
|
||||||
bg = bg_minimize
|
bg = bg_minimize
|
||||||
text = text .. "<span color='"..util.color_strip_alpha(fg_minimize).."'>"..name.."</span>"
|
text = text .. "<span color='"..fg_minimize.."'>"..name.."</span>"
|
||||||
bg_image = bg_image_minimize
|
bg_image = bg_image_minimize
|
||||||
else
|
else
|
||||||
bg = bg_normal
|
bg = bg_normal
|
||||||
text = text .. "<span color='"..util.color_strip_alpha(fg_normal).."'>"..name.."</span>"
|
text = text .. "<span color='"..fg_normal.."'>"..name.."</span>"
|
||||||
bg_image = bg_image_normal
|
bg_image = bg_image_normal
|
||||||
end
|
end
|
||||||
text = text .. "</span>"
|
text = text .. "</span>"
|
||||||
|
|
|
@ -86,7 +86,7 @@ local common_args = { w = wibox.layout.fixed.horizontal(),
|
||||||
-- @param c The desired text color.
|
-- @param c The desired text color.
|
||||||
-- @return the text wrapped in a span tag.
|
-- @return the text wrapped in a span tag.
|
||||||
local function colortext(s, c)
|
local function colortext(s, c)
|
||||||
return "<span color='" .. c .. "'>" .. s .. "</span>"
|
return "<span color='" .. awful.util.ensure_pango_color(c) .. "'>" .. s .. "</span>"
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get how the menu item should be displayed.
|
--- Get how the menu item should be displayed.
|
||||||
|
@ -94,8 +94,7 @@ end
|
||||||
-- @return item name, item background color, background image, item icon.
|
-- @return item name, item background color, background image, item icon.
|
||||||
local function label(o)
|
local function label(o)
|
||||||
if o.focused then
|
if o.focused then
|
||||||
local color = awful.util.color_strip_alpha(theme.fg_focus)
|
return colortext(o.name, theme.fg_focus), theme.bg_focus, nil, o.icon
|
||||||
return colortext(o.name, color), theme.bg_focus, nil, o.icon
|
|
||||||
else
|
else
|
||||||
return o.name, theme.bg_normal, nil, o.icon
|
return o.name, theme.bg_normal, nil, o.icon
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue