haskeline 0.6.1.5 → 0.6.1.6
raw patch · 6 files changed
+29/−20 lines, 6 filessetup-changed
Files
- Setup.hs +7/−4
- System/Console/Haskeline/Backend/DumbTerm.hs +5/−2
- System/Console/Haskeline/Backend/Posix.hsc +4/−5
- System/Console/Haskeline/Backend/Terminfo.hs +3/−1
- System/Console/Haskeline/Backend/Win32.hsc +9/−7
- haskeline.cabal +1/−1
Setup.hs view
@@ -72,11 +72,14 @@ tryCompile :: String -> BuildInfo -> LocalBuildInfo -> Verbosity -> IO Bool tryCompile program bi lbi verb = handle processExit $ handle processException $ do tempDir <- getTemporaryDirectory- withTempFile tempDir ".c" $ \fname h -> do- hPutStr h program- hClose h+ withTempFile tempDir ".c" $ \fname cH ->+ withTempFile tempDir "" $ \execName oH -> do+ hPutStr cH program+ hClose cH+ hClose oH -- TODO take verbosity from the args.- rawSystemProgramStdoutConf verb gccProgram (withPrograms lbi) (fname : args)+ rawSystemProgramStdoutConf verb gccProgram (withPrograms lbi)+ (fname : "-o" : execName : args) return True where processException :: IOException -> IO Bool
System/Console/Haskeline/Backend/DumbTerm.hs view
@@ -7,6 +7,7 @@ import System.IO import qualified Data.ByteString as B+import Control.Concurrent.Chan -- TODO: ---- Put "<" and ">" at end of term if scrolls off.@@ -31,13 +32,15 @@ lift = DumbTerm . lift . lift . lift runDumbTerm :: IO RunTerm-runDumbTerm = posixRunTerm $ \enc h ->+runDumbTerm = do+ ch <- newChan+ posixRunTerm $ \enc h -> TermOps { getLayout = tryGetLayouts (posixLayouts h), runTerm = \f -> runPosixT enc h $ evalStateT' initWindow $ unDumbTerm- $ withPosixGetEvent enc [] f+ $ withPosixGetEvent ch enc [] f } instance (MonadException m, MonadLayout m) => Term (DumbTerm m) where
System/Console/Haskeline/Backend/Posix.hsc view
@@ -164,12 +164,11 @@ ----------------------------- withPosixGetEvent :: (MonadTrans t, MonadIO m, MonadException (t m), MonadReader Prefs m) - => Encoders -> [(String,Key)] -> (t m Event -> t m a) -> t m a-withPosixGetEvent enc termKeys f = do+ => Chan Event -> Encoders -> [(String,Key)] -> (t m Event -> t m a) -> t m a+withPosixGetEvent eventChan enc termKeys f = do baseMap <- lift $ getKeySequences termKeys- evenChan <- liftIO $ newChan- withWindowHandler evenChan- $ f $ liftIO $ getEvent enc baseMap evenChan+ withWindowHandler eventChan+ $ f $ liftIO $ getEvent enc baseMap eventChan withWindowHandler :: MonadException m => Chan Event -> m a -> m a withWindowHandler eventChan = withHandler windowChange $
System/Console/Haskeline/Backend/Terminfo.hs view
@@ -11,6 +11,7 @@ import qualified Control.Exception.Extensible as Exception import qualified Data.ByteString.Char8 as B import Data.Maybe (fromMaybe, catMaybes)+import Control.Concurrent.Chan import System.Console.Haskeline.Monads as Monads import System.Console.Haskeline.LineState@@ -108,6 +109,7 @@ runTerminfoDraw :: IO (Maybe RunTerm) runTerminfoDraw = do mterm <- Exception.try setupTermFromEnv+ ch <- newChan case mterm of -- XXX narrow this: either an ioexception (from getenv) or a -- usererror.@@ -125,7 +127,7 @@ $ runReaderT' actions $ unDraw $ wrapKeypad h term- $ withPosixGetEvent enc (terminfoKeys term) f+ $ withPosixGetEvent ch enc (terminfoKeys term) f } -- If the keypad on/off capabilities are defined, wrap the computation with them.
System/Console/Haskeline/Backend/Win32.hsc view
@@ -41,8 +41,8 @@ $ c_GetNumberOfConsoleInputEvents h numEventsPtr fmap fromEnum $ peek numEventsPtr -getEvent :: HANDLE -> IO Event -getEvent h = newChan >>= keyEventLoop (eventReader h) +getEvent :: HANDLE -> Chan Event -> IO Event +getEvent h = keyEventLoop (eventReader h) eventReader :: HANDLE -> IO [Event] eventReader h = do @@ -312,17 +312,19 @@ oterm <- getConOut case oterm of Nothing -> return fileRT - Just h -> return fileRT { + Just h -> do + ch <- newChan + return fileRT { wrapInterrupt = withWindowMode . withCtrlCHandler, termOps = Just TermOps { getLayout = getBufferSize h, - runTerm = consoleRunTerm h}, + runTerm = consoleRunTerm h ch}, closeTerm = closeHandle h} -consoleRunTerm :: HANDLE -> RunTermType -consoleRunTerm conOut f = do +consoleRunTerm :: HANDLE -> Chan Event -> RunTermType +consoleRunTerm conOut eventChan f = do inH <- liftIO $ getStdHandle sTD_INPUT_HANDLE - runReaderT' conOut $ runDraw $ f $ liftIO $ getEvent inH + runReaderT' conOut $ runDraw $ f $ liftIO $ getEvent inH eventChan -- stdin is not a terminal, but we still need to check the right way to output unicode to stdout. fileRunTerm :: IO RunTerm
haskeline.cabal view
@@ -1,6 +1,6 @@ Name: haskeline Cabal-Version: >=1.6-Version: 0.6.1.5+Version: 0.6.1.6 Category: User Interfaces License: BSD3 License-File: LICENSE