aboutsummaryrefslogtreecommitdiff
path: root/lib/Daffm/Action/Commands.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Daffm/Action/Commands.hs')
-rw-r--r--lib/Daffm/Action/Commands.hs7
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 ()