implemented row selection

This commit is contained in:
2024-08-22 16:14:23 -04:00
parent 6a4a1fda82
commit 014ca39103
7 changed files with 142 additions and 3 deletions
+20 -1
View File
@@ -42,8 +42,11 @@ import Brick.Keybindings
, newKeyConfig
, onEvent
)
import Control.Monad.State.Class (modify)
import Data.Either (fromRight)
import Graphics.Vty.Input.Events (Key (KUp, KDown))
import Abacus.App.Actions
import Abacus.App.Types
-- | Application keyboard configuration
@@ -57,7 +60,13 @@ keyConfig = newKeyConfig appKeyEvents keyBindings []
-- | Binds a "KeyEventID" to its associated action
eventBindings :: [KeyEventHandler KeyEventID (EventM () AppState)]
eventBindings = [onEvent QuitE "Quits the program" halt]
eventBindings =
[ onEvent QuitE "Quits the program" halt
, onEvent MoveUpE "Moves the cursor up" $
modify moveUp
, onEvent MoveDownE "Moves the cursor down" $
modify moveDown
]
-- | Names the individual key events
appKeyEvents :: KeyEvents KeyEventID
@@ -71,6 +80,16 @@ keyBindings =
, bind 'q'
]
)
, ( MoveUpE
, [ bind KUp
, bind 'k'
]
)
, ( MoveDownE
, [ bind KDown
, bind 'j'
]
)
]
--jl