git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1489 from zudov/psci-ctrl-d-exit
3bc1da9Phil Freeman
psci/PSCi.hs+7−4
@@ -437,10 +437,10 @@ handleKindOf typ = do
437-- Parses the input and returns either a Metacommand, or an error as a string.
437-- Parses the input and returns either a Metacommand, or an error as a string.
438--
438--
439getCommand :: Bool -> InputT (StateT PSCiState IO) (Either String (Maybe Command))
439getCommand :: Bool -> InputT (StateT PSCiState IO) (Either String (Maybe Command))
440−getCommand singleLineMode = do
440+getCommand singleLineMode = handleInterrupt (return (Right Nothing)) $ do
441− firstLine <- getInputLine "> "
441+ firstLine <- withInterrupt $ getInputLine "> "
442 case firstLine of
442 case firstLine of
443− Nothing -> return (Right Nothing)
443+ Nothing -> return (Right (Just QuitPSCi)) -- Ctrl-D when input is empty
444 Just "" -> return (Right Nothing)
444 Just "" -> return (Right Nothing)
445 Just s | singleLineMode || head s == ':' -> return . either Left (Right . Just) $ parseCommand s
445 Just s | singleLineMode || head s == ':' -> return . either Left (Right . Just) $ parseCommand s
446 Just s -> either Left (Right . Just) . parseCommand <$> go [s]
446 Just s -> either Left (Right . Just) . parseCommand <$> go [s]
@@ -555,7 +555,10 @@ loop PSCiOptions{..} = do
555 Left err -> outputStrLn err >> go
555 Left err -> outputStrLn err >> go
556 Right Nothing -> go
556 Right Nothing -> go
557 Right (Just QuitPSCi) -> outputStrLn quitMessage
557 Right (Just QuitPSCi) -> outputStrLn quitMessage
558+ Right (Just c') -> do
559+ handleInterrupt (outputStrLn "Interrupted.")
558− Right (Just c') -> runPSCI (loadAllImportedModules >> handleCommand c') >> go
560+ (withInterrupt (runPSCI (loadAllImportedModules >> handleCommand c')))
561+ go
559
562
560multiLineMode :: Parser Bool
563multiLineMode :: Parser Bool
561multiLineMode = switch $
564multiLineMode = switch $