]> git.wh0rd.org Git - nano.git/commitdiff
in parse_escape_seq_kbinput(), handle unknown and unignored escape
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Sun, 23 Jul 2006 17:54:35 +0000 (17:54 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Sun, 23 Jul 2006 17:54:35 +0000 (17:54 +0000)
sequences once instead of handling them twice in parse_kbinput()

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3807 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/proto.h
src/winio.c

index e2b91af1c8cb6bf004442f150c3a5389e238ca5a..347b39a7bd55790f2e8e18df443b1b46b79f2563 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -141,6 +141,9 @@ CVS code -
        - If they're defined, translate KEY_SUP into NANO_PREVLINE_KEY
          and KEY_SDOWN into NANO_NEXTLINE_KEY, since they are sometimes
          generated by Shift-Up and Shift-Down. (DLR)
+  parse_escape_seq_kbinput()
+       - Handle unknown and unignored escape sequences once here
+         instead of twice in parse_kbinput(). (DLR)
   display_string()
        - Properly handle buf[start_index]'s being a null terminator.
          (DLR)
index b7242362cae87239660bcfc684da83f8f4dbced4..382a3d155f3461e6aedbd4526e7f98c3206ce785 100644 (file)
@@ -735,7 +735,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
 int get_escape_seq_kbinput(const int *seq, size_t seq_len, bool
        *ignore_seq);
 int get_escape_seq_abcd(int kbinput);
-int parse_escape_seq_kbinput(int kbinput, bool *ignore_seq);
+int parse_escape_seq_kbinput(WINDOW *win, int kbinput);
 int get_byte_kbinput(int kbinput);
 #ifdef ENABLE_UTF8
 long add_unicode_digit(int kbinput, long factor, long *uni);
index b226b98d7cd9dd24da8baab43435a2c98bcb401c..fbd4169863f0bec9bab27c9db944cd8622f54a74 100644 (file)
@@ -377,18 +377,8 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
                         * there are other keystrokes waiting: escape
                         * sequence mode.  Interpret the escape
                         * sequence. */
-                       bool ignore_seq;
-
-                       retval = parse_escape_seq_kbinput(*kbinput,
-                               &ignore_seq);
-
-                       /* If the escape sequence is unrecognized and
-                        * not ignored, throw it out. */
-                       if (retval == ERR && !ignore_seq) {
-                           if (win == edit)
-                               statusbar(_("Unknown Command"));
-                           beep();
-                       }
+                       retval = parse_escape_seq_kbinput(win,
+                               *kbinput);
                    }
                    break;
                case 2:
@@ -470,20 +460,10 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
                         * meta and escape sequence mode.  Reset the
                         * escape counter, set meta_key to TRUE, and
                         * interpret the escape sequence. */
-                       bool ignore_seq;
-
                        escapes = 0;
                        *meta_key = TRUE;
-                       retval = parse_escape_seq_kbinput(*kbinput,
-                               &ignore_seq);
-
-                       /* If the escape sequence is unrecognized and
-                        * not ignored, throw it out. */
-                       if (retval == ERR && !ignore_seq) {
-                           if (win == edit)
-                               statusbar(_("Unknown Command"));
-                           beep();
-                       }
+                       retval = parse_escape_seq_kbinput(win,
+                               *kbinput);
                    }
                    break;
            }
@@ -1196,14 +1176,13 @@ int get_escape_seq_abcd(int kbinput)
 }
 
 /* Interpret the escape sequence in the keystroke buffer, the first
- * character of which is kbinput.  If we want to ignore the escape
- * sequence, set retval to ERR and ignore_seq to TRUE.  Assume that the
- * keystroke buffer isn't empty, and that the initial escape has already
- * been read in. */
-int parse_escape_seq_kbinput(int kbinput, bool *ignore_seq)
+ * character of which is kbinput.  Assume that the keystroke buffer
+ * isn't empty, and that the initial escape has already been read in. */
+int parse_escape_seq_kbinput(WINDOW *win, int kbinput)
 {
     int retval, *seq;
     size_t seq_len;
+    bool ignore_seq;
 
     /* Put back the non-escape character, get the complete escape
      * sequence, translate the sequence into its corresponding key
@@ -1211,12 +1190,21 @@ int parse_escape_seq_kbinput(int kbinput, bool *ignore_seq)
     unget_input(&kbinput, 1);
     seq_len = get_key_buffer_len();
     seq = get_input(NULL, seq_len);
-    retval = get_escape_seq_kbinput(seq, seq_len, ignore_seq);
+    retval = get_escape_seq_kbinput(seq, seq_len, &ignore_seq);
 
     free(seq);
 
+    /* If we got an unrecognized escape sequence, and it's not ignored,
+     * throw it out. */
+    if (retval == ERR && !ignore_seq) {
+       if (win == edit)
+           statusbar(_("Unknown Command"));
+           beep();
+       }
+    }
+
 #ifdef DEBUG
-    fprintf(stderr, "parse_escape_seq_kbinput(): kbinput = %d, ignore_seq = %s, seq_len = %lu, retval = %d\n", kbinput, *ignore_seq ? "TRUE" : "FALSE", (unsigned long)seq_len, retval);
+    fprintf(stderr, "parse_escape_seq_kbinput(): kbinput = %d, ignore_seq = %s, seq_len = %lu, retval = %d\n", kbinput, ignore_seq ? "TRUE" : "FALSE", (unsigned long)seq_len, retval);
 #endif
 
     return retval;