ronisbr / TerminalPager.jl

Pure Julia implementation of the command less
MIT License
116 stars 8 forks source link

Use the "alternate screen" to keep the REPL clean #29

Closed digital-carver closed 11 months ago

digital-carver commented 11 months ago

When I use the pager and exit it, whichever part of the paged text was on the screen when I pressed q remains there by itself, making the REPL output look weird and cluttered with this partial output.

It would be nice if TerminalPager used (or allowed as an option) the alternate screen like less does. Then, the pager output is in its own alternate buffer, and exiting the pager leaves us back in the original clean REPL.

This is most useful when using @help, since it's easy to re-access the help text - so the help text being there in REPL output history doesn't serve much purpose.

With pager called directly, eg. function_call() |> pager, it makes more sense to leave it in the output (i.e. not use the alternate screen), since the user might not want to run function_call() again and again.

So a good default for this would be to have it as a default-off option to pager, pager(...; use_alt_screen = false), and then turn it on by default in @help (pager(@doc($f); use_alt_screen = true)).

ronisbr commented 11 months ago

Hi @digital-carver !

Thanks for the awesome suggestion! I have added the support in main. Now, if you use @help or the REPL mode pager?>, we will use the alternate screen buffer by default. Can you please test?