Merge pull request #3503 from sarubo/make_markup_available

fix: make markup available
This commit is contained in:
Emmanuel Lepage Vallée 2021-11-21 12:01:06 -08:00 committed by GitHub
commit d328f92fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 5 deletions

View File

@ -46,6 +46,9 @@ local styles = { "year", "month", "yearheader", "monthheader", "header", "weekda
-- @tparam cell_properties table Table of cell style properties -- @tparam cell_properties table Table of cell style properties
--- Cell properties. --- Cell properties.
--
-- @DOC_awful_widget_calendar_popup_cell_properties_EXAMPLE@
--
-- @field markup Markup function or format string -- @field markup Markup function or format string
-- @field fg_color Text foreground color -- @field fg_color Text foreground color
-- @field bg_color Text background color -- @field bg_color Text background color
@ -137,11 +140,14 @@ local function parse_cell_options(cell, args)
-- Get default -- Get default
props[prop] = args[prop] or beautiful["calendar_" .. cell .. "_" .. prop] or bl_style[prop] or default props[prop] = args[prop] or beautiful["calendar_" .. cell .. "_" .. prop] or bl_style[prop] or default
end end
props['markup'] = cell == "focus" and if cell == "focus" and props.markup == nil then
(args['markup'] or beautiful["calendar_" .. cell .. "_markup"] or bl_style['markup'] or local fg = props.fg_color and string.format('foreground="%s"', props.fg_color) or ""
string.format('<span foreground="%s" background="%s"><b>%s</b></span>', local bg = props.bg_color and string.format('background="%s"', props.bg_color) or ""
props['fg_color'], props['bg_color'], "%s") props.markup = string.format(
'<span %s %s><b>%s</b></span>',
fg, bg, "%s"
) )
end
return props return props
end end

View File

@ -0,0 +1,42 @@
--DOC_HIDE_START --DOC_GEN_IMAGE
local awful = require("awful")
local wibox = require("wibox")
screen[1]._resize { width = 480, height = 200 }
local wb = awful.wibar { position = "top", }
-- Create the same number of tags as the default config
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1])
-- Only bother with widgets that are visible by default
local mykeyboardlayout = awful.widget.keyboardlayout()
local my_text_clock = wibox.widget.textclock()
local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {})
local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {})
--DOC_HIDE_END
local my_header_properties = {
markup = function(text) return "<i>" .. text .. "</i>" end,
}
local my_options = { style_header = my_header_properties, }
local month_calendar = awful.widget.calendar_popup.month(my_options)
month_calendar:attach(my_text_clock, "tr")
--DOC_HIDE_START
wb:setup {
layout = wibox.layout.align.horizontal,
{
mytaglist,
layout = wibox.layout.fixed.horizontal,
},
mytasklist,
{
layout = wibox.layout.fixed.horizontal,
mykeyboardlayout,
my_text_clock,
},
}
month_calendar:toggle()
--vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 --DOC_HIDE_END