enable code corrections
This commit is contained in:
parent
3661ae559a
commit
1a085ca16b
|
@ -41,6 +41,7 @@ library
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
, brick >=2.1.1 && <2.2
|
, brick >=2.1.1 && <2.2
|
||||||
, microlens >=0.4.13.1 && <0.5
|
, microlens >=0.4.13.1 && <0.5
|
||||||
|
, microlens-mtl >=0.2.0.3 && <0.3
|
||||||
, microlens-th >=0.4.3.15 && <0.5
|
, microlens-th >=0.4.3.15 && <0.5
|
||||||
, mtl >=2.3.1 && <2.4
|
, mtl >=2.3.1 && <2.4
|
||||||
, vty ==6.1.*
|
, vty ==6.1.*
|
||||||
|
@ -60,6 +61,7 @@ executable hamming
|
||||||
, brick >=2.1.1 && <2.2
|
, brick >=2.1.1 && <2.2
|
||||||
, hamming
|
, hamming
|
||||||
, microlens >=0.4.13.1 && <0.5
|
, microlens >=0.4.13.1 && <0.5
|
||||||
|
, microlens-mtl >=0.2.0.3 && <0.3
|
||||||
, microlens-th >=0.4.3.15 && <0.5
|
, microlens-th >=0.4.3.15 && <0.5
|
||||||
, mtl >=2.3.1 && <2.4
|
, mtl >=2.3.1 && <2.4
|
||||||
, vty ==6.1.*
|
, vty ==6.1.*
|
||||||
|
@ -88,6 +90,7 @@ test-suite hamming-test
|
||||||
, hamming
|
, hamming
|
||||||
, hspec >=2.11.9 && <2.12
|
, hspec >=2.11.9 && <2.12
|
||||||
, microlens >=0.4.13.1 && <0.5
|
, microlens >=0.4.13.1 && <0.5
|
||||||
|
, microlens-mtl >=0.2.0.3 && <0.3
|
||||||
, microlens-th >=0.4.3.15 && <0.5
|
, microlens-th >=0.4.3.15 && <0.5
|
||||||
, mtl >=2.3.1 && <2.4
|
, mtl >=2.3.1 && <2.4
|
||||||
, vty ==6.1.*
|
, vty ==6.1.*
|
||||||
|
|
|
@ -22,6 +22,7 @@ dependencies:
|
||||||
- base >= 4.7 && < 5
|
- base >= 4.7 && < 5
|
||||||
- brick >= 2.1.1 && < 2.2
|
- brick >= 2.1.1 && < 2.2
|
||||||
- microlens >= 0.4.13.1 && < 0.5
|
- microlens >= 0.4.13.1 && < 0.5
|
||||||
|
- microlens-mtl >= 0.2.0.3 && < 0.3
|
||||||
- microlens-th >= 0.4.3.15 && < 0.5
|
- microlens-th >= 0.4.3.15 && < 0.5
|
||||||
- mtl >= 2.3.1 && < 2.4
|
- mtl >= 2.3.1 && < 2.4
|
||||||
- vty >= 6.1 && < 6.2
|
- vty >= 6.1 && < 6.2
|
||||||
|
|
|
@ -30,12 +30,14 @@ module Hamming.App.Events (eventHandler) where
|
||||||
|
|
||||||
import Brick.Main (halt)
|
import Brick.Main (halt)
|
||||||
import Brick.Types (BrickEvent (VtyEvent), gets, modify)
|
import Brick.Types (BrickEvent (VtyEvent), gets, modify)
|
||||||
|
import Control.Monad.State.Class (put)
|
||||||
import Graphics.Vty.Input.Events
|
import Graphics.Vty.Input.Events
|
||||||
( Event (EvKey)
|
( Event (EvKey)
|
||||||
, Key (..)
|
, Key (..)
|
||||||
, Modifier (MCtrl)
|
, Modifier (MCtrl)
|
||||||
)
|
)
|
||||||
import Lens.Micro ((^.), (.~), (%~))
|
import Lens.Micro ((^.), (.~), (%~))
|
||||||
|
import Lens.Micro.Mtl (zoom)
|
||||||
|
|
||||||
import Hamming
|
import Hamming
|
||||||
import Hamming.App.Actions
|
import Hamming.App.Actions
|
||||||
|
@ -46,6 +48,10 @@ eventHandler :: Handler
|
||||||
eventHandler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt
|
eventHandler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt
|
||||||
eventHandler (VtyEvent (EvKey (KChar 'c') [])) =
|
eventHandler (VtyEvent (EvKey (KChar 'c') [])) =
|
||||||
modify $ hammingCode %~ setCheckBits
|
modify $ hammingCode %~ setCheckBits
|
||||||
|
eventHandler (VtyEvent (EvKey (KChar 'v') [])) =
|
||||||
|
zoom hammingCode $ gets correctErrors >>= \case
|
||||||
|
Just c -> put c
|
||||||
|
Nothing -> return ()
|
||||||
eventHandler e = gets (^.appMode) >>= \case
|
eventHandler e = gets (^.appMode) >>= \case
|
||||||
DisplayMode -> displayHandler e
|
DisplayMode -> displayHandler e
|
||||||
EditMode _ -> editHandler e
|
EditMode _ -> editHandler e
|
||||||
|
|
Loading…
Reference in New Issue
Block a user