From 85c775a3a3b5a11c4e44f423163d912ba56460b3 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 9 Jun 2006 16:04:19 +0000
Subject: [PATCH] make suspension clear the screen and put the cursor on the
 last line before displaying anything, as Pico does

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3648 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog  |  6 +++---
 src/nano.c | 19 +++++++++++++------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bc9bfd92..25a6aa6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -148,6 +148,9 @@ CVS code -
 	  do_suspend(), do_input(), rcfile_error(), parse_argument(),
 	  parse_rcfile(), nano.1, nano.texi, and nanorc.sample.in.
 	  (Benno Schulenberg, minor tweaks by DLR and Nick Warne)
+	- Make suspension clear the screen and put the cursor on the
+	  last line before displaying anything, as Pico does.  Changes
+	  to do_suspend() and do_continue(). (DLR)
 - browser.c:
   do_browser()
 	- Reference NANO_GOTODIR_(ALT|F)?KEY instead of
@@ -265,9 +268,6 @@ CVS code -
 	  (DLR, found by Benno Schulenberg)
   renumber()
 	- Remove invalid assert. (DLR, found by Filipe Moreira)
-  do_suspend()
-	- Add an extra newline before "Use \"fg\" to return to nano".
-	  (DLR)
   do_input()
 	- Remove redundant check for allow_funcs' being TRUE when we get
 	  KEY_MOUSE. (DLR)
diff --git a/src/nano.c b/src/nano.c
index 6fcf0d25..21a2f70c 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -993,10 +993,13 @@ RETSIGTYPE handle_hupterm(int signal)
 /* Handler for SIGTSTP (suspend). */
 RETSIGTYPE do_suspend(int signal)
 {
-    /* Temporarily leave curses mode. */
-    endwin();
+    /* Blank the screen, and move the cursor to the last line of it. */
+    erase();
+    move(LINES - 1, 0);
+    refresh();
 
-    printf("\n\n\n\n\n\n%s\n", _("Use \"fg\" to return to nano."));
+    /* Display our helpful message. */
+    printf(_("Use \"fg\" to return to nano.\n"));
     fflush(stdout);
 
     /* Restore the old terminal settings. */
@@ -1017,11 +1020,15 @@ RETSIGTYPE do_continue(int signal)
 {
 #ifndef NANO_TINY
     /* Perhaps the user resized the window while we slept.  Handle it,
-     * and update the screen in the process. */
+     * and restore the terminal to its previous state and update the
+     * screen in the process. */
     handle_sigwinch(0);
 #else
-    /* Reenter curses mode, and update the screen in the process. */
-    doupdate();
+    /* Restore the terminal to its previous state. */
+    terminal_init();
+
+    /* Update the screen. */
+    total_refresh();
 #endif
 }
 
-- 
GitLab