diff options
Diffstat (limited to 'Pty.hs')
-rw-r--r-- | Pty.hs | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,7 +1,7 @@ module Pty (Pty, runWithPty, readPty, writePty) where import System.Posix -import System.Posix.Pty hiding (setTerminalAttributes, getTerminalAttributes) +import System.Posix.Pty import qualified System.Console.Terminal.Size as Console import System.Posix.Signals.Exts import System.Process @@ -17,11 +17,12 @@ runWithPty :: String -> [String] -> ((Pty, ProcessHandle) -> IO a) -> IO a runWithPty cmd params a = bracket setup cleanup go where setup = do - as <- getTerminalAttributes stdInput + as <- System.Posix.getTerminalAttributes stdInput sz <- Console.size (p, ph) <- spawnWithPty Nothing True cmd params (maybe 80 Console.width sz, maybe 25 Console.height sz) _ <- installHandler windowChange (Catch (forwardresize p)) Nothing + System.Posix.Pty.setTerminalAttributes p as Immediately -- This is similar to cfmakeraw(3). let masteras = as `withoutMode` IgnoreBreak @@ -39,7 +40,7 @@ runWithPty cmd params a = bracket setup cleanup go `withoutMode` KeyboardInterrupts `withoutMode` ExtendedFunctions `withoutMode` EnableParity - setTerminalAttributes stdInput masteras Immediately + System.Posix.setTerminalAttributes stdInput masteras Immediately return (p, ph, as) cleanup (p, ph, as) = do -- Needed in case the provided action throws an exception @@ -47,7 +48,7 @@ runWithPty cmd params a = bracket setup cleanup go terminateProcess ph closePty p _ <- installHandler windowChange Default Nothing - setTerminalAttributes stdInput as Immediately + System.Posix.setTerminalAttributes stdInput as Immediately go (p, ph, _) = a (p, ph) forwardresize p = do msz <- Console.size |