diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-05 12:32:24 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-05 13:40:47 +0530 |
| commit | a4144c0c6e0d3df3740c70b9ad947642d9d48ac6 (patch) | |
| tree | 9fc8315aeb5d5ebf867c804d17920216c5396ab1 /lib/Daffm/Action | |
| parent | 556f890c3bb799dd6bc1e83c5dcff12f25ed5c24 (diff) | |
| download | daffm-a4144c0c6e0d3df3740c70b9ad947642d9d48ac6.tar.gz daffm-a4144c0c6e0d3df3740c70b9ad947642d9d48ac6.zip | |
Show keyseq,selections in statusline + minor refactor
Diffstat (limited to 'lib/Daffm/Action')
| -rw-r--r-- | lib/Daffm/Action/Keymap.hs | 23 |
1 files changed, 23 insertions, 0 deletions
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]}) |
