From 52c76341217a96a8a89e5dcea148a89c2f64838b Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 22 Aug 2024 19:23:30 -0400 Subject: [PATCH] added reset key --- src/Abacus/App/Events.hs | 7 +++++++ src/Abacus/App/Types.hs | 1 + 2 files changed, 8 insertions(+) diff --git a/src/Abacus/App/Events.hs b/src/Abacus/App/Events.hs index eecfa7d..d92b3c9 100644 --- a/src/Abacus/App/Events.hs +++ b/src/Abacus/App/Events.hs @@ -57,7 +57,9 @@ import Graphics.Vty.Input.Events , KPageDown ) ) +import Lens.Micro.Platform ((%=)) +import Abacus import Abacus.App.Actions import Abacus.App.Types @@ -90,6 +92,8 @@ eventBindings = modify rungLeft , onEvent RungRightE "Moves all beads to the right of the rung" $ modify rungRight + , onEvent ResetBeadsE "Resets the beads on the abacus" $ + abacus %= resetAbacus ] ++ map ( \n -> onEvent (SelRungE n) "Moves to a numbered rung" $ modify $ selRung n @@ -148,6 +152,9 @@ keyBindings = , bind 'L' ] ) + , ( ResetBeadsE + , [bind 'r'] + ) ] ++ map ( \n -> ( SelRungE n diff --git a/src/Abacus/App/Types.hs b/src/Abacus/App/Types.hs index 9d7ddc0..481ab50 100644 --- a/src/Abacus/App/Types.hs +++ b/src/Abacus/App/Types.hs @@ -60,6 +60,7 @@ data KeyEventID | BeadRightE | RungLeftE | RungRightE + | ResetBeadsE | SelRungE Int deriving (Eq, Ord, Show)