aboutsummaryrefslogtreecommitdiff
path: root/lib/Daffm/State.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-10-05 23:32:17 +0530
committerAkshay Nair <phenax5@gmail.com>2025-10-08 13:08:32 +0530
commit41d8a90746cd97d1dcb8228c1e9a0846ba9d9b6a (patch)
tree942f95367163ad967323ba41f8a400b654e99688 /lib/Daffm/State.hs
parent424d65e53b99c65f07f36578e3d0975c4d093c0e (diff)
downloaddaffm-41d8a90746cd97d1dcb8228c1e9a0846ba9d9b6a.tar.gz
daffm-41d8a90746cd97d1dcb8228c1e9a0846ba9d9b6a.zip
Add search command
Diffstat (limited to 'lib/Daffm/State.hs')
-rw-r--r--lib/Daffm/State.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Daffm/State.hs b/lib/Daffm/State.hs
index 210cd8d..1429897 100644
--- a/lib/Daffm/State.hs
+++ b/lib/Daffm/State.hs
@@ -32,12 +32,16 @@ mkEmptyAppState config =
stateCwd = "",
stateKeyMap = configKeymap config,
stateOpenerScript = configOpener config,
- stateKeySequence = []
+ stateKeySequence = [],
+ stateSearchTerm = Nothing,
+ stateSearchMatches = Vec.empty,
+ stateSearchIndex = 0
}
toggleSetItem :: (Ord a) => a -> Set.Set a -> Set.Set a
-toggleSetItem val set =
- if Set.member val set then Set.delete val set else Set.insert val set
+toggleSetItem val set
+ | Set.member val set = Set.delete val set
+ | otherwise = Set.insert val set
toggleFileSelection :: FilePathText -> AppState -> AppState
toggleFileSelection path st = st {stateFileSelections = toggleSetItem path $ stateFileSelections st}
@@ -83,7 +87,7 @@ loadDirToState dir' appState@(AppState {stateCwd, stateListPositionHistory}) = d
let targetFilePosM = targetFilePathM >>= \f -> findIndex ((== f) . filePath) files
let pos = fromMaybe 0 (targetFilePosM <|> cachedPosM <|> prevDirPosM)
let list = L.listMoveTo pos $ L.list FocusMain (Vec.fromList files) 1
- pure $ appState {stateFiles = list, stateCwd = dir}
+ pure $ appState {stateFiles = list, stateCwd = dir, stateSearchIndex = 0, stateSearchMatches = Vec.empty}
False -> pure appState
fileTypeFromStatus :: Posix.FileStatus -> FileType