diff options
author | jao <jao@gnu.org> | 2022-02-08 00:21:31 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-02-08 00:21:31 +0000 |
commit | 48dc39edaca5ff4e011ea9475fe8b75d24b5e4c4 (patch) | |
tree | 47f849a34d3e5eb92b5333984a0beffccf0b4ff1 /src/Xmobar/Text/Output.hs | |
parent | c75f31c0887b12c1e9fd63a05a494d703c43576a (diff) | |
download | xmobar-48dc39edaca5ff4e011ea9475fe8b75d24b5e4c4.tar.gz xmobar-48dc39edaca5ff4e011ea9475fe8b75d24b5e4c4.tar.bz2 |
pango output: fonts
Diffstat (limited to 'src/Xmobar/Text/Output.hs')
-rw-r--r-- | src/Xmobar/Text/Output.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/Xmobar/Text/Output.hs b/src/Xmobar/Text/Output.hs index 134dfed..783a5bb 100644 --- a/src/Xmobar/Text/Output.hs +++ b/src/Xmobar/Text/Output.hs @@ -15,7 +15,8 @@ module Xmobar.Text.Output (initLoop, format) where -import Xmobar.Config.Types (Config(textOutputFormat), TextOutputFormat(..)) +import Xmobar.Config.Types (Config(textOutputFormat, additionalFonts, font) + , TextOutputFormat(..)) import Xmobar.Run.Parsers ( Segment , Widget(..) , parseString @@ -23,7 +24,7 @@ import Xmobar.Run.Parsers ( Segment , colorComponents) import Xmobar.Text.Ansi (withAnsiColor) -import Xmobar.Text.Pango (withPangoColor) +import Xmobar.Text.Pango (withPangoMarkup) import Xmobar.Text.Swaybar (formatSwaybar, prepare) initLoop :: Config -> IO () @@ -31,16 +32,17 @@ initLoop conf = case textOutputFormat conf of Swaybar -> prepare _ -> return () -withColor :: TextOutputFormat -> (String, String) -> String -> String -withColor Ansi c = withAnsiColor c -withColor Pango c = withPangoColor c -withColor _ _ = id - formatWithColor :: Config -> Segment -> String -formatWithColor conf (Text s, info, _, _) = - withColor (textOutputFormat conf) components s - where components = colorComponents conf color - color = tColorsString info +formatWithColor conf (Text s, info, idx, _) = + case textOutputFormat conf of + Ansi -> withAnsiColor (fg, bg) s + Pango -> withPangoMarkup fg bg fn s + _ -> s + where (fg, bg) = colorComponents conf (tColorsString info) + fonts = additionalFonts conf + fn = if idx < 1 || idx > length fonts + then font conf + else fonts !! (idx - 1) formatWithColor conf (Hspace n, i, x, y) = formatWithColor conf (Text $ replicate (fromIntegral n) ' ', i, x, y) formatWithColor _ _ = "" |