input: Ignore invalid "<" key sequences

Ignoring invalid key sequences simplifies input handling in UIs. The only
downside is having to use "<lt>" everytime a "<" is needed on functional tests.
This commit is contained in:
Thiago de Arruda
2014-12-14 09:20:07 -03:00
parent 17b211d288
commit 3e83e44792
2 changed files with 13 additions and 7 deletions

View File

@@ -187,14 +187,20 @@ size_t input_enqueue(String keys)
unsigned int new_size = trans_special((uint8_t **)&ptr, buf, false);
if (!new_size) {
if (*ptr == '<') {
// Invalid key sequence, skip until the next '>' or until *end
do {
ptr++;
} while (ptr < end && *ptr != '>');
ptr++;
continue;
}
// copy the character unmodified
*buf = (uint8_t)*ptr++;
new_size = 1;
}
new_size = handle_mouse_event(&ptr, buf, new_size);
// TODO(tarruda): Don't produce past unclosed '<' characters, except if
// there's a lot of characters after the '<'
rbuffer_write(input_buffer, (char *)buf, new_size);
}