packages feed

yi-core 0.14.0 → 0.14.1

raw patch · 2 files changed

+27/−5 lines, 2 filesdep −dyre

Dependencies removed: dyre

Files

src/Yi/Command.hs view
@@ -15,6 +15,7 @@  module Yi.Command where +import           Control.Concurrent  (MVar,newEmptyMVar,putMVar,takeMVar) import           Control.Exception   (SomeException) import           Lens.Micro.Platform ((.=)) import           Control.Monad       (void)@@ -30,7 +31,7 @@ import           Yi.Keymap           (YiM, withUI) import           Yi.MiniBuffer import qualified Yi.Mode.Compilation as Compilation (mode)-import qualified Yi.Mode.Interactive as Interactive (spawnProcess)+import qualified Yi.Mode.Interactive as Interactive (mode,spawnProcess) import           Yi.Monad            (maybeM) import           Yi.Process          (runShellCommand, shellFileName) import qualified Yi.Rope             as R (fromText)@@ -100,11 +101,31 @@    withCurrentBuffer $ setMode Compilation.mode    return () +-- | Run the given command with args in interactive mode.+interactiveRun :: T.Text -> [T.Text] -> (Either SomeException ExitCode -> YiM x) -> YiM ()+interactiveRun cmd args onExit = withOtherWindow $ do+    bc <- liftBase $ newEmptyMVar+    b <- startSubprocess (T.unpack cmd) (T.unpack <$> args) $ \r -> do+      b <- liftBase $ takeMVar bc+      withGivenBuffer b $ setMode Compilation.mode+      onExit r+    maybeM deleteBuffer =<< cabalBuffer <$> getEditorDyn+    withCurrentBuffer $ setMode Interactive.mode+    liftBase $ putMVar bc b+    return ()++-- | Select 'buildRun' or 'interactiveRun' based on stack or cabal command name+selectRunner :: T.Text -> T.Text -> [T.Text] -> (Either SomeException ExitCode -> YiM x) -> YiM ()+selectRunner command = if command `elem` ["eval","exec","ghci","repl","runghc","runhaskell","script"]+  then interactiveRun+  else buildRun+ makeBuild :: CommandArguments -> YiM () makeBuild (CommandArguments args) = buildRun "make" args (const $ return ())  cabalRun :: T.Text -> (Either SomeException ExitCode -> YiM x) -> CommandArguments -> YiM ()-cabalRun cmd onExit (CommandArguments args) = buildRun "cabal" (cmd:args) onExit+cabalRun cmd onExit (CommandArguments args) = runner "cabal" (cmd:args) onExit where+  runner = selectRunner cmd  makeRun :: (Either SomeException ExitCode -> YiM x) -> CommandArguments -> YiM () makeRun onExit (CommandArguments args) = buildRun "make" args onExit@@ -143,4 +164,6 @@ stackCommandE cmd = stackRun cmd (const $ return ())  stackRun :: T.Text -> (Either SomeException ExitCode -> YiM x) -> CommandArguments -> YiM ()-stackRun cmd onExit (CommandArguments args) = buildRun "stack" (cmd:args) onExit+stackRun cmd onExit (CommandArguments args) = runner "stack" (cmd:args) onExit where+    runner = selectRunner cmd+
yi-core.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           yi-core-version:        0.14.0+version:        0.14.1 synopsis:       Yi editor core library category:       Yi homepage:       https://github.com/yi-editor/yi#readme@@ -74,7 +74,6 @@     , yi-language >= 0.1.1.0     , yi-rope >= 0.7.0.0     , semigroups-    , dyre >= 0.8.11   if os(win32)     build-depends:         Win32