From: Sami Kerola Date: Wed, 18 Mar 2020 20:13:02 +0000 (+0000) Subject: more: move runtime usage output to a function X-Git-Tag: v2.36-rc1~158^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b6818219fb53bb0a338510e850dd9f928088bb76;p=thirdparty%2Futil-linux.git more: move runtime usage output to a function This change also removes a ghost prompt that was left in place when printing help. When looking old commits the output fluke has been around at least since util-linux v2.2. Signed-off-by: Sami Kerola --- diff --git a/text-utils/more.c b/text-utils/more.c index f426b66269..823aa8d946 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -1402,6 +1402,37 @@ static char *find_editor(void) return editor; } +static void runtime_usage(void) +{ + fputs(_("Most commands optionally preceded by integer argument k. " + "Defaults in brackets.\n" + "Star (*) indicates argument becomes new default.\n"), stdout); + puts("-------------------------------------------------------------------------------"); + fprintf(stdout, + _ + (" Display next k lines of text [current screen size]\n" + "z Display next k lines of text [current screen size]*\n" + " Display next k lines of text [1]*\n" + "d or ctrl-D Scroll k lines [current scroll size, initially 11]*\n" + "q or Q or Exit from more\n" + "s Skip forward k lines of text [1]\n" + "f Skip forward k screenfuls of text [1]\n" + "b or ctrl-B Skip backwards k screenfuls of text [1]\n" + "' Go to place where previous search started\n" + "= Display current line number\n" + "/ Search for kth occurrence of regular expression [1]\n" + "n Search for kth occurrence of last r.e [1]\n" + "! or :! Execute in a subshell\n" + "v Start up '%s' at current line\n" + "ctrl-L Redraw screen\n" + ":n Go to kth next file [1]\n" + ":p Go to kth previous file [1]\n" + ":f Display current file name and line number\n" + ". Repeat previous command\n"), + find_editor()); + puts("-------------------------------------------------------------------------------"); +} + /* Read a command and do it. A command consists of an optional integer * argument followed by the command character. Return the number of * lines to display in the next screenful. If there is nothing more to @@ -1610,34 +1641,8 @@ static int more_key_command(struct more_control *ctl, char *filename, FILE *f) case 'h': if (ctl->no_scroll) more_clear_screen(ctl); - fputs(_("\n" - "Most commands optionally preceded by integer argument k. " - "Defaults in brackets.\n" - "Star (*) indicates argument becomes new default.\n"), stdout); - puts("---------------------------------------" - "----------------------------------------"); - fprintf(stdout, - _(" Display next k lines of text [current screen size]\n" - "z Display next k lines of text [current screen size]*\n" - " Display next k lines of text [1]*\n" - "d or ctrl-D Scroll k lines [current scroll size, initially 11]*\n" - "q or Q or Exit from more\n" - "s Skip forward k lines of text [1]\n" - "f Skip forward k screenfuls of text [1]\n" - "b or ctrl-B Skip backwards k screenfuls of text [1]\n" - "' Go to place where previous search started\n" - "= Display current line number\n" - "/ Search for kth occurrence of regular expression [1]\n" - "n Search for kth occurrence of last r.e [1]\n" - "! or :! Execute in a subshell\n" - "v Start up '%s' at current line\n" - "ctrl-L Redraw screen\n" - ":n Go to kth next file [1]\n" - ":p Go to kth previous file [1]\n" - ":f Display current file name and line number\n" - ". Repeat previous command\n"), find_editor()); - puts("---------------------------------------" - "----------------------------------------"); + kill_line(ctl); + runtime_usage(); output_prompt(ctl, filename); break; case 'v': /* This case should go right before default */