From 16e41689938bb2e61948a904fb32a63228ce700e Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Mon, 11 Sep 2000 22:33:54 +0000
Subject: [PATCH] A heapin spoonful of updates in key handling

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@216 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog       |   7 ++++
 global.c        |  10 +++--
 nano.c          | 109 ++++++++++++++++++++++++++++++++++++------------
 po/cat-id-tbl.c |  75 +++++++++++++++++----------------
 po/es.gmo       | Bin 17318 -> 17318 bytes
 po/nano.pot     | 100 ++++++++++++++++++++++++++++----------------
 6 files changed, 198 insertions(+), 103 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 79ff502a..1d2807e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,11 +6,18 @@ CVS code -
   do_cut_text()
 	- Don't immediately abort if we're on filebot and the marker is
 	  set (fixes bug #42).
+- global.c:
+  shortcut_init()
+	- Added in FKEYs that for some reason were left out.  *boggle*
 - nano.c:
 	- main()
 	- Added check for _POSIX_VDISABLE and use raw mode if not
 	  available, allows nano to work with cygwin.
 	- Added gettext calls to enable/disable strings (Jordi).
+	- Revamped a great deal of the F-key and keypad key handling,
+	  because we not longer use keypad() (see below).
+	- Removed keypad() call because nano was not working with the
+	  keypad in many terms, which is very bad.
 - search.c:
   findnextstr()
 	- Reset starting at current for search instead of begin.
diff --git a/global.c b/global.c
index 1d1ce3be..07f11ddb 100644
--- a/global.c
+++ b/global.c
@@ -205,7 +205,7 @@ void shortcut_init(void)
 
     if (ISSET(PICO_MSGS))
 	sc_init_one(&main_list[0], NANO_HELP_KEY, _("Get Help"),
-		    nano_help_msg, 0, 0, 0, VIEW, do_help);
+		    nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
     else
 	sc_init_one(&main_list[0], NANO_WRITEOUT_KEY, _("WriteOut"),
 		    nano_writeout_msg,
@@ -225,7 +225,8 @@ void shortcut_init(void)
 
     if (ISSET(PICO_MSGS))
 	sc_init_one(&main_list[3], NANO_JUSTIFY_KEY, _("Justify"),
-		    nano_justify_msg, 0, 0, 0, NOVIEW, do_justify);
+		    nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0, 
+		    NOVIEW, do_justify);
     else
 	sc_init_one(&main_list[3], NANO_REPLACE_KEY, _("Replace"),
 		    nano_replace_msg,
@@ -303,7 +304,8 @@ void shortcut_init(void)
 		    NANO_ALT_R, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
     else
 	sc_init_one(&main_list[23], NANO_JUSTIFY_KEY, _("Justify"),
-		    nano_justify_msg, 0, 0, 0, NOVIEW, do_justify);
+		    nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0, 
+		    NOVIEW, do_justify);
 
     sc_init_one(&main_list[24], NANO_ENTER_KEY, _("Enter"),
 		nano_enter_msg,
@@ -315,7 +317,7 @@ void shortcut_init(void)
 		    NANO_ALT_G, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
     else
 	sc_init_one(&main_list[25], NANO_HELP_KEY, _("Get Help"),
-		    nano_help_msg, 0, 0, 0, VIEW, do_help);
+		    nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
 
 
     sc_init_one(&whereis_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
diff --git a/nano.c b/nano.c
index dedbc9a5..bde606c6 100644
--- a/nano.c
+++ b/nano.c
@@ -1674,7 +1674,7 @@ int main(int argc, char *argv[])
     int kbinput;		/* Input from keyboard */
     long startline = 0;		/* Line to try and start at */
     int keyhandled = 0;		/* Have we handled the keystroke yet? */
-    int tmpkey = 0, i;
+    int i;
     char *argv0;
     struct termios term;
 
@@ -1854,14 +1854,12 @@ int main(int argc, char *argv[])
 
     /* Setup up the main text window */
     edit = newwin(editwinrows, COLS, 2, 0);
-    keypad(edit, TRUE);
 
     mouse_init();
 
     /* And the other windows */
     topwin = newwin(2, COLS, 0, 0);
     bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
-    keypad(bottomwin, TRUE);
 
 #ifdef DEBUG
     fprintf(stderr, _("Main: bottom win\n"));
@@ -1897,9 +1895,90 @@ int main(int argc, char *argv[])
 	kbinput = wgetch(edit);
 	if (kbinput == 27) {	/* Grab Alt-key stuff first */
 	    switch (kbinput = wgetch(edit)) {
+	    /* Alt-O, suddenly very important ;) */
+	    case 79:
+		kbinput = wgetch(edit);
+		if (kbinput <= 'S' && kbinput >= 'P')
+		     kbinput = KEY_F(kbinput  - 79);
+#ifdef DEBUG
+		else {
+		    	fprintf(stderr, _("I got Alt-O-%c! (%d)\n"),
+			kbinput, kbinput);
+			break;
+		}
+#endif
+		break;
 	    case 91:
 
 		switch (kbinput = wgetch(edit)) {
+		case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
+		    kbinput = wgetch(edit);
+		    if (kbinput >= '1' && kbinput <= '5') {
+			    kbinput = KEY_F(kbinput - 48);
+			    wgetch(edit);
+		    }
+		    else if (kbinput >= '7' && kbinput <= '9') {
+			    kbinput = KEY_F(kbinput - 49);
+			    wgetch(edit);
+		    }
+		    else if (kbinput == 126)
+			    kbinput = KEY_HOME;
+
+#ifdef DEBUG
+		    else {
+		    	    fprintf(stderr, _("I got Alt-[-1-%c! (%d)\n"),
+			    kbinput, kbinput);
+			    break;
+		    }
+#endif
+
+		    break;
+		case '2': /* Alt-[-2-[0,1,3,4] = F9-F12 in many terms */
+		    kbinput = wgetch(edit);
+		    wgetch(edit);
+		    switch (kbinput) {
+			case '0':
+			    kbinput = KEY_F(9);
+			    break;
+			case '1':
+			    kbinput = KEY_F(10);
+			    break;
+			case '3':
+			    kbinput = KEY_F(11);
+			    break;
+			case '4':
+			    kbinput = KEY_F(12);
+			    break;			    
+#ifdef DEBUG
+			default:
+		    	    fprintf(stderr, _("I got Alt-[-2-%c! (%d)\n"),
+			    kbinput, kbinput);
+			    break;
+#endif
+
+		    }
+		    break;
+		case '3': /* Alt-[-3 = Delete? */
+		    kbinput = NANO_DELETE_KEY;
+		    wgetch(edit);
+		    break;
+		case '4': /* Alt-[-4 = End? */
+		    kbinput = NANO_END_KEY;
+		    wgetch(edit);
+		    break;
+		case '5': /* Alt-[-5 = Page Up */
+		    kbinput = KEY_PPAGE;
+		    wgetch(edit);
+		    break;
+		case '6': /* Alt-[-6 = Page Down */
+		    kbinput = KEY_NPAGE;
+		    wgetch(edit);
+		    break;
+		case '[': /* Alt-[-[-[A-E], F1-F5 in linux console */
+		    kbinput = wgetch(edit);
+		     if (kbinput >= 'A' && kbinput <= 'E')
+		 	kbinput = KEY_F(kbinput - 64);
+		    break;
 		case 'A':
 		    kbinput = KEY_UP;
 		    break;
@@ -1918,30 +1997,6 @@ int main(int argc, char *argv[])
 		case 'F':
 		    kbinput = KEY_END;
 		    break;
-		case 49:	/* X window F-keys */
-		    tmpkey = wgetch(edit);
-		    kbinput = KEY_F(tmpkey) - 48;
-		    wgetch(edit);	/* Junk character */
-		    break;
-		case 53:	/* page up */
-		    kbinput = KEY_PPAGE;
-		    if ((kbinput = wgetch(edit)) == 126)
-			kbinput = KEY_PPAGE;	/* Ignore extra tilde */
-		    else {	/* I guess this could happen ;-) */
-			ungetch(kbinput);
-			continue;
-		    }
-		    break;
-		case 54:	/* page down */
-		    kbinput = KEY_NPAGE;
-		    if ((kbinput = wgetch(edit)) == 126)
-			kbinput = KEY_NPAGE;	/* Same thing here */
-		    else {
-			ungetch(kbinput);
-			continue;
-		    }
-		    break;
-
 		default:
 #ifdef DEBUG
 		    fprintf(stderr, _("I got Alt-[-%c! (%d)\n"),
diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c
index a4973bb9..e0b912f9 100644
--- a/po/cat-id-tbl.c
+++ b/po/cat-id-tbl.c
@@ -192,41 +192,44 @@ Usage: nano [option] +LINE <file>\n\
   {"Main: set up windows\n", 159},
   {"Main: bottom win\n", 160},
   {"Main: open file\n", 161},
-  {"I got Alt-[-%c! (%d)\n", 162},
-  {"I got Alt-%c! (%d)\n", 163},
-  {"Case Sensitive Regexp Search%s%s", 164},
-  {"Regexp Search%s%s", 165},
-  {"Case Sensitive Search%s%s", 166},
-  {"Search%s%s", 167},
-  {" (to replace)", 168},
-  {"Search Cancelled", 169},
-  {"Search Wrapped", 170},
-  {"Replaced %d occurences", 171},
-  {"Replaced 1 occurence", 172},
-  {"Replace Cancelled", 173},
-  {"Replace with [%s]", 174},
-  {"Replace with", 175},
-  {"Replace this instance?", 176},
-  {"Enter line number", 177},
-  {"Aborted", 178},
-  {"Come on, be reasonable", 179},
-  {"Only %d lines available, skipping to last line", 180},
-  {"actual_x_from_start for xplus=%d returned %d\n", 181},
-  {"input '%c' (%d)\n", 182},
-  {"New Buffer", 183},
-  {"  File: ...", 184},
-  {"Modified", 185},
-  {"Moved to (%d, %d) in edit buffer\n", 186},
-  {"current->data = \"%s\"\n", 187},
-  {"I got \"%s\"\n", 188},
-  {"Yes", 189},
-  {"All", 190},
-  {"No", 191},
-  {"do_cursorpos: linepct = %f, bytepct = %f\n", 192},
-  {"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 193},
-  {"Dumping file buffer to stderr...\n", 194},
-  {"Dumping cutbuffer to stderr...\n", 195},
-  {"Dumping a buffer to stderr...\n", 196},
+  {"I got Alt-O-%c! (%d)\n", 162},
+  {"I got Alt-[-1-%c! (%d)\n", 163},
+  {"I got Alt-[-2-%c! (%d)\n", 164},
+  {"I got Alt-[-%c! (%d)\n", 165},
+  {"I got Alt-%c! (%d)\n", 166},
+  {"Case Sensitive Regexp Search%s%s", 167},
+  {"Regexp Search%s%s", 168},
+  {"Case Sensitive Search%s%s", 169},
+  {"Search%s%s", 170},
+  {" (to replace)", 171},
+  {"Search Cancelled", 172},
+  {"Search Wrapped", 173},
+  {"Replaced %d occurences", 174},
+  {"Replaced 1 occurence", 175},
+  {"Replace Cancelled", 176},
+  {"Replace with [%s]", 177},
+  {"Replace with", 178},
+  {"Replace this instance?", 179},
+  {"Enter line number", 180},
+  {"Aborted", 181},
+  {"Come on, be reasonable", 182},
+  {"Only %d lines available, skipping to last line", 183},
+  {"actual_x_from_start for xplus=%d returned %d\n", 184},
+  {"input '%c' (%d)\n", 185},
+  {"New Buffer", 186},
+  {"  File: ...", 187},
+  {"Modified", 188},
+  {"Moved to (%d, %d) in edit buffer\n", 189},
+  {"current->data = \"%s\"\n", 190},
+  {"I got \"%s\"\n", 191},
+  {"Yes", 192},
+  {"All", 193},
+  {"No", 194},
+  {"do_cursorpos: linepct = %f, bytepct = %f\n", 195},
+  {"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 196},
+  {"Dumping file buffer to stderr...\n", 197},
+  {"Dumping cutbuffer to stderr...\n", 198},
+  {"Dumping a buffer to stderr...\n", 199},
 };
 
-int _msg_tbl_length = 196;
+int _msg_tbl_length = 199;
diff --git a/po/es.gmo b/po/es.gmo
index 1d2d6b4f0426f798cdb89a8b8459796862490ce9..b9d8ce4d3bb586f1435713c686b6658ea23bb49c 100644
GIT binary patch
delta 16
XcmZ41&bX|daf5&cqrqlDjj7TAFpC8e

delta 16
XcmZ41&bX|daf5&cqv2*jjj7TAFp&il

diff --git a/po/nano.pot b/po/nano.pot
index f1b3a38c..e29ca6dc 100644
--- a/po/nano.pot
+++ b/po/nano.pot
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-09-06 23:44-0400\n"
+"POT-Creation-Date: 2000-09-11 18:42-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -263,7 +263,7 @@ msgstr ""
 msgid "Cancel the current function"
 msgstr ""
 
-#: global.c:207 global.c:317 global.c:389
+#: global.c:207 global.c:319 global.c:391
 msgid "Get Help"
 msgstr ""
 
@@ -271,120 +271,120 @@ msgstr ""
 msgid "WriteOut"
 msgstr ""
 
-#: global.c:214 global.c:378
+#: global.c:214 global.c:380
 msgid "Exit"
 msgstr ""
 
-#: global.c:222 global.c:313 global.c:334 global.c:353
+#: global.c:222 global.c:315 global.c:336 global.c:355
 msgid "Goto Line"
 msgstr ""
 
-#: global.c:227 global.c:305
+#: global.c:227 global.c:306
 msgid "Justify"
 msgstr ""
 
-#: global.c:230 global.c:301 global.c:331
+#: global.c:231 global.c:302 global.c:333
 msgid "Replace"
 msgstr ""
 
-#: global.c:234
+#: global.c:235
 msgid "Read File"
 msgstr ""
 
-#: global.c:238
+#: global.c:239
 msgid "Where Is"
 msgstr ""
 
-#: global.c:242 global.c:370
+#: global.c:243 global.c:372
 msgid "Prev Page"
 msgstr ""
 
-#: global.c:246 global.c:374
+#: global.c:247 global.c:376
 msgid "Next Page"
 msgstr ""
 
-#: global.c:250
+#: global.c:251
 msgid "Cut Text"
 msgstr ""
 
-#: global.c:253
+#: global.c:254
 msgid "UnCut Txt"
 msgstr ""
 
-#: global.c:257
+#: global.c:258
 msgid "Cur Pos"
 msgstr ""
 
-#: global.c:261
+#: global.c:262
 msgid "To Spell"
 msgstr ""
 
-#: global.c:265
+#: global.c:266
 msgid "Up"
 msgstr ""
 
-#: global.c:268
+#: global.c:269
 msgid "Down"
 msgstr ""
 
-#: global.c:271
+#: global.c:272
 msgid "Forward"
 msgstr ""
 
-#: global.c:274
+#: global.c:275
 msgid "Back"
 msgstr ""
 
-#: global.c:277
+#: global.c:278
 msgid "Home"
 msgstr ""
 
-#: global.c:280
+#: global.c:281
 msgid "End"
 msgstr ""
 
-#: global.c:283
+#: global.c:284
 msgid "Refresh"
 msgstr ""
 
-#: global.c:286
+#: global.c:287
 msgid "Mark Text"
 msgstr ""
 
-#: global.c:289
+#: global.c:290
 msgid "Delete"
 msgstr ""
 
-#: global.c:293
+#: global.c:294
 msgid "Backspace"
 msgstr ""
 
-#: global.c:297
+#: global.c:298
 msgid "Tab"
 msgstr ""
 
-#: global.c:308
+#: global.c:310
 msgid "Enter"
 msgstr ""
 
-#: global.c:321 global.c:341 global.c:360
+#: global.c:323 global.c:343 global.c:362
 msgid "First Line"
 msgstr ""
 
-#: global.c:324 global.c:344 global.c:363
+#: global.c:326 global.c:346 global.c:365
 msgid "Last Line"
 msgstr ""
 
-#: global.c:327 global.c:347
+#: global.c:329 global.c:349
 msgid "Case Sens"
 msgstr ""
 
-#: global.c:337 global.c:356 global.c:366 global.c:382 global.c:386
-#: global.c:392 winio.c:999
+#: global.c:339 global.c:358 global.c:368 global.c:384 global.c:388
+#: global.c:394 winio.c:999
 msgid "Cancel"
 msgstr ""
 
-#: global.c:350
+#: global.c:352
 msgid "No Replace"
 msgstr ""
 
@@ -675,24 +675,52 @@ msgstr ""
 msgid "Cannot move bottom win"
 msgstr ""
 
+#: nano.c:1618
+#, c-format
+msgid "%s enable/disable"
+msgstr ""
+
+#: nano.c:1630
+msgid "enabled"
+msgstr ""
+
+#: nano.c:1631
+msgid "disabled"
+msgstr ""
+
 #: nano.c:1852
 msgid "Main: set up windows\n"
 msgstr ""
 
-#: nano.c:1867
+#: nano.c:1865
 msgid "Main: bottom win\n"
 msgstr ""
 
-#: nano.c:1873
+#: nano.c:1871
 msgid "Main: open file\n"
 msgstr ""
 
-#: nano.c:1947
+#: nano.c:1905
+#, c-format
+msgid "I got Alt-O-%c! (%d)\n"
+msgstr ""
+
+#: nano.c:1929
+#, c-format
+msgid "I got Alt-[-1-%c! (%d)\n"
+msgstr ""
+
+#: nano.c:1954
+#, c-format
+msgid "I got Alt-[-2-%c! (%d)\n"
+msgstr ""
+
+#: nano.c:2002
 #, c-format
 msgid "I got Alt-[-%c! (%d)\n"
 msgstr ""
 
-#: nano.c:1973
+#: nano.c:2028
 #, c-format
 msgid "I got Alt-%c! (%d)\n"
 msgstr ""
-- 
GitLab