From c29693fbd09cb803503a3bb689cf18e4f1b1ec25 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 24 Apr 2016 20:00:34 +0200 Subject: [PATCH] GTK: allow to open terminal at current directory TODO: terminal needs to be configurable --- src/HSFM/GUI/Gtk/Callbacks.hs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/HSFM/GUI/Gtk/Callbacks.hs b/src/HSFM/GUI/Gtk/Callbacks.hs index bd8c04b..4be6606 100644 --- a/src/HSFM/GUI/Gtk/Callbacks.hs +++ b/src/HSFM/GUI/Gtk/Callbacks.hs @@ -68,6 +68,12 @@ import System.Posix.Env.ByteString ( getEnv ) +import qualified System.Posix.Process.ByteString as SPP +import System.Posix.Types + ( + ProcessID + ) + @@ -216,6 +222,9 @@ setViewCallbacks mygui myview = do [Control] <- eventModifier "w" <- fmap glibToString eventKeyName liftIO $ void $ closeTab mygui myview + _ <- viewBox myview `on` keyPressEvent $ tryEvent $ do + "F4" <- fmap glibToString eventKeyName + liftIO $ void $ openTerminalHere myview -- righ-click _ <- view `on` buttonPressEvent $ do @@ -287,7 +296,19 @@ setViewCallbacks mygui myview = do ----- TAB OPERATIONMS ---- +---- OTHER ---- + + +openTerminalHere :: MyView -> IO ProcessID +openTerminalHere myview = do + cwd <- (P.fromAbs . path) <$> getCurrentDir myview + -- TODO: make terminal configurable + SPP.forkProcess $ SPP.executeFile "sakura" True ["-d", cwd] Nothing + + + + +---- TAB OPERATIONS ---- -- |Closes the current tab, but only if there is more than one tab.