-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#31] Refactor and simplify CLI #32
Conversation
Resolves #31
Yeah, I've seen the same effect, when scrolling upwards an output larger than viewpoint. AFAIU this is a fundamental limitation of the primary screen buffer, unless you switch to an alternate screen buffer as full-screen terminal applications do ( |
@Bodigrim Do you know if there's an easy way to use an alternative screen buffer (like writing a single line of code)? I find the current behavior undesirable so I'm thinking about possible solutions, e.g. printing only the first "terminal window height" lines during the interactive mode. |
Okay, here is a simple program that starts an alternate terminal screen (inspired by this) and and returns back after it. I can try to use it in
#!/usr/bin/env cabal
{- cabal:
build-depends:
, base ^>= 4.16
-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Concurrent
import Data.Foldable
main :: IO ()
main = do
putStrLn "\ESC[?1049h\ESC[H"
for_ [1 .. 5] $ \(i :: Int) -> do
putStrLn $ "Going back in: " <> show i
threadDelay 1_000_000
putStrLn "\ESC[?1049l" |
Anyway, here's a relevant issue in |
By default, It handles exceptions and SIGINT correctly if interrupted during interactive output so it would switch back again correctly. Nothing is printed in the terminal on Ctrl+C but this could be one of the future improvements 🙂 There's so much I can do in a limited time... But at least I'm satisfied enough with the current behaviour, although, it took a while to achieve the result 😮💨 |
Looks great! |
Resolves #31
I implemented the changes described in #31 🎉
It was a massive refactoring because I realised that changing CLI simply to make the interactive behaviour the default one is not that simple. As a result, the entire
DrCabal.Interactive
module was removed and I incorporated its changes toDrCabal.Watch
(sorry @Bodigrim).Now:
Now, to run the profiling, you only need to do the following command:
I haven't updated the documentation yet and I will do it as a part of #30.
The only problem so far is when the profiling output is longer than the screen height, I can't scroll back and the output seems to be mangled in a horrible way:
@Bodigrim Did you observe the same behaviour when you implemented the
interactive
command? Maybe I changed something wrongly during this refactoring 🤔