From 91951ab22ad548c99511dff613adc1c147e50bc6 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 23 Jul 2016 14:01:38 +0200
Subject: [PATCH] input: don't bother putting a keycode into byte range

A keycode is either already in byte range (so there is nothing to do)
or it is not and it shouldn't be (so there is nothing to do either).
---
 src/browser.c |  2 +-
 src/proto.h   |  2 +-
 src/text.c    |  2 +-
 src/winio.c   | 15 +++++----------
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/browser.c b/src/browser.c
index 4d784bde..23b31026 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -149,7 +149,7 @@ char *do_browser(char *path)
 		/* If we selected the same filename as last time, fake a
 		 * press of the Enter key so that the file is read in. */
 		if (old_selected == selected)
-		    unget_kbinput(sc_seq_or(do_enter, 0), FALSE, FALSE);
+		    unget_kbinput(sc_seq_or(do_enter, 0), FALSE);
 	    }
 
 	    continue;
diff --git a/src/proto.h b/src/proto.h
index 58f7fad8..1da24708 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -763,7 +763,7 @@ void dump_filestruct_reverse(void);
 void get_key_buffer(WINDOW *win);
 size_t get_key_buffer_len(void);
 void unget_input(int *input, size_t input_len);
-void unget_kbinput(int kbinput, bool metakey, bool funckey);
+void unget_kbinput(int kbinput, bool metakey);
 int *get_input(WINDOW *win, size_t input_len);
 int get_kbinput(WINDOW *win);
 int parse_kbinput(WINDOW *win);
diff --git a/src/text.c b/src/text.c
index 36cc90e1..dbad310c 100644
--- a/src/text.c
+++ b/src/text.c
@@ -2559,7 +2559,7 @@ void do_justify(bool full_justify)
 	}
     } else {
 	/* Put the keystroke back into the queue. */
-	unget_kbinput(kbinput, meta_key, func_key);
+	unget_kbinput(kbinput, meta_key);
 
 	/* Set the desired screen column (always zero, except at EOF). */
 	openfile->placewewant = xplustabs();
diff --git a/src/winio.c b/src/winio.c
index f98117b0..0cfe2724 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -248,15 +248,10 @@ void unget_input(int *input, size_t input_len)
     memcpy(key_buffer, input, input_len * sizeof(int));
 }
 
-/* Put back the character stored in kbinput, putting it in byte range
- * beforehand.  If metakey is TRUE, put back the Escape character after
- * putting back kbinput.  If funckey is TRUE, put back the function key
- * (a value outside byte range) without putting it in byte range. */
-void unget_kbinput(int kbinput, bool metakey, bool funckey)
+/* Put the character given in kbinput back into the input stream.  If it
+ * is a Meta key, also insert an Escape character in front of it. */
+void unget_kbinput(int kbinput, bool metakey)
 {
-    if (!funckey)
-	kbinput = (char)kbinput;
-
     unget_input(&kbinput, 1);
 
     if (metakey) {
@@ -1563,7 +1558,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
 	    /* And put the corresponding key into the keyboard buffer. */
 	    if (f != NULL) {
 		const sc *s = first_sc_for(currmenu, f->scfunc);
-		unget_kbinput(s->seq, s->type == META, s->type == DIRECT);
+		unget_kbinput(s->seq, s->type == META);
 	    }
 	    return 1;
 	} else
@@ -1591,7 +1586,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
 	     * wheel is equivalent to moving down three lines. */
 	    for (i = 0; i < 3; i++)
 		unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
-				KEY_PPAGE : KEY_NPAGE, FALSE, FALSE);
+				KEY_PPAGE : KEY_NPAGE, FALSE);
 
 	    return 1;
 	} else
-- 
GitLab