diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-03 17:30:44 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-03 17:30:44 +0530 |
| commit | 4d669ba5d5858e47b8d5723aae89b75481a2df2f (patch) | |
| tree | 8a939aa17cf850a74b51637a8a7e1a1846e3a02a /lib/Daffm/State.hs | |
| parent | a3d5295ee745ab851c28d0a53147cbad65a7805f (diff) | |
| download | daffm-4d669ba5d5858e47b8d5723aae89b75481a2df2f.tar.gz daffm-4d669ba5d5858e47b8d5723aae89b75481a2df2f.zip | |
Add multifile selection/marking
Diffstat (limited to 'lib/Daffm/State.hs')
| -rw-r--r-- | lib/Daffm/State.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Daffm/State.hs b/lib/Daffm/State.hs index 3990ac0..ead5209 100644 --- a/lib/Daffm/State.hs +++ b/lib/Daffm/State.hs @@ -9,6 +9,7 @@ import Data.Char (toLower) import Data.List (findIndex, sortBy) import qualified Data.Map.Strict as Map import Data.Maybe (fromMaybe) +import qualified Data.Set as Set import qualified Data.Text.Zipper.Generic as Zipper import qualified Data.Vector as Vec import System.Directory (listDirectory, makeAbsolute, setCurrentDirectory) @@ -24,10 +25,18 @@ mkEmptyAppState = stateCmdlineEditor = mkEditor "", stateFocusTarget = FocusMain, stateListPositionCache = Map.empty, + stateFileSelections = Set.empty, stateCwd = "", stateParentDir = "" } +toggleSetItem :: (Ord a) => a -> Set.Set a -> Set.Set a +toggleSetItem val set = + if val `Set.member` set then Set.delete val set else Set.insert val set + +toggleFileSelection :: FilePath -> AppState -> AppState +toggleFileSelection path st = st {stateFileSelections = toggleSetItem path $ stateFileSelections st} + loadDirInAppState :: FilePath -> FilePath -> AppState -> IO AppState loadDirInAppState dir parentDir appState@(AppState {stateCwd, stateListPositionCache}) = do setCurrentDirectory dir |
