summaryrefslogtreecommitdiffstats
path: root/src/Much/State.hs
blob: 43756a701d3e79abb93c41197fd295a144c024c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveGeneric #-}
module Much.State where

import Blessings.String (Blessings)
import Data.Aeson
import Data.Time
import GHC.Generics
import Much.TreeView (TreeView)
import Scanner
import System.Posix.Signals
import qualified Data.Text as T
import qualified Data.Map as M
import qualified Data.Tree.Zipper as Z

data State = State
    { cursor :: Z.TreePos Z.Full TreeView
    , xoffset :: Int
    , yoffset :: Int
    , flashMessage :: Blessings String
    , screenWidth :: Int
    , screenHeight :: Int
    , headBuffer :: [Blessings String]
    , treeBuffer :: [Blessings String]
    , now :: UTCTime
    , signalHandlers :: [(Signal, IO ())]
    , query :: String
    , keymap :: String -> State -> IO State
    , mousemap :: Scan -> State -> IO State
    , tagSymbols :: M.Map T.Text T.Text
    , colorConfig :: ColorConfig (Blessings String -> Blessings String)
    }

instance Show (State -> IO ()) where
    show = const "λ"

data ColorConfig a = ColorConfig
    { alt :: a
    , search :: a
    , focus :: a
    , quote :: a
    , boring :: a
    , prefix :: a
    , date :: a
    , tags :: a
    , unreadSearch :: a
    , unreadMessage :: a
    , boringMessage :: a
    , tagMap :: M.Map T.Text a
    } deriving (Generic, Show)

instance FromJSON a => FromJSON (ColorConfig a)