diff --git a/src/help.c b/src/help.c index b228f21..78e56c0 100644 --- a/src/help.c +++ b/src/help.c @@ -68,6 +68,7 @@ void display_the_help_text(bool redisplaying) } fclose(fp); +#ifndef DISABLE_MULTIBUFFER if (redisplaying) close_buffer(); @@ -77,6 +78,9 @@ void display_the_help_text(bool redisplaying) UNSET(MULTIBUFFER); } else open_buffer(tempfilename, FALSE); +#else + replace_buffer(tempfilename); +#endif display_buffer(); } @@ -100,6 +104,23 @@ void do_help(void) /* In case user chooses help at prompt, save the string entered, * if any, by the user at the prompt. */ +#ifdef DISABLE_MULTIBUFFER + /* Save current file's content in a safe temporary file, its syntax + * coloring scheme, i.e. colortype struct, (also disable it for now) and + * reuse the current buffer. */ + FILE *fuser; + char *userfile = safe_tempfile(&fuser); + if (userfile == NULL) { + statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); + return; + } + write_file(userfile, fuser, TRUE, OVERWRITE, TRUE); + fclose(fuser); + + colortype *color = openfile->colorstrings; + openfile->colorstrings = NULL; +#endif + blank_statusbar(); /* Get a safe temporary file for displaying the help text. If we can't @@ -204,7 +225,9 @@ void do_help(void) currmenu = MHELP; } else if (func == do_exit) { /* Exit from the help viewer. */ +#ifndef DISABLE_MULTIBUFFER close_buffer(); +#endif break; } else if ((kbinput >= '0' && kbinput <= '9') || (kbinput >= 'a' && kbinput <= 'z') || @@ -216,8 +239,17 @@ void do_help(void) } - /* We're exiting from the help screen. So, restore the flags and the - * original menu, refresh the entire screen and deallocate the memory. */ + /* We're exiting from the help screen. So, restore the flags, the + * original menu, and even original buffer content if multibuffer is + * disabled, refresh the entire screen and deallocate the memory. */ + +#ifdef DISABLE_MULTIBUFFER + userfile == NULL ? open_buffer("", TRUE) : replace_buffer(userfile); + openfile->colorstrings = color; + + remove(userfile); + free(userfile); +#endif #ifdef ENABLE_LINENUMBERS if (saved_margin != 0) {