diff options
Diffstat (limited to 'src/input_dispatcher.cc')
-rw-r--r-- | src/input_dispatcher.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/input_dispatcher.cc b/src/input_dispatcher.cc index 62c1f40..7df19aa 100644 --- a/src/input_dispatcher.cc +++ b/src/input_dispatcher.cc @@ -100,9 +100,14 @@ input_dispatcher::new_input(const struct timeval& current_time, int ch) switch (this->id_escape_matcher(keyseq.data())) { case escape_match_t::NONE: { for (int lpc = 0; this->id_escape_buffer[lpc]; - lpc++) { + lpc++) + { + snprintf(keyseq.data(), + keyseq.size(), + "x%02x", + this->id_escape_buffer[lpc] & 0xff); handled = this->id_key_handler( - this->id_escape_buffer[lpc]); + this->id_escape_buffer[lpc], keyseq.data()); } this->id_escape_index = 0; break; @@ -120,6 +125,13 @@ input_dispatcher::new_input(const struct timeval& current_time, int ch) { this->id_escape_index = 0; } + } else if (ch > 0xff) { + if (KEY_F(0) <= ch && ch <= KEY_F(64)) { + snprintf(keyseq.data(), keyseq.size(), "f%d", ch - KEY_F0); + } else { + snprintf(keyseq.data(), keyseq.size(), "n%04o", ch); + } + handled = this->id_key_handler(ch, keyseq.data()); } else { auto seq_size = utf::utf8::char_size([ch]() { return std::make_pair(ch, 16); @@ -127,7 +139,7 @@ input_dispatcher::new_input(const struct timeval& current_time, int ch) if (seq_size == 1) { snprintf(keyseq.data(), keyseq.size(), "x%02x", ch & 0xff); - handled = this->id_key_handler(ch); + handled = this->id_key_handler(ch, keyseq.data()); } else { this->reset_escape_buffer(ch, current_time, seq_size); } @@ -149,7 +161,8 @@ input_dispatcher::poll(const struct timeval& current_time) timersub(¤t_time, &this->id_escape_start_time, &diff); if (escape_threshold < diff) { - this->id_key_handler(KEY_CTRL_RBRACKET); + static const char ESC_KEYSEQ[] = "\x1b"; + this->id_key_handler(KEY_ESCAPE, ESC_KEYSEQ); this->id_escape_index = 0; } } |