From a302dfc2aabda53446fb38e035e61ae91b28f84a Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 4 Oct 2025 18:07:30 +0530 Subject: Add multi-key handling + command parsing + shell/shell! aliases --- lib/Daffm/Types.hs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'lib/Daffm/Types.hs') diff --git a/lib/Daffm/Types.hs b/lib/Daffm/Types.hs index ffff4d0..953e3a8 100644 --- a/lib/Daffm/Types.hs +++ b/lib/Daffm/Types.hs @@ -6,6 +6,7 @@ import qualified Brick.Widgets.List as L import qualified Data.Map as Map import qualified Data.Set as Set import qualified Data.Text as Text +import qualified Graphics.Vty as V import System.Posix.Types (FileMode, FileOffset) data FileType @@ -39,10 +40,36 @@ data AppState = AppState stateFocusTarget :: FocusTarget, stateCwd :: FilePathText, stateListPositionCache :: Map.Map Text.Text Int, - stateParentDir :: FilePathText + stateParentDir :: FilePathText, + stateKeySequence :: KeySequence, + stateKeyMap :: Keymap } deriving (Show) type AppEvent = EventM FocusTarget AppState type CmdlineEditor = Editor.Editor Text.Text FocusTarget + +data KeyMatchResult = MatchSuccess Command | MatchPartial | MatchFailure + deriving (Show, Eq) + +data Command + = CmdShell Bool Text.Text + | CmdQuit + | CmdSetCmdline Text.Text + | CmdEnterCmdline + | CmdLeaveCmdline + | CmdOpenSelection + | CmdChangeDir Text.Text + | CmdReload + | CmdToggleSelection + | CmdClearSelection + | CmdGoBack + | CmdNoop + deriving (Show, Eq) + +type Key = V.Key + +type Keymap = Map.Map [Key] Command + +type KeySequence = [Key] -- cgit v1.3.1