diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-01-15 19:53:40 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-01-16 21:13:22 +0100 |
commit | 29b263f350ea7dccb243ec28f6af7fc5c41f578e (patch) | |
tree | b2b989436762bbf321693d92862ecfb0fddef656 /src/GDB.hs | |
parent | 6deeb46561c122f22bb289522520bc458636a796 (diff) |
Haskeline for input handling
Diffstat (limited to 'src/GDB.hs')
-rw-r--r-- | src/GDB.hs | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -17,13 +17,11 @@ import Data.Char import Data.List import Data.Text (Text) import Data.Text qualified as T -import Data.Text.IO qualified as T import Data.Void import Text.Megaparsec hiding (State) import Text.Megaparsec.Char -import System.IO.Error import System.Process import Output @@ -175,12 +173,9 @@ gdbCommand gdb cmd = do (Exit, _) -> outProc OutputError (gdbProcess gdb) "result exit" gdbSession :: MonadOutput m => GDB -> m () -gdbSession gdb = do - outPrompt "gdb> " - loop "" - outClearPrompt +gdbSession gdb = loop "" where - loop prev = liftIO (catchIOError (Just <$> T.getLine) (\e -> if isEOFError e then return Nothing else ioError e)) >>= \case + loop prev = outPromptGetLine "gdb> " >>= \case Just line -> do let cmd = if T.null line then prev else line gdbCommand gdb ("-interpreter-exec console \"" <> cmd <> "\"") |