--------------------------------------------------------------------------------
module Patat.Presentation.Display.Internal
    ( DisplaySettings (..)
    , themed
    ) where


--------------------------------------------------------------------------------
import qualified Patat.PrettyPrint as PP
import qualified Patat.Theme       as Theme
import qualified Skylighting       as Skylighting


--------------------------------------------------------------------------------
data DisplaySettings = DisplaySettings
    { DisplaySettings -> Theme
dsTheme     :: !Theme.Theme
    , DisplaySettings -> SyntaxMap
dsSyntaxMap :: !Skylighting.SyntaxMap
    }


--------------------------------------------------------------------------------
themed
    :: DisplaySettings -> (Theme.Theme -> Maybe Theme.Style) -> PP.Doc -> PP.Doc
themed :: DisplaySettings -> (Theme -> Maybe Style) -> Doc -> Doc
themed DisplaySettings
ds Theme -> Maybe Style
f = case Theme -> Maybe Style
f (DisplaySettings -> Theme
dsTheme DisplaySettings
ds) of
    Maybe Style
Nothing                  -> forall a. a -> a
id
    Just (Theme.Style [])    -> forall a. a -> a
id
    Just (Theme.Style [SGR]
codes) -> [SGR] -> Doc -> Doc
PP.ansi [SGR]
codes