tweaks: move a function to before the one that calls it

And condense its logic.  And improve its comment.
master
Benno Schulenberg 2019-12-27 17:01:15 +01:00
parent 29f2e3181a
commit 87542eeaf1
2 changed files with 10 additions and 17 deletions

View File

@ -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);

View File

@ -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. */