diff options
| -rw-r--r-- | Omni/Log/Concurrent.hs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Omni/Log/Concurrent.hs b/Omni/Log/Concurrent.hs index 4654365..86a3853 100644 --- a/Omni/Log/Concurrent.hs +++ b/Omni/Log/Concurrent.hs @@ -88,15 +88,12 @@ initializeLines :: LineManager -> IO () initializeLines LineManager {..} = when lmSupportsANSI <| do nsMap <- readIORef namespaceLines - forM_ (Map.toList nsMap) <| \(ns, lineNum) -> do - ANSI.hSaveCursor IO.stderr + forM_ (Map.toList nsMap) <| \(ns, _) -> do ANSI.hSetCursorColumn IO.stderr 0 - when (lineNum > 0) <| ANSI.hCursorDown IO.stderr lineNum ANSI.hClearLine IO.stderr let nsText = Text.pack (Namespace.toPath ns) - IO.hPutStr IO.stderr (Text.unpack <| "[…] " <> nsText) + IO.hPutStrLn IO.stderr (Text.unpack <| "[…] " <> nsText) IO.hFlush IO.stderr - ANSI.hRestoreCursor IO.stderr updateLine :: Namespace -> Text -> IO () updateLine ns output = do @@ -115,15 +112,17 @@ updateLine ns output = do case Map.lookup ns nsMap of Nothing -> pure () Just lineNum -> do - ANSI.hSaveCursor IO.stderr + let numLines = length lmNamespaces + -- Move to the target line from bottom + ANSI.hCursorUp IO.stderr (numLines - lineNum) ANSI.hSetCursorColumn IO.stderr 0 - ANSI.hCursorUp IO.stderr (length lmNamespaces - lineNum) ANSI.hClearLine IO.stderr let nsText = Text.pack (Namespace.toPath ns) let formattedOutput = if Text.null output then "[~] " <> nsText else "[~] " <> nsText <> ": " <> output IO.hPutStr IO.stderr (Text.unpack formattedOutput) IO.hFlush IO.stderr - ANSI.hRestoreCursor IO.stderr + -- Move back to bottom + ANSI.hCursorDown IO.stderr (numLines - lineNum) updateLineState :: Namespace -> BuildState -> IO () updateLineState ns buildState = do @@ -136,9 +135,10 @@ updateLineState ns buildState = do case Map.lookup ns nsMap of Nothing -> pure () Just lineNum -> do - ANSI.hSaveCursor IO.stderr + let numLines = length lmNamespaces + -- Move to the target line from bottom + ANSI.hCursorUp IO.stderr (numLines - lineNum) ANSI.hSetCursorColumn IO.stderr 0 - ANSI.hCursorUp IO.stderr (length lmNamespaces - lineNum) ANSI.hClearLine IO.stderr let nsText = Text.pack (Namespace.toPath ns) case buildState of @@ -151,4 +151,5 @@ updateLineState ns buildState = do Building -> IO.hPutStr IO.stderr (Text.unpack <| "[~] " <> nsText) IO.hFlush IO.stderr - ANSI.hRestoreCursor IO.stderr + -- Move back to bottom + ANSI.hCursorDown IO.stderr (numLines - lineNum) |
