diff --git a/src/input.cpp b/src/input.cpp index b759c1982..5cba29738 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -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); diff --git a/src/input_common.cpp b/src/input_common.cpp index 19ad41e2e..05041bd99 100644 --- a/src/input_common.cpp +++ b/src/input_common.cpp @@ -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 diff --git a/src/input_common.h b/src/input_common.h index 618b30e7c..896c820dc 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -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.