From 7b03f0308b2e428b53a6f6de67b3681dfb421ebc Mon Sep 17 00:00:00 2001 From: Jens Nolte <jens@nightmarestudio.de> Date: Sat, 1 Feb 2020 22:19:46 +0100 Subject: [PATCH] Use record for RenderBlock --- src/QBar/Server.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/QBar/Server.hs b/src/QBar/Server.hs index 1f69276..fcccd91 100644 --- a/src/QBar/Server.hs +++ b/src/QBar/Server.hs @@ -27,16 +27,19 @@ renderIndicator :: CachedBlock -- Using 'cachedBlock' is a hack to actually get the block to update on every bar update (by doing this it will not get a cache later in the pipeline). renderIndicator = forever $ each $ map (mkBlockState . mkBlockOutput . normalText) ["/", "-", "\\", "|"] -data RenderBlock = RenderBlock T.Text (Maybe T.Text) (Maybe T.Text) - deriving(Show) +data RenderBlock = RenderBlock { + renderBlockFullText :: PangoText, + renderBlockShortText :: Maybe PangoText, + renderBlockName :: Maybe T.Text +} deriving(Show) instance ToJSON RenderBlock where - toJSON (RenderBlock fullText' shortText' blockName') = object $ - fullText'' <> shortText'' <> blockName'' <> pango'' + toJSON RenderBlock{renderBlockFullText, renderBlockShortText, renderBlockName} = object $ + fullText' <> shortText' <> blockName' <> pango' where - fullText'' = [ "full_text" .= fullText' ] - shortText'' = fromMaybe (\s -> ["short_text" .= s]) mempty shortText' - blockName'' = fromMaybe (\s -> ["name" .= s]) mempty blockName' - pango'' = [ "markup" .= ("pango" :: T.Text) ] + fullText' = [ "full_text" .= renderBlockFullText ] + shortText' = fromMaybe (\s -> ["short_text" .= s]) mempty renderBlockShortText + blockName' = fromMaybe (\s -> ["name" .= s]) mempty renderBlockName + pango' = [ "markup" .= ("pango" :: T.Text) ] -- |A consumer that accepts lists of 'BlockOutput' and renders them to stdout using the {sway,i3}bar-protocol. -- GitLab