Skip to content
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

Line wrapping #695

Merged
merged 2 commits into from
Oct 21, 2024
Merged

Line wrapping #695

merged 2 commits into from
Oct 21, 2024

Conversation

v1rtualr3ality
Copy link

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
Copy link
Owner

dalance commented Oct 21, 2024

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

@dalance dalance merged commit 7df5bbc into dalance:master Oct 21, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants