diff --git a/src/help.c b/src/help.c index 9245805..baa7de7 100644 --- a/src/help.c +++ b/src/help.c @@ -44,6 +44,10 @@ char *tempfilename = NULL; /* Name of the safe temporary file that we will use for wrapping * and writing the help text. */ +bool first_time; + /* For letting current line be one at the center; needs to be done + * only for the first time. */ + /* Writes the hard wrapped help text in the temp file and displays it. */ void display_the_help_text(bool redisplaying) { @@ -51,6 +55,8 @@ void display_the_help_text(bool redisplaying) const char *ptr = beg_of_intro; /* The current line of the help text. */ FILE *fp = fopen(tempfilename, "w+b"); + size_t saved_current_lineno = openfile->current->lineno; + /* For staying at, or at least, close to the current position. */ if (fp == NULL) { statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); @@ -83,6 +89,23 @@ void display_the_help_text(bool redisplaying) open_buffer(tempfilename, FALSE); display_buffer(); + + if (redisplaying) { + if (first_time) { + /* Current line must be one at the center for proper scrolling + * of text while rewrapping. */ + saved_current_lineno += 10; + first_time = FALSE; + } + + while (openfile->current->lineno < saved_current_lineno) { + /* do_down only if we can. */ + if (openfile->current->lineno + 9 > openfile->filebot->lineno) + break; + else + do_down(TRUE); + } + } } /* Our main help-viewer function. */ @@ -106,6 +129,7 @@ void do_help(void) * if any, by the user at the prompt. */ inhelp = TRUE; + first_time = TRUE; blank_statusbar();