summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Text/Output.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xmobar/Text/Output.hs')
-rw-r--r--src/Xmobar/Text/Output.hs24
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 _ _ = ""