[PATCH] more: ensure that on larger terminals 'h' shows only the in-app help text

Benno Schulenberg <[email protected]>
Newsgroups org.kernel.vger.util-linux
Message-ID <[email protected]>
When a terminal has more than 24 rows, the rows above the help text
(shown by typing 'h' or '?') were still those of the displayed file.
That could make it hard to notice that the two lines above the first
row of dashes belonged to the help text, not to the displayed file.

Improve upon this by scrolling off any lines above the 23-line help
text.

Signed-off-by: Benno Schulenberg <[email protected]>
---
 text-utils/more.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/text-utils/more.c b/text-utils/more.c
index a035591af..d0fd6a48f 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1805,6 +1805,8 @@ static int more_key_command(struct more_control *ctl, char *filename)
 		case more_kc_help:
 			if (ctl->no_scroll)
 				more_clear_screen(ctl);
+			else for (int i = ctl->lines_per_page; i > 23; i--)
+				putchar('\n');
 			erase_to_col(ctl, 0);
 			runtime_usage();
 			output_prompt(ctl, filename);
-- 
2.48.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.