Debian Codegraph @

obvious/lib/markup.lua

raw symbols SCIP
1 -----------------------------------
2 -- Author: Uli Schlachter --
3 -- Copyright 2009 Uli Schlachter --
4 -- Copyright 2009 Majic --
5 -----------------------------------
6
7 local beautiful = require("beautiful")
8 local tostring = tostring
9
10 local markup = {
11 fg = {},
12 bg = {},
13 }
14
15 --[[
16
17 -- Little map of how I
18 -- organized this for usage.
19
20 +-- markup
21 |
22 |`-- bold() Set bold.
23 |`-- italic() Set italicized text.
24 |`-- strike() Set strikethrough text.
25 |`-- underline() Set underlined text.
26 |`-- big() Set bigger text.
27 |`-- small() Set smaller text.
28 |`-- font() Set the font of the text.
29 |
30 |`--+ bg
31 | |
32 | |`-- color() Set background color.
33 | |`-- focus() Set focus background color.
34 | |`-- normal() Set normal background color.
35 | `-- urgent() Set urgent background color.
36 |
37 |`--+ fg
38 | |
39 | |`-- color() Set foreground color.
40 | |`-- focus() Set focus foreground color.
41 | |`-- normal() Set normal foreground color.
42 | `-- urgent() Set urgent foreground color.
43 |
44 |`-- focus() Set both foreground and background focus colors.
45 |`-- normal() Set both foreground and background normal colors.
46 `-- urgent() Set both foreground and background urgent colors.
47
48 ]]
49
50 -- Basic stuff...
51 function markup.bold(text) return '<b>' .. tostring(text) .. '</b>' end
52 function markup.italic(text) return '<i>' .. tostring(text) .. '</i>' end
53 function markup.strike(text) return '<s>' .. tostring(text) .. '</s>' end
54 function markup.underline(text) return '<u>' .. tostring(text) .. '</u>' end
55 function markup.big(text) return '<big>' .. tostring(text) .. '</big>' end
56 function markup.small(text) return '<small>' .. tostring(text) .. '</small>' end
57
58 function markup.font(font, text)
59 return '<span font_desc="' .. tostring(font) .. '">' .. tostring(text) ..'</span>'
60 end
61
62 -- Set the foreground.
63 function markup.fg.color(color, text)
64 return '<span foreground="' .. tostring(color) .. '">' .. tostring(text) .. '</span>'
65 end
66
67 -- Set the background.
68 function markup.bg.color(color, text)
69 return '<span background="' .. tostring(color) .. '">' .. tostring(text) .. '</span>'
70 end
71
72 -- Context: focus
73 function markup.fg.focus(text) return markup.fg.color(beautiful.fg_focus, text) end
74 function markup.bg.focus(text) return markup.bg.color(beautiful.bg_focus, text) end
75 function markup.focus(text) return markup.bg.focus(markup.fg.focus(text)) end
76
77 -- Context: normal
78 function markup.fg.normal(text) return markup.fg.color(beautiful.fg_normal, text) end
79 function markup.bg.normal(text) return markup.bg.color(beautiful.bg_normal, text) end
80 function markup.normal(text) return markup.bg.normal(markup.fg.normal(text)) end
81
82 -- Context: urgent
83 function markup.fg.urgent(text) return markup.fg.color(beautiful.fg_urgent, text) end
84 function markup.bg.urgent(text) return markup.bg.color(beautiful.bg_urgent, text) end
85 function markup.urgent(text) return markup.bg.urgent(markup.fg.urgent(text)) end
86
87 return markup
88
89 -- vim:ft=lua:ts=2:sw=2:sts=2:tw=80:et