- assert(key >= KEY_OFFSET);
- ret = i9ep->ici->key_handler(key - KEY_OFFSET);
- return ret < 0? ret : 0;
+again:
+ if (i9ep->key_sequence_length == 0)
+ return 0;
+ for (i = i9ep->num_key_bindings - 1; i >= 0; i--) {
+ if (strcmp(i9ep->key_sequence, i9ep->ici->bound_keyseqs[i]))
+ continue;
+ i9ep->key_sequence[0] = '\0';
+ i9ep->key_sequence_length = 0;
+ ret = i9ep->ici->key_handler(i);
+ return ret < 0? ret : 0;
+ }
+ PARA_WARNING_LOG("ignoring key %d\n", i9ep->key_sequence[0]);
+ /*
+ * We received an undefined key sequence. Throw away the first byte,
+ * and try to parse the remainder.
+ */
+ memmove(i9ep->key_sequence, i9ep->key_sequence + 1,
+ i9ep->key_sequence_length); /* move also terminating zero byte */
+ i9ep->key_sequence_length--;
+ goto again;