feat(input): delay all simplifications

Avoid unsimplfied Ctrl-C in input buffer when it is not mapped.
This commit is contained in:
zeertzjq 2022-04-26 10:09:35 +08:00
parent 68ddbdd03b
commit 7029b4b44a

View File

@ -238,8 +238,9 @@ size_t input_enqueue(String keys)
// but since the keys are UTF-8, so the first byte cannot be
// K_SPECIAL(0x80).
uint8_t buf[19] = { 0 };
// Do not simplify the keys here. Simplification will be done later.
unsigned int new_size
= trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, true, false, true, NULL);
= trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, true, false, false, NULL);
if (new_size) {
new_size = handle_mouse_event(&ptr, buf, new_size);
@ -487,7 +488,12 @@ static void process_interrupts(void)
size_t consume_count = 0;
RBUFFER_EACH_REVERSE(input_buffer, c, i) {
if ((uint8_t)c == Ctrl_C) {
if ((uint8_t)c == Ctrl_C
|| ((uint8_t)c == 'C' && i >= 3
&& (uint8_t)(*rbuffer_get(input_buffer, i - 3)) == K_SPECIAL
&& (uint8_t)(*rbuffer_get(input_buffer, i - 2)) == KS_MODIFIER
&& (uint8_t)(*rbuffer_get(input_buffer, i - 1)) == MOD_MASK_CTRL)) {
*rbuffer_get(input_buffer, i) = Ctrl_C;
got_int = true;
consume_count = i;
break;