diff --git a/qbar/src/QBar/Theme.hs b/qbar/src/QBar/Theme.hs index cf70679f16bf8454725236e1ba4f6262c46560c8..8990a9363943d484e8905ece43bab0ce9caf39f3 100644 --- a/qbar/src/QBar/Theme.hs +++ b/qbar/src/QBar/Theme.hs @@ -155,7 +155,7 @@ rainbowTheme = AnimatedTheme rainbowThemePipe rainbowBlock :: BlockOutput -> State Integer ThemedBlockOutput rainbowBlock block@BlockOutput{_blockName} = do let text = rawText $ block ^. fullText - let chars = T.unpack . T.reverse $ text + let chars = reverse . splitToChars $ text coloredChars <- mapM rainbowChar chars let rainbowText = reverse coloredChars return $ ThemedBlockOutput { @@ -163,10 +163,10 @@ rainbowTheme = AnimatedTheme rainbowThemePipe _fullText = ThemedBlockText rainbowText, _shortText = Nothing } - rainbowChar :: Char -> State Integer ThemedBlockTextSegment + rainbowChar :: T.Text -> State Integer ThemedBlockTextSegment rainbowChar char = do color <- nextRainbowColor - return $ mkThemedSegment (color, Nothing) $ T.singleton char + return $ mkThemedSegment (color, Nothing) $ char nextRainbowColor :: State Integer Color -- nextRainbowColor = state $ \index -> (rainbowColor (fromInteger index), index + 1) nextRainbowColor = do @@ -178,3 +178,13 @@ rainbowTheme = AnimatedTheme rainbowThemePipe let hue' = position * 3 color = hsv hue' 0.8 1.0 in ColorRGB color + splitToChars :: T.Text -> [T.Text] + splitToChars = splitStringToChars . T.unpack + splitStringToChars :: String -> [T.Text] + splitStringToChars [] = [] + splitStringToChars ('&':xs) = splitStringToCharsAmp "&" xs + splitStringToChars (x:xs) = T.singleton x : splitStringToChars xs + splitStringToCharsAmp :: String -> String -> [T.Text] + splitStringToCharsAmp _ [] = [] + splitStringToCharsAmp acc (';':xs) = T.pack (acc <> ";") : splitStringToChars xs + splitStringToCharsAmp acc (x:xs) = splitStringToCharsAmp (acc <> [x]) xs