blob: 446344695e20c34fe4e2af66c92c8fbca0120b2d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
module Daffm.Action.Keymap where
import Control.Monad.State (get, modify)
import Daffm.Action.Commands
import Daffm.Keymap (matchKeySequence)
import Daffm.Types
processKeySequence :: AppEvent KeyMatchResult
processKeySequence = do
(AppState {stateKeyMap, stateKeySequence}) <- get
let match = matchKeySequence stateKeyMap stateKeySequence
case match of
MatchSuccess cmd -> do
processCommand cmd
modify (\st -> st {stateKeySequence = []})
MatchPartial -> pure ()
MatchFailure -> do
modify (\st -> st {stateKeySequence = []})
pure match
appendToKeySequence :: Key -> AppEvent ()
appendToKeySequence key =
modify (\st -> st {stateKeySequence = stateKeySequence st <> [key]})
|