summaryrefslogtreecommitdiff
path: root/src/Output.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-10-27 21:56:22 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-10-27 21:56:22 +0200
commit86351a85ec5c92a390e7bfc70648a67be84619c0 (patch)
tree856b21d62b372ed5e6e64cf105d6f34c860a1965 /src/Output.hs
parent3e70d73d4499689840596598ea943296a34b53ab (diff)
Show GDB console output always and without prompt
Diffstat (limited to 'src/Output.hs')
-rw-r--r--src/Output.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Output.hs b/src/Output.hs
index ca7f862..661e4fc 100644
--- a/src/Output.hs
+++ b/src/Output.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE OverloadedStrings #-}
+
module Output (
Output, OutputType(..),
MonadOutput(..),
@@ -38,6 +40,7 @@ data OutputType = OutputChildStdout
| OutputMatch
| OutputMatchFail
| OutputError
+ | OutputAlways
class MonadIO m => MonadOutput m where
getOutput :: m Output
@@ -58,6 +61,7 @@ outColor OutputChildFail = T.pack "31"
outColor OutputMatch = T.pack "32"
outColor OutputMatchFail = T.pack "31"
outColor OutputError = T.pack "31"
+outColor OutputAlways = "0"
outSign :: OutputType -> Text
outSign OutputChildStdout = T.empty
@@ -67,6 +71,7 @@ outSign OutputChildFail = T.pack "!!"
outSign OutputMatch = T.pack "+"
outSign OutputMatchFail = T.pack "/"
outSign OutputError = T.pack "!!"
+outSign OutputAlways = T.empty
printWhenQuiet :: OutputType -> Bool
printWhenQuiet = \case
@@ -77,6 +82,7 @@ printWhenQuiet = \case
OutputMatch -> False
OutputMatchFail -> True
OutputError -> True
+ OutputAlways -> True
clearPrompt :: OutputState -> IO ()
clearPrompt OutputState { outCurPrompt = Just _ } = T.putStr $ T.pack "\ESC[2K\r"
@@ -89,16 +95,14 @@ showPrompt _ = return ()
ioWithOutput :: MonadOutput m => (Output -> IO a) -> m a
ioWithOutput act = liftIO . act =<< getOutput
-outLine :: MonadOutput m => OutputType -> Text -> Text -> m ()
+outLine :: MonadOutput m => OutputType -> Maybe Text -> Text -> m ()
outLine otype prompt line = ioWithOutput $ \out ->
when (outVerbose (outConfig out) || printWhenQuiet otype) $ do
withMVar (outState out) $ \st -> do
clearPrompt st
TL.putStrLn $ TL.fromChunks
[ T.pack "\ESC[", outColor otype, T.pack "m"
- , prompt
- , outSign otype
- , T.pack "> "
+ , maybe "" (<> outSign otype <> "> ") prompt
, line
, T.pack "\ESC[0m"
]