From b4fe44842fb6914f9060b0d018de53983b0aab0b Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 25 Dec 2025 12:28:47 +0530 Subject: Add env vars for managing escape-free commands --- lib/Daffm/State.hs | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'lib/Daffm/State.hs') diff --git a/lib/Daffm/State.hs b/lib/Daffm/State.hs index bc91ecb..9b3d81d 100644 --- a/lib/Daffm/State.hs +++ b/lib/Daffm/State.hs @@ -28,21 +28,30 @@ mkEditor = Editor.editor FocusCmdline (Just 1) mkEmptyAppState :: Configuration -> AppState mkEmptyAppState config = - AppState - { stateFiles = L.list FocusMain (Vec.fromList []) 1, - stateMessage = Nothing, - stateCmdlineEditor = mkEditor "", - stateFocusTarget = FocusMain, - stateListPositionHistory = Map.empty, - stateFileSelections = Set.empty, - stateCwd = "", - stateKeyMap = configKeymap config, + applyConfigToState config $ + AppState + { stateFiles = L.list FocusMain (Vec.fromList []) 1, + stateMessage = Nothing, + stateCmdlineEditor = mkEditor "", + stateFocusTarget = FocusMain, + stateListPositionHistory = Map.empty, + stateFileSelections = Set.empty, + stateCwd = "", + stateKeyMap = Map.empty, + stateOpenerScript = Nothing, + stateKeySequence = [], + stateSearchTerm = Nothing, + stateSearchMatches = Vec.empty, + stateCustomCommands = Map.empty, + stateSearchIndex = 0 + } + +applyConfigToState :: Configuration -> AppState -> AppState +applyConfigToState config state = + state + { stateKeyMap = configKeymap config, stateOpenerScript = configOpener config, - stateKeySequence = [], - stateSearchTerm = Nothing, - stateSearchMatches = Vec.empty, - stateCustomCommands = configCommands config, - stateSearchIndex = 0 + stateCustomCommands = configCommands config } toggleSetItem :: (Ord a) => a -> Set.Set a -> Set.Set a -- cgit v1.3.1