svitak/app/State.hs

27 lines
780 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
-- | The mutable application state's initial value. Navigation logic lives in
-- the UI, which renders chapters lazily into 'stCache'.
module State (initialState) where
import qualified Data.Map.Strict as M
import qualified Data.Text as T
import Types (AppState (..), ChapterIndex (..), ReadMode(..))
-- | Empty state shown while the book's structure loads in the background.
initialState :: T.Text -> FilePath -> AppState
initialState title path =
AppState
{ stRefs = [],
stToc = [],
stCache = M.empty,
stIndex = ChapterIndex 0,
stZoom = 1.0,
stTitle = title,
stBookPath = path,
stGen = 0,
stUse = M.empty,
stTick = 0,
stSearchIndex = M.empty,
stMode = Paginated
}