{-# Language TemplateHaskell, OverloadedLists, OverloadedStrings #-}
module Client.Image.Palette
(
Palette(..)
, palNicks
, palSelf
, palSelfHighlight
, palTime
, palMeta
, palSigil
, palLabel
, palLatency
, palWindowName
, palError
, palTextBox
, palActivity
, palMention
, palCommand
, palCommandReady
, palCommandPlaceholder
, palCommandPrefix
, palCommandError
, palWindowDivider
, palLineMarker
, palCModes
, palUModes
, palSnomask
, paletteMap
, defaultPalette
) where
import Control.Lens
import Data.Text (Text)
import Data.Vector (Vector)
import Graphics.Vty.Attributes
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
data Palette = Palette
{ _palNicks :: Vector Attr
, _palSelf :: Attr
, _palSelfHighlight :: Attr
, _palTime :: Attr
, _palMeta :: Attr
, _palSigil :: Attr
, _palLabel :: Attr
, _palLatency :: Attr
, _palWindowName :: Attr
, _palError :: Attr
, _palTextBox :: Attr
, _palActivity :: Attr
, _palMention :: Attr
, _palCommand :: Attr
, _palCommandReady :: Attr
, _palCommandPrefix :: Attr
, _palCommandError :: Attr
, _palCommandPlaceholder :: Attr
, _palWindowDivider :: Attr
, _palLineMarker :: Attr
, _palCModes :: HashMap Char Attr
, _palUModes :: HashMap Char Attr
, _palSnomask :: HashMap Char Attr
}
deriving Show
makeLenses ''Palette
defaultPalette :: Palette
defaultPalette = Palette
{ _palNicks = defaultNickColorPalette
, _palSelf = withForeColor defAttr red
, _palSelfHighlight = withForeColor defAttr red
, _palTime = withForeColor defAttr brightBlack
, _palMeta = withForeColor defAttr brightBlack
, _palSigil = withForeColor defAttr cyan
, _palLabel = withForeColor defAttr green
, _palLatency = withForeColor defAttr yellow
, _palWindowName = withForeColor defAttr cyan
, _palError = withForeColor defAttr red
, _palTextBox = withForeColor defAttr brightBlack
, _palActivity = withForeColor defAttr green
, _palMention = withForeColor defAttr red
, _palCommand = withForeColor defAttr yellow
, _palCommandReady = withForeColor defAttr green
, _palCommandPrefix = withForeColor defAttr blue
, _palCommandError = withForeColor defAttr red
, _palCommandPlaceholder = withStyle defAttr reverseVideo
, _palWindowDivider = withStyle defAttr reverseVideo
, _palLineMarker = defAttr
, _palCModes = HashMap.empty
, _palUModes = HashMap.empty
, _palSnomask = HashMap.empty
}
defaultNickColorPalette :: Vector Attr
defaultNickColorPalette =
withForeColor defAttr <$>
[cyan, magenta, green, yellow, blue,
brightCyan, brightMagenta, brightGreen, brightBlue]
paletteMap :: [(Text, ReifiedLens' Palette Attr)]
paletteMap =
[ ("self" , Lens palSelf)
, ("self-highlight" , Lens palSelfHighlight)
, ("time" , Lens palTime)
, ("meta" , Lens palMeta)
, ("sigil" , Lens palSigil)
, ("label" , Lens palLabel)
, ("latency" , Lens palLatency)
, ("window-name" , Lens palWindowName)
, ("error" , Lens palError)
, ("textbox" , Lens palTextBox)
, ("activity" , Lens palActivity)
, ("mention" , Lens palMention)
, ("command" , Lens palCommand)
, ("command-ready" , Lens palCommandReady)
, ("command-placeholder", Lens palCommandPlaceholder)
, ("command-prefix" , Lens palCommandPrefix)
, ("command-error" , Lens palCommandError)
, ("window-divider" , Lens palWindowDivider)
, ("line-marker" , Lens palLineMarker)
]