From 29b263f350ea7dccb243ec28f6af7fc5c41f578e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 15 Jan 2023 19:53:40 +0100 Subject: Haskeline for input handling --- src/GDB.hs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/GDB.hs') diff --git a/src/GDB.hs b/src/GDB.hs index f360637..3c60457 100644 --- a/src/GDB.hs +++ b/src/GDB.hs @@ -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 <> "\"") -- cgit v1.2.3