aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--daffm.cabal1
-rw-r--r--lib/Daffm.hs10
-rw-r--r--notes.org16
3 files changed, 24 insertions, 3 deletions
diff --git a/daffm.cabal b/daffm.cabal
index 5f74735..a9cce5f 100644
--- a/daffm.cabal
+++ b/daffm.cabal
@@ -30,6 +30,7 @@ common common-config
data-default <= 0.8.0.1,
directory <= 1.3.9.0,
filepath <= 1.5.4.0,
+ process <= 1.6.26.1,
unix-compat <= 0.7.4.1,
mtl == 2.3.1,
temporary,
diff --git a/lib/Daffm.hs b/lib/Daffm.hs
index 5bd0830..a7a3705 100644
--- a/lib/Daffm.hs
+++ b/lib/Daffm.hs
@@ -1,5 +1,6 @@
module Daffm where
+import Brick (suspendAndResume')
import qualified Brick.Main as M
import qualified Brick.Types as T
import qualified Brick.Widgets.Edit as Editor
@@ -18,6 +19,7 @@ import qualified Graphics.Vty as V
import System.Directory (listDirectory, makeAbsolute, setCurrentDirectory)
import System.FilePath (takeDirectory)
import qualified System.PosixCompat as Posix
+import System.Process (callProcess)
type AppEvent = T.EventM FocusTarget AppState
@@ -33,7 +35,9 @@ openSelectedFile = do
Just (FileInfo {filePath, fileType = Directory}) ->
modifyM (liftIO . loadDirInAppState filePath stateCwd)
Just (FileInfo {filePath, fileType}) -> do
- liftIO . putStrLn $ "Opening " <> show fileType <> ": " <> filePath
+ suspendAndResume' $ do
+ callProcess "nvim" [filePath]
+ putStrLn $ "Opening " <> show fileType <> ": " <> filePath
pure ()
Nothing -> pure ()
pure ()
@@ -47,8 +51,8 @@ appEvent :: T.BrickEvent FocusTarget e -> AppEvent ()
appEvent brickevent@(T.VtyEvent event) = do
focusTarget <- gets stateFocusTarget
case (focusTarget, event) of
- (_, V.EvKey V.KEsc []) -> modify (\st -> st {stateFocusTarget = FocusMain})
- (_, V.EvKey (V.KChar ':') []) -> modify (\st -> st {stateFocusTarget = FocusCmdline})
+ (FocusCmdline, V.EvKey V.KEsc []) -> modify (\st -> st {stateFocusTarget = FocusMain})
+ (FocusMain, V.EvKey (V.KChar ':') []) -> modify (\st -> st {stateFocusTarget = FocusCmdline})
(FocusMain, V.EvKey (V.KChar 'q') []) -> M.halt
(FocusMain, V.EvKey (V.KChar 'l') []) -> openSelectedFile
(FocusMain, V.EvKey (V.KChar 'h') []) -> goBackToParentDir
diff --git a/notes.org b/notes.org
new file mode 100644
index 0000000..d7beb46
--- /dev/null
+++ b/notes.org
@@ -0,0 +1,16 @@
+** Current
+- [ ] Show file permissions
+- [ ] Preserve cursor position per dir while navigating
+- [ ] Cmdline must be single line
+- [ ] Commands
+- [ ] Run shell command
+- [ ] Command substitutions (%:filehighlighted %d:cwd %s:selections)
+** Later
+- [ ] handle on open (for external integrations)
+- [ ] Cmdline history
+- [ ] bind command: define keybindings
+- [ ] copy/paste across instances
+ - user-land solution (write selections to file and read from second instance)
+ - socket
+- [ ] support multikey bindings?
+- [ ] configuration file (toml?)