commit 87542eeaf1ab8034bafa4450627d56bc4def4deb
parent 29f2e3181a23f23cd4c93aee89ba8195c8759e54
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 27 Dec 2019 17:01:15 +0100
tweaks: move a function to before the one that calls it
And condense its logic. And improve its comment.
Diffstat:
2 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/proto.h b/src/proto.h
@@ -610,7 +610,6 @@ void implant(const char *string);
#endif
int get_kbinput(WINDOW *win, bool showcursor);
int parse_kbinput(WINDOW *win);
-int arrow_from_ABCD(int letter);
int parse_escape_sequence(WINDOW *win, int kbinput);
int get_byte_kbinput(int kbinput);
int get_control_kbinput(int kbinput);
diff --git a/src/winio.c b/src/winio.c
@@ -786,6 +786,16 @@ int parse_kbinput(WINDOW *win)
return retval;
}
+/* Return the arrow-key code that corresponds to the given letter.
+ * (This mapping is common to a handful of escape sequences.) */
+int arrow_from_ABCD(int letter)
+{
+ if (letter < 'C')
+ return (letter == 'A' ? KEY_UP : KEY_DOWN);
+ else
+ return (letter == 'D' ? KEY_LEFT : KEY_RIGHT);
+}
+
/* Translate escape sequences, most of which correspond to extended
* keypad values, into their corresponding key values. These sequences
* are generated when the keypad doesn't support the needed keys.
@@ -1256,22 +1266,6 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
return ERR;
}
-/* Return the equivalent arrow-key value for the first four letters
- * in the alphabet, common to many escape sequences. */
-int arrow_from_ABCD(int letter)
-{
- switch (letter) {
- case 'A':
- return KEY_UP;
- case 'B':
- return KEY_DOWN;
- case 'C':
- return KEY_RIGHT;
- default:
- return KEY_LEFT;
- }
-}
-
/* Interpret the escape sequence in the keystroke buffer, the first
* character of which is kbinput. Assume that the keystroke buffer
* isn't empty, and that the initial escape has already been read in. */