dalance / procs

A modern replacement for ps written in Rust
MIT License
5.1k stars 114 forks source link

Line wrapping #695

Closed v1rtualr3ality closed 1 week ago

v1rtualr3ality commented 2 weeks ago

Specifically when -w/--watch is specified, and the terminal is narrowed to the point where the header takes up more than one line, and there are more visible processes than are lines available on the screen, only the bottommost header line is displayed (at least on the terminal emulator "Terminal" on Debian). This is because the number of visible processes scrolls the view window and cuts off upper lines (I discovered this by using tmux's scrollback buffer to investigate what was above the confines of the regular screen). Such behavior can be seen with the output of procs -w on a 24x80 terminal: image This off-by-one error also causes the scrollback to get polluted with duplicate header lines, although this is simply annoying rather than detrimental (again running procs -w, just scrolling up a few lines): image This PR changes Watcher::display_header to return Result<usize, Error> where the Ok variant has the number of lines the header takes up, so that the the (new) header_lines parameter of View::filter can be populated. It also changes View::filter to break a bit earlier according to how many lines were taken up by the header, so as to prevent the two behaviors identified above.

dalance commented 1 week ago

Thank you for your contribution! I'll merge this PR.