diff --git a/hamming.cabal b/hamming.cabal index d30e9b9..92d7e18 100644 --- a/hamming.cabal +++ b/hamming.cabal @@ -41,6 +41,7 @@ library base >=4.7 && <5 , brick >=2.1.1 && <2.2 , microlens >=0.4.13.1 && <0.5 + , microlens-mtl >=0.2.0.3 && <0.3 , microlens-th >=0.4.3.15 && <0.5 , mtl >=2.3.1 && <2.4 , vty ==6.1.* @@ -60,6 +61,7 @@ executable hamming , brick >=2.1.1 && <2.2 , hamming , microlens >=0.4.13.1 && <0.5 + , microlens-mtl >=0.2.0.3 && <0.3 , microlens-th >=0.4.3.15 && <0.5 , mtl >=2.3.1 && <2.4 , vty ==6.1.* @@ -88,6 +90,7 @@ test-suite hamming-test , hamming , hspec >=2.11.9 && <2.12 , microlens >=0.4.13.1 && <0.5 + , microlens-mtl >=0.2.0.3 && <0.3 , microlens-th >=0.4.3.15 && <0.5 , mtl >=2.3.1 && <2.4 , vty ==6.1.* diff --git a/package.yaml b/package.yaml index fd25673..86b4e00 100644 --- a/package.yaml +++ b/package.yaml @@ -22,6 +22,7 @@ dependencies: - base >= 4.7 && < 5 - brick >= 2.1.1 && < 2.2 - microlens >= 0.4.13.1 && < 0.5 +- microlens-mtl >= 0.2.0.3 && < 0.3 - microlens-th >= 0.4.3.15 && < 0.5 - mtl >= 2.3.1 && < 2.4 - vty >= 6.1 && < 6.2 diff --git a/src/Hamming/App/Events.hs b/src/Hamming/App/Events.hs index f060ce5..4323743 100644 --- a/src/Hamming/App/Events.hs +++ b/src/Hamming/App/Events.hs @@ -30,12 +30,14 @@ module Hamming.App.Events (eventHandler) where import Brick.Main (halt) import Brick.Types (BrickEvent (VtyEvent), gets, modify) +import Control.Monad.State.Class (put) import Graphics.Vty.Input.Events ( Event (EvKey) , Key (..) , Modifier (MCtrl) ) import Lens.Micro ((^.), (.~), (%~)) +import Lens.Micro.Mtl (zoom) import Hamming import Hamming.App.Actions @@ -46,6 +48,10 @@ eventHandler :: Handler eventHandler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt eventHandler (VtyEvent (EvKey (KChar 'c') [])) = modify $ hammingCode %~ setCheckBits +eventHandler (VtyEvent (EvKey (KChar 'v') [])) = + zoom hammingCode $ gets correctErrors >>= \case + Just c -> put c + Nothing -> return () eventHandler e = gets (^.appMode) >>= \case DisplayMode -> displayHandler e EditMode _ -> editHandler e