diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-05 23:32:17 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-08 13:08:32 +0530 |
| commit | 41d8a90746cd97d1dcb8228c1e9a0846ba9d9b6a (patch) | |
| tree | 942f95367163ad967323ba41f8a400b654e99688 /lib/Daffm/Action/Commands.hs | |
| parent | 424d65e53b99c65f07f36578e3d0975c4d093c0e (diff) | |
| download | daffm-41d8a90746cd97d1dcb8228c1e9a0846ba9d9b6a.tar.gz daffm-41d8a90746cd97d1dcb8228c1e9a0846ba9d9b6a.zip | |
Add search command
Diffstat (limited to 'lib/Daffm/Action/Commands.hs')
| -rw-r--r-- | lib/Daffm/Action/Commands.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Daffm/Action/Commands.hs b/lib/Daffm/Action/Commands.hs index a9cf691..35262df 100644 --- a/lib/Daffm/Action/Commands.hs +++ b/lib/Daffm/Action/Commands.hs @@ -9,7 +9,7 @@ import Control.Monad.IO.Class (MonadIO (liftIO)) import Daffm.Action.Cmdline import Daffm.Action.Core import Daffm.Types -import Daffm.Utils (trimStart) +import Daffm.Utils (trim, trimStart) import Data.Bifunctor (Bifunctor (second)) import Data.Char (isSpace) import Data.Maybe (fromMaybe) @@ -45,6 +45,9 @@ parseCommand cmd = mkCmd . splitCmdArgs $ trimStart cmd ("cmdline-set", txt) -> Just $ CmdSetCmdline txt ("selection-toggle", _) -> Just CmdToggleSelection ("selection-clear", _) -> Just CmdClearSelection + ("search", term) -> Just $ CmdSearch $ trim term + ("search-next", _) -> Just $ CmdSearchNext 1 + ("search-prev", _) -> Just $ CmdSearchNext (-1) _ -> Nothing readCommandLines' :: Text.Text -> IO [Text.Text] @@ -83,6 +86,8 @@ processCommand CmdToggleSelection = toggleCurrentFileSelection processCommand CmdClearSelection = clearFileSelections processCommand CmdGoBack = goBackToParentDir processCommand (CmdChain chain) = forM_ chain processCommand +processCommand (CmdSearch term) = setSearchTerm term >> applySearch >> nextSearchMatch +processCommand (CmdSearchNext change) = updateSearchIndex (+ change) >> nextSearchMatch processCommand CmdNoop = pure () evaluateCommand :: Text.Text -> AppEvent () |
