Add quit_if_one_screen option for dynamic_paging mode#157
Add quit_if_one_screen option for dynamic_paging mode#157keith-hall wants to merge 3 commits intoAMythicDev:mainfrom
Conversation
Co-authored-by: keith-hall <11882719+keith-hall@users.noreply.github.com> Agent-Logs-Url: https://github.com/forkeith/minus/sessions/4a0e60ce-db58-455e-b6b1-815f7f4b411b
Co-authored-by: keith-hall <11882719+keith-hall@users.noreply.github.com> Agent-Logs-Url: https://github.com/forkeith/minus/sessions/8db94332-4c4f-4f84-9bda-7746f8a59750
Co-authored-by: keith-hall <11882719+keith-hall@users.noreply.github.com> Agent-Logs-Url: https://github.com/forkeith/minus/sessions/82e3065c-4b6e-4bcc-bce1-d43c6658b9da
|
@keith-hall Thanks for the contribution! I'm still reviewing the code, but small question for you - why create a new setting instead of reusing |
|
Hi, thanks for taking a look, and good question. Mainly I just wasn't sure whether it would be desirable to re-use the same setting/command when it feels like a different situation - with Edit: I forgot to mention, I would be happy to unify and re-use the |
|
I suspect it is the |
Adds a
less -F-style auto-quit fordynamic_paging: when content fits on one screen and the end of output is signalled, the pager exits automatically and preserves the content on the terminal. Unlikeset_run_no_overflow(static mode only), this supports buffering use cases where the total line count is unknown upfront.New API
Pager::set_quit_if_one_screen(bool)— enables the feature. Whentrue, auto-quits with content preserved if it fits on screen once end-of-output is signalled. Otherwise the pager stays open for user scrolling/quitting.Pager::end_of_output()— explicitly signals end-of-output without dropping thePagerhandle. Preferred when the caller needs to keep the handle alive (e.g.bat's use case).Pagerclones also fires the signal automatically via anAliveGuardRAII type.Internals
AliveGuardholds a channel sender and firesCommand::CheckQuitIfOneScreenon drop;dynamic_pagingreceives its own independentArc<AliveGuard>so only the caller's clones count toward the signal.PagerState::quit_if_one_screen: booltracks the setting; theCheckQuitIfOneScreenhandler restores the terminal, writes formatted lines to the main screen, then respects the configuredExitStrategy.Usage