make use of .=
and %=
operators
This commit is contained in:
parent
4e5c07a070
commit
ee6e2cb8e6
|
@ -36,8 +36,8 @@ import Graphics.Vty.Input.Events
|
||||||
, Key (..)
|
, Key (..)
|
||||||
, Modifier (MCtrl)
|
, Modifier (MCtrl)
|
||||||
)
|
)
|
||||||
import Lens.Micro ((^.), (.~), (%~))
|
import Lens.Micro ((^.))
|
||||||
import Lens.Micro.Mtl (zoom)
|
import Lens.Micro.Mtl (zoom, (.=), (%=))
|
||||||
|
|
||||||
import Hamming
|
import Hamming
|
||||||
import Hamming.App.Actions
|
import Hamming.App.Actions
|
||||||
|
@ -48,7 +48,7 @@ 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 (VtyEvent (EvKey (KChar 'c') [])) =
|
eventHandler (VtyEvent (EvKey (KChar 'c') [])) =
|
||||||
modify $ hammingCode %~ setCheckBits
|
hammingCode %= setCheckBits
|
||||||
eventHandler (VtyEvent (EvKey (KChar 'v') [])) =
|
eventHandler (VtyEvent (EvKey (KChar 'v') [])) =
|
||||||
zoom hammingCode $ gets correctErrors >>= \case
|
zoom hammingCode $ gets correctErrors >>= \case
|
||||||
Just c -> put c
|
Just c -> put c
|
||||||
|
@ -59,28 +59,28 @@ eventHandler e = gets (^.appMode) >>= \case
|
||||||
|
|
||||||
displayHandler :: Handler
|
displayHandler :: Handler
|
||||||
displayHandler (VtyEvent (EvKey (KChar 'e') [])) =
|
displayHandler (VtyEvent (EvKey (KChar 'e') [])) =
|
||||||
modify $ appMode .~ EditMode initialEditor
|
appMode .= EditMode initialEditor
|
||||||
displayHandler _ = return ()
|
displayHandler _ = return ()
|
||||||
|
|
||||||
editHandler :: Handler
|
editHandler :: Handler
|
||||||
editHandler (VtyEvent (EvKey KEsc [])) =
|
editHandler (VtyEvent (EvKey KEsc [])) =
|
||||||
modify $ appMode .~ DisplayMode
|
appMode .= DisplayMode
|
||||||
editHandler (VtyEvent (EvKey KUp [])) =
|
editHandler (VtyEvent (EvKey KUp [])) =
|
||||||
modify $ appMode.editState %~ moveUp
|
appMode.editState %= moveUp
|
||||||
editHandler (VtyEvent (EvKey (KChar 'k') [])) =
|
editHandler (VtyEvent (EvKey (KChar 'k') [])) =
|
||||||
modify $ appMode.editState %~ moveUp
|
appMode.editState %= moveUp
|
||||||
editHandler (VtyEvent (EvKey KDown [])) =
|
editHandler (VtyEvent (EvKey KDown [])) =
|
||||||
modify $ appMode.editState %~ moveDown
|
appMode.editState %= moveDown
|
||||||
editHandler (VtyEvent (EvKey (KChar 'j') [])) =
|
editHandler (VtyEvent (EvKey (KChar 'j') [])) =
|
||||||
modify $ appMode.editState %~ moveDown
|
appMode.editState %= moveDown
|
||||||
editHandler (VtyEvent (EvKey KLeft [])) =
|
editHandler (VtyEvent (EvKey KLeft [])) =
|
||||||
modify $ appMode.editState %~ moveLeft
|
appMode.editState %= moveLeft
|
||||||
editHandler (VtyEvent (EvKey (KChar 'h') [])) =
|
editHandler (VtyEvent (EvKey (KChar 'h') [])) =
|
||||||
modify $ appMode.editState %~ moveLeft
|
appMode.editState %= moveLeft
|
||||||
editHandler (VtyEvent (EvKey KRight [])) =
|
editHandler (VtyEvent (EvKey KRight [])) =
|
||||||
modify $ appMode.editState %~ moveRight
|
appMode.editState %= moveRight
|
||||||
editHandler (VtyEvent (EvKey (KChar 'l') [])) =
|
editHandler (VtyEvent (EvKey (KChar 'l') [])) =
|
||||||
modify $ appMode.editState %~ moveRight
|
appMode.editState %= moveRight
|
||||||
editHandler (VtyEvent (EvKey (KChar 'f') [])) =
|
editHandler (VtyEvent (EvKey (KChar 'f') [])) =
|
||||||
modify flipBit
|
modify flipBit
|
||||||
editHandler _ = return ()
|
editHandler _ = return ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user