From 0d5c0e31b9e0cbaa0c97b4ea6e55ddbdae689660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 31 May 2026 19:54:12 +0200 Subject: Terminal: erase lines --- main/Terminal.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main/Terminal.hs b/main/Terminal.hs index b516f93..53814f9 100644 --- a/main/Terminal.hs +++ b/main/Terminal.hs @@ -15,6 +15,7 @@ module Terminal ( printLine, updateLine, updateLinePart, + eraseLinesSince, printBottomLines, clearBottomLines, @@ -422,6 +423,15 @@ updateLinePart TerminalLine {..} offset str = do , AnsiText $ "\ESC[u" ] +eraseLinesSince :: TerminalLine -> IO () +eraseLinesSince TerminalLine {..} = do + let Terminal {..} = tlTerminal + when termAnsi $ do + withMVar termLock $ \_ -> do + bindex <- atomically $ readTVar termBottomIndex + putAnsi $ AnsiText $ "\ESC[" <> T.pack (show (bindex - tlLineIndex)) <> "F\ESC[J" + atomically $ writeTVar termBottomIndex tlLineIndex + printBottomLines :: Terminal -> String -> IO () printBottomLines Terminal { termAnsi = False } _ = do -- cgit v1.2.3