Remove R_BEGIN_INPUT_FUNCTIONS

The enum starts at 0 (defined to be!), so we can eliminate this one.

That allows us to remove a reliance on the position of
beginning_of_line, and it would trigger a "type-limits" warning.

Also leave a comment because I actually hit that.
This commit is contained in:
Fabian Homborg 2019-05-29 20:36:01 +02:00
parent 4a6a354675
commit 39099ceb10
2 changed files with 5 additions and 6 deletions

View file

@ -63,7 +63,7 @@ struct terminfo_mapping_t {
const char *seq; // character sequence generated on keypress const char *seq; // character sequence generated on keypress
}; };
static constexpr size_t input_function_count = R_END_INPUT_FUNCTIONS - R_BEGIN_INPUT_FUNCTIONS; static constexpr size_t input_function_count = R_END_INPUT_FUNCTIONS;
/// Input function metadata. This list should be kept in sync with the key code list in /// Input function metadata. This list should be kept in sync with the key code list in
/// input_common.h. /// input_common.h.
@ -140,9 +140,8 @@ static_assert(sizeof(input_function_metadata) / sizeof(input_function_metadata[0
"input_function_metadata?"); "input_function_metadata?");
wcstring describe_char(wint_t c) { wcstring describe_char(wint_t c) {
if (c >= R_BEGIN_INPUT_FUNCTIONS && c < R_END_INPUT_FUNCTIONS) { if (c < R_END_INPUT_FUNCTIONS) {
size_t idx = c - R_BEGIN_INPUT_FUNCTIONS; return format_string(L"%02x (%ls)", c, input_function_metadata[c].name);
return format_string(L"%02x (%ls)", c, input_function_metadata[idx].name);
} }
return format_string(L"%02x", c); return format_string(L"%02x", c);
} }

View file

@ -67,12 +67,12 @@ enum class readline_cmd_t {
expand_abbr, expand_abbr,
cancel, cancel,
repeat_jump, repeat_jump,
reverse_repeat_jump, // NOTE: This one has to be last.
reverse_repeat_jump
}; };
// The range of key codes for inputrc-style keyboard functions. // The range of key codes for inputrc-style keyboard functions.
enum { enum {
R_BEGIN_INPUT_FUNCTIONS = static_cast<int>(readline_cmd_t::beginning_of_line),
R_END_INPUT_FUNCTIONS = static_cast<int>(readline_cmd_t::reverse_repeat_jump) + 1 R_END_INPUT_FUNCTIONS = static_cast<int>(readline_cmd_t::reverse_repeat_jump) + 1
}; };