yellowman / nsh

OpenBSD networking configuration shell
http://www.nmedia.net/nsh/
Other
174 stars 27 forks source link

make the pager aware of lines overflowing the width of the terminal #131

Closed stspdotname closed 1 year ago

stspdotname commented 1 year ago

Lines longer than the terminal width were causing the pager to scroll too far, hiding lines at the beginning of the output. This cosmetic problem can be reproduced easily by running in a narrow xterm and running a command which uses the pager, like 'show diff-config' or 'show interface' (with my patch that adds pager support to this command).

Fix this issue by displaying the pager prompt if the next line to be displayed would cause the terminal to scroll due to display-width. The old logic was merely counting the number of lines, assuming none of the lines displayed would occupy more than the available number of columns.

The display-width can only determined precisely by using a wide-character representation of the line, so we now do the necessary conversion and also heed the user's locale settings. Most strings we display will be ASCII but there is nothing which would stop users from using Unicode in some free-form fields, such as an interface's description string.

smytht commented 1 year ago

I like this and I have seen the issue it intends to resolve would prefer if Chris also reviewed as he was discussing Paginaton to begin with...