added edit mode to application state

This commit is contained in:
2024-07-25 20:06:13 -04:00
parent f995da30b6
commit 8feecdfad5
2 changed files with 32 additions and 7 deletions

View File

@@ -30,7 +30,15 @@ module Hamming.App.Types (
-- * AppState
AppState (..),
-- ** Lenses
appMode,
hammingCode,
-- * AppMode
AppMode (..),
-- * EditState,
EditState (..),
-- ** Lenses
rowNum,
colNum,
-- * Other Types
ResName,
Event,
@@ -46,7 +54,21 @@ import Lens.Micro.TH (makeLenses)
-- | The main state of the application
data AppState = AppState
{ _hammingCode :: Word16
{ _appMode :: AppMode
, _hammingCode :: Word16
}
-- | The application's main mode
data AppMode
= DisplayMode
| EditMode EditState
-- | The state of the editor
data EditState = EditState
{ _rowNum :: Int
-- ^ The selected row number
, _colNum :: Int
-- ^ The selected column
}
-- | Identifies a resource
@@ -61,10 +83,13 @@ type Action a = EventM ResName AppState a
-- | Event handler
type Handler = Event -> Action ()
makeLenses ''AppState
concat <$> mapM makeLenses
[ ''AppState
, ''EditState
]
-- | Initial application state
initialState :: AppState
initialState = AppState 0
initialState = AppState DisplayMode 0
--jl