toggle between display/edit modes
This commit is contained in:
parent
cc6afa222d
commit
417a8691e8
|
@ -24,15 +24,18 @@ License along with this program. If not, see
|
||||||
|
|
||||||
|-}
|
|-}
|
||||||
|
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
module Hamming.App.Events (eventHandler) where
|
module Hamming.App.Events (eventHandler) where
|
||||||
|
|
||||||
import Brick.Main (halt)
|
import Brick.Main (halt)
|
||||||
import Brick.Types (BrickEvent (VtyEvent))
|
import Brick.Types (BrickEvent (VtyEvent), gets, modify)
|
||||||
import Graphics.Vty.Input.Events
|
import Graphics.Vty.Input.Events
|
||||||
( Event (EvKey)
|
( Event (EvKey)
|
||||||
, Key (KChar)
|
, Key (KChar, KEsc)
|
||||||
, Modifier (MCtrl)
|
, Modifier (MCtrl)
|
||||||
)
|
)
|
||||||
|
import Lens.Micro ((^.), (.~))
|
||||||
|
|
||||||
import Hamming.App.Types
|
import Hamming.App.Types
|
||||||
|
|
||||||
|
@ -40,6 +43,18 @@ import Hamming.App.Types
|
||||||
eventHandler :: Handler
|
eventHandler :: Handler
|
||||||
eventHandler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt
|
eventHandler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt
|
||||||
eventHandler (VtyEvent (EvKey (KChar 'q') [])) = halt
|
eventHandler (VtyEvent (EvKey (KChar 'q') [])) = halt
|
||||||
eventHandler _ = return ()
|
eventHandler e = gets (^.appMode) >>= \case
|
||||||
|
DisplayMode -> displayHandler e
|
||||||
|
EditMode _ -> editHandler e
|
||||||
|
|
||||||
|
displayHandler :: Handler
|
||||||
|
displayHandler (VtyEvent (EvKey (KChar 'e') [])) =
|
||||||
|
modify $ appMode .~ EditMode initialEditor
|
||||||
|
displayHandler _ = return ()
|
||||||
|
|
||||||
|
editHandler :: Handler
|
||||||
|
editHandler (VtyEvent (EvKey KEsc [])) =
|
||||||
|
modify $ appMode .~ DisplayMode
|
||||||
|
editHandler _ = return ()
|
||||||
|
|
||||||
--jl
|
--jl
|
||||||
|
|
Loading…
Reference in New Issue
Block a user