Skip to content
Snippets Groups Projects
Commit 2a520d43 authored by Jens Nolte's avatar Jens Nolte
Browse files

Use type-alias for PangoText where appropriate

parent 4c928d4c
No related branches found
No related tags found
No related merge requests found
......@@ -10,11 +10,10 @@ import qualified Data.Text.Lazy as T
import Numeric (showHex)
data Color = ColorRGB (RGB Double) | ColorRGBA (RGB Double) Double
type Theme = [BlockOutput] -> [(T.Text, Maybe T.Text)]
type Theme = [BlockOutput] -> [(PangoText, Maybe PangoText)]
type SimplifiedTheme = Bool -> Importance -> (Color, Maybe Color)
type AnimatedTheme = Double -> Theme
......@@ -22,20 +21,20 @@ type AnimatedTheme = Double -> Theme
mkTheme :: SimplifiedTheme -> Theme
mkTheme theming' = map themeBlock
where
themeBlock :: BlockOutput -> (T.Text, Maybe T.Text)
themeBlock :: BlockOutput -> (PangoText, Maybe PangoText)
themeBlock block = (fullText', shortText')
where
theming :: SimplifiedTheme
theming
| block^.invalid = invalidSimplifiedTheme
| otherwise = theming'
fullText' :: T.Text
fullText' :: PangoText
fullText' = themeBlockText theming $ block ^. fullText
shortText' :: Maybe T.Text
shortText' :: Maybe PangoText
shortText' = themeBlockText theming <$> block ^. shortText
themeBlockText :: SimplifiedTheme -> BlockText -> T.Text
themeBlockText theming (BlockText b) = foldr ((<>) . themeSegment theming) "" b
themeSegment :: SimplifiedTheme -> BlockTextSegment -> T.Text
themeBlockText :: SimplifiedTheme -> BlockText -> PangoText
themeBlockText theming (BlockText b) = foldMap (themeSegment theming) b
themeSegment :: SimplifiedTheme -> BlockTextSegment -> PangoText
themeSegment theming BlockTextSegment {active, importance, text} = (coloredText' $ theming active importance) text
themeSegment _ (PangoTextSegment text) = text
......
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