module System.Console.Haskeline(
InputT,
runInputT,
haveTerminalUI,
mapInputT,
Behavior,
runInputTBehavior,
defaultBehavior,
useFileHandle,
useFile,
preferTerm,
getInputLine,
getInputLineWithInitial,
getInputChar,
getPassword,
waitForAnyKey,
outputStr,
outputStrLn,
getExternalPrint,
Settings(..),
defaultSettings,
setComplete,
Prefs(),
readPrefs,
defaultPrefs,
runInputTWithPrefs,
runInputTBehaviorWithPrefs,
withRunInBase,
getHistory,
putHistory,
modifyHistory,
withInterrupt,
Interrupt(..),
handleInterrupt,
module System.Console.Haskeline.Completion)
where
import System.Console.Haskeline.LineState
import System.Console.Haskeline.Command
import System.Console.Haskeline.Vi
import System.Console.Haskeline.Emacs
import System.Console.Haskeline.Prefs
import System.Console.Haskeline.History
import System.Console.Haskeline.Monads
import System.Console.Haskeline.InputT
import System.Console.Haskeline.Completion
import System.Console.Haskeline.Term
import System.Console.Haskeline.Key
import System.Console.Haskeline.RunCommand
import Control.Monad.Catch (MonadMask, handle)
import Data.Char (isSpace, isPrint)
import Data.Maybe (isJust)
import System.IO
defaultSettings :: MonadIO m => Settings m
defaultSettings :: forall (m :: * -> *). MonadIO m => Settings m
defaultSettings = Settings {complete :: CompletionFunc m
complete = forall (m :: * -> *). MonadIO m => CompletionFunc m
completeFilename,
historyFile :: Maybe FilePath
historyFile = forall a. Maybe a
Nothing,
autoAddHistory :: Bool
autoAddHistory = Bool
True}
outputStr :: MonadIO m => String -> InputT m ()
outputStr :: forall (m :: * -> *). MonadIO m => FilePath -> InputT m ()
outputStr FilePath
xs = do
FilePath -> IO ()
putter <- forall (m :: * -> *) a.
ReaderT
RunTerm
(ReaderT
(IORef History)
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))
a
-> InputT m a
InputT forall a b. (a -> b) -> a -> b
$ forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks RunTerm -> FilePath -> IO ()
putStrOut
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ FilePath -> IO ()
putter FilePath
xs
outputStrLn :: MonadIO m => String -> InputT m ()
outputStrLn :: forall (m :: * -> *). MonadIO m => FilePath -> InputT m ()
outputStrLn = forall (m :: * -> *). MonadIO m => FilePath -> InputT m ()
outputStr forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. [a] -> [a] -> [a]
++ FilePath
"\n")
getInputLine :: (MonadIO m, MonadMask m)
=> String
-> InputT m (Maybe String)
getInputLine :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
FilePath -> InputT m (Maybe FilePath)
getInputLine = forall (m :: * -> *) a.
MonadIO m =>
(TermOps -> Prefix -> InputT m a)
-> (FileOps -> IO a) -> FilePath -> InputT m a
promptedInput (forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
InsertMode -> TermOps -> Prefix -> InputT m (Maybe FilePath)
getInputCmdLine InsertMode
emptyIM) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileOps -> MaybeT IO FilePath
getLocaleLine
getInputLineWithInitial :: (MonadIO m, MonadMask m)
=> String
-> (String, String)
-> InputT m (Maybe String)
getInputLineWithInitial :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
FilePath -> (FilePath, FilePath) -> InputT m (Maybe FilePath)
getInputLineWithInitial FilePath
prompt (FilePath
left,FilePath
right) = forall (m :: * -> *) a.
MonadIO m =>
(TermOps -> Prefix -> InputT m a)
-> (FileOps -> IO a) -> FilePath -> InputT m a
promptedInput (forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
InsertMode -> TermOps -> Prefix -> InputT m (Maybe FilePath)
getInputCmdLine InsertMode
initialIM)
(forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileOps -> MaybeT IO FilePath
getLocaleLine) FilePath
prompt
where
initialIM :: InsertMode
initialIM = FilePath -> InsertMode -> InsertMode
insertString FilePath
left forall a b. (a -> b) -> a -> b
$ forall s. Move s => s -> s
moveToStart forall a b. (a -> b) -> a -> b
$ FilePath -> InsertMode -> InsertMode
insertString FilePath
right forall a b. (a -> b) -> a -> b
$ InsertMode
emptyIM
getInputCmdLine :: (MonadIO m, MonadMask m) => InsertMode -> TermOps -> Prefix -> InputT m (Maybe String)
getInputCmdLine :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
InsertMode -> TermOps -> Prefix -> InputT m (Maybe FilePath)
getInputCmdLine InsertMode
initialIM TermOps
tops Prefix
prefix = do
EditMode
emode <- forall (m :: * -> *) a.
ReaderT
RunTerm
(ReaderT
(IORef History)
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))
a
-> InputT m a
InputT forall a b. (a -> b) -> a -> b
$ forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Prefs -> EditMode
editMode
Maybe FilePath
result <- forall (m :: * -> *) a.
MonadIO m =>
TermOps -> InputCmdT m a -> InputT m a
runInputCmdT TermOps
tops forall a b. (a -> b) -> a -> b
$ case EditMode
emode of
EditMode
Emacs -> forall (m :: * -> *) s a.
(CommandMonad m, MonadState Layout m, LineState s) =>
TermOps -> Prefix -> KeyCommand m s a -> s -> m a
runCommandLoop TermOps
tops Prefix
prefix InputKeyCmd InsertMode (Maybe FilePath)
emacsCommands InsertMode
initialIM
EditMode
Vi -> forall (m :: * -> *) s a. Monad m => s -> StateT s m a -> m a
evalStateT' forall (m :: * -> *). Monad m => ViState m
emptyViState forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) s a.
(CommandMonad m, MonadState Layout m, LineState s) =>
TermOps -> Prefix -> KeyCommand m s a -> s -> m a
runCommandLoop TermOps
tops Prefix
prefix InputKeyCmd InsertMode (Maybe FilePath)
viKeyCommands InsertMode
initialIM
forall (m :: * -> *). MonadIO m => Maybe FilePath -> InputT m ()
maybeAddHistory Maybe FilePath
result
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe FilePath
result
maybeAddHistory :: forall m . MonadIO m => Maybe String -> InputT m ()
maybeAddHistory :: forall (m :: * -> *). MonadIO m => Maybe FilePath -> InputT m ()
maybeAddHistory Maybe FilePath
result = do
Settings m
settings :: Settings m <- forall (m :: * -> *) a.
ReaderT
RunTerm
(ReaderT
(IORef History)
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))
a
-> InputT m a
InputT forall r (m :: * -> *). MonadReader r m => m r
ask
HistoryDuplicates
histDupes <- forall (m :: * -> *) a.
ReaderT
RunTerm
(ReaderT
(IORef History)
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))
a
-> InputT m a
InputT forall a b. (a -> b) -> a -> b
$ forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Prefs -> HistoryDuplicates
historyDuplicates
case Maybe FilePath
result of
Just FilePath
line | forall (m :: * -> *). Settings m -> Bool
autoAddHistory Settings m
settings Bool -> Bool -> Bool
&& Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isSpace FilePath
line)
-> let adder :: FilePath -> History -> History
adder = case HistoryDuplicates
histDupes of
HistoryDuplicates
AlwaysAdd -> FilePath -> History -> History
addHistory
HistoryDuplicates
IgnoreConsecutive -> FilePath -> History -> History
addHistoryUnlessConsecutiveDupe
HistoryDuplicates
IgnoreAll -> FilePath -> History -> History
addHistoryRemovingAllDupes
in forall (m :: * -> *).
MonadIO m =>
(History -> History) -> InputT m ()
modifyHistory (FilePath -> History -> History
adder FilePath
line)
Maybe FilePath
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
getInputChar :: (MonadIO m, MonadMask m) => String
-> InputT m (Maybe Char)
getInputChar :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
FilePath -> InputT m (Maybe Char)
getInputChar = forall (m :: * -> *) a.
MonadIO m =>
(TermOps -> Prefix -> InputT m a)
-> (FileOps -> IO a) -> FilePath -> InputT m a
promptedInput forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
TermOps -> Prefix -> InputT m (Maybe Char)
getInputCmdChar forall a b. (a -> b) -> a -> b
$ \FileOps
fops -> do
Maybe Char
c <- FileOps -> IO (Maybe Char)
getPrintableChar FileOps
fops
FileOps -> IO ()
maybeReadNewline FileOps
fops
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Char
c
getPrintableChar :: FileOps -> IO (Maybe Char)
getPrintableChar :: FileOps -> IO (Maybe Char)
getPrintableChar FileOps
fops = do
Maybe Char
c <- forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT forall a b. (a -> b) -> a -> b
$ FileOps -> MaybeT IO Char
getLocaleChar FileOps
fops
case forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Char -> Bool
isPrint Maybe Char
c of
Just Bool
False -> FileOps -> IO (Maybe Char)
getPrintableChar FileOps
fops
Maybe Bool
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Char
c
getInputCmdChar :: (MonadIO m, MonadMask m) => TermOps -> Prefix -> InputT m (Maybe Char)
getInputCmdChar :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
TermOps -> Prefix -> InputT m (Maybe Char)
getInputCmdChar TermOps
tops Prefix
prefix = forall (m :: * -> *) a.
MonadIO m =>
TermOps -> InputCmdT m a -> InputT m a
runInputCmdT TermOps
tops
forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s a.
(CommandMonad m, MonadState Layout m, LineState s) =>
TermOps -> Prefix -> KeyCommand m s a -> s -> m a
runCommandLoop TermOps
tops Prefix
prefix forall (m :: * -> *).
Monad m =>
KeyCommand m InsertMode (Maybe Char)
acceptOneChar InsertMode
emptyIM
acceptOneChar :: Monad m => KeyCommand m InsertMode (Maybe Char)
acceptOneChar :: forall (m :: * -> *).
Monad m =>
KeyCommand m InsertMode (Maybe Char)
acceptOneChar = forall a. [KeyMap a] -> KeyMap a
choiceCmd [forall (m :: * -> *) s t.
(Char -> Command m s t) -> KeyCommand m s t
useChar forall a b. (a -> b) -> a -> b
$ \Char
c InsertMode
s -> forall t (m :: * -> *) s.
(LineState t, Monad m) =>
(s -> t) -> Command m s t
change (Char -> InsertMode -> InsertMode
insertChar Char
c) InsertMode
s
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. a -> Maybe a
Just Char
c)
, Char -> Key
ctrlChar Char
'l' forall a. Key -> a -> KeyMap a
+> forall (m :: * -> *) s. Command m s s
clearScreenCmd forall (m :: * -> *) s t u.
Monad m =>
Command m s t -> Command m t u -> Command m s u
>|>
forall (m :: * -> *) s t. KeyCommand m s t -> Command m s t
keyCommand forall (m :: * -> *).
Monad m =>
KeyCommand m InsertMode (Maybe Char)
acceptOneChar
, Char -> Key
ctrlChar Char
'd' forall a. Key -> a -> KeyMap a
+> forall (m :: * -> *) s a. Monad m => Command m s (Maybe a)
failCmd]
waitForAnyKey :: (MonadIO m, MonadMask m)
=> String
-> InputT m Bool
waitForAnyKey :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
FilePath -> InputT m Bool
waitForAnyKey = forall (m :: * -> *) a.
MonadIO m =>
(TermOps -> Prefix -> InputT m a)
-> (FileOps -> IO a) -> FilePath -> InputT m a
promptedInput forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
TermOps -> Prefix -> InputT m Bool
getAnyKeyCmd
forall a b. (a -> b) -> a -> b
$ \FileOps
fops -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Maybe a -> Bool
isJust forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT forall a b. (a -> b) -> a -> b
$ FileOps -> MaybeT IO Char
getLocaleChar FileOps
fops
getAnyKeyCmd :: (MonadIO m, MonadMask m) => TermOps -> Prefix -> InputT m Bool
getAnyKeyCmd :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
TermOps -> Prefix -> InputT m Bool
getAnyKeyCmd TermOps
tops Prefix
prefix = forall (m :: * -> *) a.
MonadIO m =>
TermOps -> InputCmdT m a -> InputT m a
runInputCmdT TermOps
tops
forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s a.
(CommandMonad m, MonadState Layout m, LineState s) =>
TermOps -> Prefix -> KeyCommand m s a -> s -> m a
runCommandLoop TermOps
tops Prefix
prefix forall {b}.
KeyMap
(b
-> CmdM
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Bool)
acceptAnyChar InsertMode
emptyIM
where
acceptAnyChar :: KeyMap
(b
-> CmdM
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Bool)
acceptAnyChar = forall a. [KeyMap a] -> KeyMap a
choiceCmd
[ Char -> Key
ctrlChar Char
'd' forall a. Key -> a -> KeyMap a
+> forall a b. a -> b -> a
const (forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False)
, forall a. (Key -> Maybe (KeyConsumed a)) -> KeyMap a
KeyMap forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a. a -> KeyConsumed a
Consumed forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True)
]
getPassword :: (MonadIO m, MonadMask m) => Maybe Char
-> String -> InputT m (Maybe String)
getPassword :: forall (m :: * -> *).
(MonadIO m, MonadMask m) =>
Maybe Char -> FilePath -> InputT m (Maybe FilePath)
getPassword Maybe Char
x = forall (m :: * -> *) a.
MonadIO m =>
(TermOps -> Prefix -> InputT m a)
-> (FileOps -> IO a) -> FilePath -> InputT m a
promptedInput
(\TermOps
tops Prefix
prefix -> forall (m :: * -> *) a.
MonadIO m =>
TermOps -> InputCmdT m a -> InputT m a
runInputCmdT TermOps
tops
forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s a.
(CommandMonad m, MonadState Layout m, LineState s) =>
TermOps -> Prefix -> KeyCommand m s a -> s -> m a
runCommandLoop TermOps
tops Prefix
prefix KeyMap
(Command
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Password
(Maybe FilePath))
loop
forall a b. (a -> b) -> a -> b
$ FilePath -> Maybe Char -> Password
Password [] Maybe Char
x)
(\FileOps
fops -> FileOps
-> forall (m :: * -> *) a. (MonadIO m, MonadMask m) => m a -> m a
withoutInputEcho FileOps
fops forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT forall a b. (a -> b) -> a -> b
$ FileOps -> MaybeT IO FilePath
getLocaleLine FileOps
fops)
where
loop :: KeyMap
(Command
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Password
(Maybe FilePath))
loop = forall a. [KeyMap a] -> KeyMap a
choiceCmd [ Char -> Key
simpleChar Char
'\n' forall a. Key -> a -> KeyMap a
+> forall (m :: * -> *) s.
(Monad m, Result s) =>
Command m s (Maybe FilePath)
finish
, BaseKey -> Key
simpleKey BaseKey
Backspace forall a. Key -> a -> KeyMap a
+> forall t (m :: * -> *) s.
(LineState t, Monad m) =>
(s -> t) -> Command m s t
change Password -> Password
deletePasswordChar
forall (m :: * -> *) s t u.
Monad m =>
Command m s t -> Command m t u -> Command m s u
>|> Command
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Password
(Maybe FilePath)
loop'
, forall (m :: * -> *) s t.
(Char -> Command m s t) -> KeyCommand m s t
useChar forall a b. (a -> b) -> a -> b
$ \Char
c -> forall t (m :: * -> *) s.
(LineState t, Monad m) =>
(s -> t) -> Command m s t
change (Char -> Password -> Password
addPasswordChar Char
c) forall (m :: * -> *) s t u.
Monad m =>
Command m s t -> Command m t u -> Command m s u
>|> Command
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Password
(Maybe FilePath)
loop'
, Char -> Key
ctrlChar Char
'd' forall a. Key -> a -> KeyMap a
+> \Password
p -> if forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Password -> FilePath
passwordState Password
p)
then forall (m :: * -> *) s a. Monad m => Command m s (Maybe a)
failCmd Password
p
else forall (m :: * -> *) s.
(Monad m, Result s) =>
Command m s (Maybe FilePath)
finish Password
p
, Char -> Key
ctrlChar Char
'l' forall a. Key -> a -> KeyMap a
+> forall (m :: * -> *) s. Command m s s
clearScreenCmd forall (m :: * -> *) s t u.
Monad m =>
Command m s t -> Command m t u -> Command m s u
>|> Command
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Password
(Maybe FilePath)
loop'
]
loop' :: Command
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Password
(Maybe FilePath)
loop' = forall (m :: * -> *) s t. KeyCommand m s t -> Command m s t
keyCommand KeyMap
(Command
(StateT
Layout
(UndoT
(StateT
HistLog
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))))
Password
(Maybe FilePath))
loop
promptedInput :: MonadIO m => (TermOps -> Prefix -> InputT m a)
-> (FileOps -> IO a)
-> String -> InputT m a
promptedInput :: forall (m :: * -> *) a.
MonadIO m =>
(TermOps -> Prefix -> InputT m a)
-> (FileOps -> IO a) -> FilePath -> InputT m a
promptedInput TermOps -> Prefix -> InputT m a
doTerm FileOps -> IO a
doFile FilePath
prompt = do
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Handle -> IO ()
hFlush Handle
stdout
RunTerm
rterm <- forall (m :: * -> *) a.
ReaderT
RunTerm
(ReaderT
(IORef History)
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))
a
-> InputT m a
InputT forall r (m :: * -> *). MonadReader r m => m r
ask
case RunTerm -> Either TermOps FileOps
termOps RunTerm
rterm of
Right FileOps
fops -> forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
RunTerm -> FilePath -> IO ()
putStrOut RunTerm
rterm FilePath
prompt
FileOps -> forall a. IO a -> IO a
wrapFileInput FileOps
fops forall a b. (a -> b) -> a -> b
$ FileOps -> IO a
doFile FileOps
fops
Left TermOps
tops -> do
let prompt' :: Prefix
prompt' = FilePath -> Prefix
stringToGraphemes FilePath
prompt
let (Prefix
lastLine,Prefix
rest) = forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` FilePath -> Prefix
stringToGraphemes FilePath
"\r\n")
forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a]
reverse Prefix
prompt'
forall (m :: * -> *). MonadIO m => FilePath -> InputT m ()
outputStr forall a b. (a -> b) -> a -> b
$ Prefix -> FilePath
graphemesToString forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a]
reverse Prefix
rest
TermOps -> Prefix -> InputT m a
doTerm TermOps
tops forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a]
reverse Prefix
lastLine
withInterrupt :: (MonadIO m, MonadMask m) => InputT m a -> InputT m a
withInterrupt :: forall (m :: * -> *) a.
(MonadIO m, MonadMask m) =>
InputT m a -> InputT m a
withInterrupt InputT m a
act = do
RunTerm
rterm <- forall (m :: * -> *) a.
ReaderT
RunTerm
(ReaderT
(IORef History)
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))
a
-> InputT m a
InputT forall r (m :: * -> *). MonadReader r m => m r
ask
RunTerm
-> forall a (m :: * -> *). (MonadIO m, MonadMask m) => m a -> m a
wrapInterrupt RunTerm
rterm InputT m a
act
handleInterrupt :: MonadMask m => m a -> m a -> m a
handleInterrupt :: forall (m :: * -> *) a. MonadMask m => m a -> m a -> m a
handleInterrupt m a
f = forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
(e -> m a) -> m a -> m a
handle forall a b. (a -> b) -> a -> b
$ \Interrupt
Interrupt -> m a
f
getExternalPrint :: MonadIO m => InputT m (String -> IO ())
getExternalPrint :: forall (m :: * -> *). MonadIO m => InputT m (FilePath -> IO ())
getExternalPrint = do
RunTerm
rterm <- forall (m :: * -> *) a.
ReaderT
RunTerm
(ReaderT
(IORef History)
(ReaderT
(IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))
a
-> InputT m a
InputT forall r (m :: * -> *). MonadReader r m => m r
ask
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case RunTerm -> Either TermOps FileOps
termOps RunTerm
rterm of
Right FileOps
_ -> RunTerm -> FilePath -> IO ()
putStrOut RunTerm
rterm
Left TermOps
tops -> TermOps -> FilePath -> IO ()
externalPrint TermOps
tops