From a4144c0c6e0d3df3740c70b9ad947642d9d48ac6 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 5 Oct 2025 12:32:24 +0530 Subject: Show keyseq,selections in statusline + minor refactor --- lib/Daffm/Action/Keymap.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/Daffm/Action/Keymap.hs (limited to 'lib/Daffm/Action/Keymap.hs') diff --git a/lib/Daffm/Action/Keymap.hs b/lib/Daffm/Action/Keymap.hs new file mode 100644 index 0000000..4463446 --- /dev/null +++ b/lib/Daffm/Action/Keymap.hs @@ -0,0 +1,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]}) -- cgit v1.3.1