From edc1ea4c16505f86eebd297f722993127df31f17 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Wed, 7 Apr 2004 01:07:50 +0000
Subject: [PATCH] wrong place; signal_init() should be called after the input
 mode (cbreak or raw) is set in order to work properly; also clarify related
 comments

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1710 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 src/nano.c  | 13 ++++++++-----
 src/winio.c | 13 +++++++------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index ad6322ed..981912c6 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2939,15 +2939,18 @@ void handle_sigwinch(int s)
     /* Turn cursor back on for sure. */
     curs_set(1);
 
+    /* Put the terminal in cbreak mode (read one character at a time and
+     * interpret the special control keys) if we can selectively disable
+     * the special control keys. */
+#ifdef _POSIX_VDISABLE
+    cbreak();
+#endif
+
     /* Set up the signal handlers again, so that the special control
      * keys all work the same as before. */
     signal_init();
 
-    /* Switch to cbreak mode and turn the keypad on, so that the keypad
-     * and input still work if we resized during verbatim input. */
-#ifdef _POSIX_VDISABLE
-    cbreak();
-#endif
+    /* Turn the keypad on in the windows we'll be reading input from. */
     keypad(edit, TRUE);
     keypad(bottomwin, TRUE);
 
diff --git a/src/winio.c b/src/winio.c
index 45204300..e92a4268 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -74,10 +74,11 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
     allow_pending_sigwinch(TRUE);
 #endif
 
-    /* Switch to raw mode so that we can type ^C, ^Q, ^S, ^Z, and ^\
-     * (and ^Y on systems supporting delayed suspend) without getting
-     * interrupts, and turn the keypad off so that we don't get extended
-     * keypad values, all of which are outside the ASCII range. */
+    /* Switch to raw mode if necessary so that we can type ^C, ^Q, ^S,
+     * ^Z, and ^\ (and ^Y on systems supporting delayed suspend) without
+     * getting interrupts, and turn the keypad off so that we don't get
+     * extended keypad values, all of which are outside the ASCII
+     * range. */
 #ifdef _POSIX_VDISABLE
     raw();
 #endif
@@ -103,8 +104,8 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
 	nodelay(win, FALSE);
     }
 
-    /* Switch back to cbreak mode and turn the keypad back on now that
-     * we're done. */
+    /* Switch back to cbreak mode if necessary and turn the keypad back
+     * on now that we're done. */
 #ifdef _POSIX_VDISABLE
     cbreak();
 #endif
-- 
GitLab