From 63c8ab94fbc7f1d10805e671e2d073f8d05dc4ea Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Thu, 4 Jan 2001 02:33:52 +0000
Subject: [PATCH] Tadaa.  Keypad issue fixed. It was the stupid timeout(0)
 call.  UGH

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@437 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 BUGS      |  3 +++
 ChangeLog |  4 ++++
 files.c   |  1 -
 nano.c    | 28 ++++++----------------------
 proto.h   |  1 -
 winio.c   |  5 -----
 6 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/BUGS b/BUGS
index 1adfbcde..b3351763 100644
--- a/BUGS
+++ b/BUGS
@@ -78,6 +78,9 @@
   favor of the last stored search (47) [FIXED]
 - If nano fails to open a file when it starts up,doing almost anything
   causes a segfault (discovered by Ben Roberts) (48). [FIXED]
+- In certain terminals, nano would not work properly with keypad().
+  Turned out to be the silly timeout(0) call which is completely
+  unneeded anyway.  (49) [FIXED]
 
 ** Open BUGS **
 
diff --git a/ChangeLog b/ChangeLog
index 2389c71d..894978df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@ General -
 	  filestat().  New shortcut list browser_list.  Some new
 	  strings to translate.  Chris needs to add comments to his
 	  code.
+	- We only call keypad() once now for each window, at the beginning.
+	  FINALLY!  No more keypad_on(), no more individual calls in
+	  main(), do_help(), do_browser(), etc etc etc.  Removed call to
+	  timeout(0) in main() (which caused the whole mess), fixes BUG #49.
 - faq.html:
 	- Fix typos and small mistakes (Jordi).
 - files.c:
diff --git a/files.c b/files.c
index db496e53..90872778 100644
--- a/files.c
+++ b/files.c
@@ -1205,7 +1205,6 @@ char *do_browser(char *inpath)
 
     titlebar(path);
     bottombars(browser_list, BROWSER_LIST_LEN);
-    keypad_on(TRUE);
     curs_set(0);
     wmove(edit, 0, 0);
     i = 0;
diff --git a/nano.c b/nano.c
index 53daa177..0dd17726 100644
--- a/nano.c
+++ b/nano.c
@@ -74,12 +74,6 @@ char *last_search = NULL;	/* Last string we searched for */
 char *last_replace = NULL;	/* Last replacement string */
 int search_last_line;		/* Is this the last search line? */
 
-void keypad_on(int yesno)
-{
-    keypad(edit, yesno);
-    keypad(bottomwin, yesno);
-}
-
 /* What we do when we're all set to exit */
 RETSIGTYPE finish(int sigage)
 {
@@ -89,10 +83,6 @@ RETSIGTYPE finish(int sigage)
     } else
 	mvwaddstr(bottomwin, 0, 0, hblank);
     
-    /* Apparently you REALLY can't get away with not calling keypad()
-       or your window looks awful when it exits.  so we just call it right
-       before we exit, muhaha :-) */
-    keypad_on(TRUE);
     wrefresh(bottomwin);
     endwin();
 
@@ -1649,6 +1639,10 @@ void window_init(void)
     /* And the other windows */
     topwin = newwin(2, COLS, 0, 0);
     bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
+
+    /* HAHA! Only do this once! */
+    keypad(edit, TRUE);
+    keypad(bottomwin, TRUE);
 }
 
 void mouse_init(void)
@@ -1656,15 +1650,12 @@ void mouse_init(void)
 #ifndef NANO_SMALL
 #ifdef NCURSES_MOUSE_VERSION
     if (ISSET(USE_MOUSE)) {
-	keypad_on(TRUE);
-
 	mousemask(BUTTON1_RELEASED, NULL);
 	mouseinterval(50);
 
-    } else {
+    } else
 	mousemask(0, NULL);
-	keypad_on(FALSE);
-    }
+
 #endif
 #endif
 
@@ -2215,7 +2206,6 @@ int main(int argc, char *argv[])
     nonl();
     cbreak();
     noecho();
-    timeout(0);
 
     /* Set up some global variables */
     global_init();
@@ -2233,12 +2223,6 @@ int main(int argc, char *argv[])
     window_init();
     mouse_init();
 
-#ifdef PDCURSES
-    /* Must have this for the arrow, et al, keys to even work in 
-       PDCurses+cygwin under Windows */
-    keypad_on(TRUE);
-#endif
-
 #ifdef DEBUG
     fprintf(stderr, _("Main: bottom win\n"));
 #endif
diff --git a/proto.h b/proto.h
index 84d822f0..ed630a8d 100644
--- a/proto.h
+++ b/proto.h
@@ -138,7 +138,6 @@ void search_init_globals(void);
 void replace_abort(void);
 void add_to_cutbuffer(filestruct * inptr);
 void do_replace_highlight(int highlight_flag, char *word);
-void keypad_on(int yesno);
 void nano_disabled_msg(void);
 #ifdef NANO_EXTRA
 void do_credits(void);
diff --git a/winio.c b/winio.c
index fbc840fb..2276f6e5 100644
--- a/winio.c
+++ b/winio.c
@@ -1183,11 +1183,6 @@ int do_help(void)
     int i, j, row = 0, page = 1, kbinput = 0, no_more = 0;
     int no_help_flag = 0;
 
-
-    /* Oh well, they've asked for the help menu, if the keypad is not on now
-       we're going to have to turn it on */
-    keypad_on(TRUE);
-
     blank_edit();
     curs_set(0);
     blank_statusbar();
-- 
GitLab