Skip to content
Snippets Groups Projects
Verified Commit e2969310 authored by Legy (Beini)'s avatar Legy (Beini)
Browse files

Fix bug in rainbow theme generation with `&` escape sequences

parent 4d2f6a07
No related branches found
No related tags found
1 merge request!9Ags ready
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment