Rename R_MIN and R_MAX to R_BEGIN/END_INPUT_FUNCTIONS

This makes the names more obvious.
We also make the range half-open as is the convention.
This commit is contained in:
ridiculousfish 2018-01-29 11:52:55 -08:00
parent 9ce3ac5b93
commit 43c839ab0e
3 changed files with 14 additions and 11 deletions

View file

@ -329,7 +329,8 @@ void input_function_push_args(int code) {
wchar_t arg;
// Skip and queue up any function codes. See issue #2357.
while ((arg = input_common_readch(0)) >= R_MIN && arg <= R_MAX) {
while ((arg = input_common_readch(0)) >= R_BEGIN_INPUT_FUNCTIONS &&
arg < R_END_INPUT_FUNCTIONS) {
skipped.push_back(arg);
}
@ -483,7 +484,8 @@ static wchar_t input_read_characters_only() {
wchar_t char_to_return;
for (;;) {
char_to_return = input_common_readch(0);
bool is_readline_function = (char_to_return >= R_MIN && char_to_return <= R_MAX);
bool is_readline_function =
(char_to_return >= R_BEGIN_INPUT_FUNCTIONS && char_to_return < R_END_INPUT_FUNCTIONS);
// R_NULL and R_EOF are more control characters than readline functions, so check specially
// for those.
if (!is_readline_function || char_to_return == R_NULL || char_to_return == R_EOF) {
@ -509,7 +511,7 @@ wint_t input_readch(bool allow_commands) {
while (1) {
wchar_t c = input_common_readch(0);
if (c >= R_MIN && c <= R_MAX) {
if (c >= R_BEGIN_INPUT_FUNCTIONS && c < R_END_INPUT_FUNCTIONS) {
switch (c) {
case R_EOF: // if it's closed, then just return
{
@ -525,7 +527,7 @@ wint_t input_readch(bool allow_commands) {
return input_readch();
}
c = input_common_readch(0);
while (c >= R_MIN && c <= R_MAX) {
while (c >= R_BEGIN_INPUT_FUNCTIONS && c < R_END_INPUT_FUNCTIONS) {
c = input_common_readch(0);
}
input_common_next_ch(c);

View file

@ -194,7 +194,7 @@ wchar_t input_common_readch(int timed) {
while (1) {
wint_t b = readb();
if (b >= R_NULL && b <= R_MAX) return b;
if (b >= R_NULL && b < R_END_INPUT_FUNCTIONS) return b;
if (MB_CUR_MAX == 1) {
// return (unsigned char)b; // single-byte locale, all values are legal

View file

@ -14,11 +14,7 @@ enum {
// delivered, or when an exception happened.
R_NULL = R_MIN,
R_EOF,
// Key codes for inputrc-style keyboard functions that are passed on to the caller of
// input_read().
//
// NOTE: If you modify this sequence of symbols you must update the name_arr, code_arr and
// desc_arr variables in input.cpp to match!
R_BEGINNING_OF_LINE,
R_END_OF_LINE,
R_FORWARD_CHAR,
@ -72,8 +68,13 @@ enum {
R_BACKWARD_JUMP,
R_AND,
R_CANCEL,
R_TIMEOUT, // we didn't get interactive input within wait_on_escape_ms
R_MAX = R_CANCEL
// The range of key codes for inputrc-style keyboard functions that are passed on to the caller
// of input_read().
R_BEGIN_INPUT_FUNCTIONS = R_BEGINNING_OF_LINE,
R_END_INPUT_FUNCTIONS = R_CANCEL + 1
};
/// Init the library.