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