mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-04 14:46:03 +00:00
Fix detection of ASCII control chars in key event text
This commit is contained in:
parent
dcfeab8461
commit
5fafd70b0f
1 changed files with 12 additions and 3 deletions
|
|
@ -348,8 +348,17 @@ encode_key(const KeyEvent *ev, char *output) {
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_ascii_control_char(char c) {
|
||||
return c <= 31 || c == 127;
|
||||
startswith_ascii_control_char(const char *p) {
|
||||
if (!p || !*p) return false;
|
||||
uint32_t codep, state = UTF8_ACCEPT;
|
||||
while(*p) {
|
||||
if (decode_utf8(&state, &codep, *p) == UTF8_ACCEPT) {
|
||||
return codep < 32 || codep == 127;
|
||||
}
|
||||
state = UTF8_ACCEPT;
|
||||
p++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -365,7 +374,7 @@ encode_glfw_key_event(const GLFWkeyevent *e, const bool cursor_key_mode, const u
|
|||
.embed_text = key_encoding_flags & 16
|
||||
};
|
||||
if (!ev.report_text && is_modifier_key(e->key)) return 0;
|
||||
ev.has_text = e->text && !is_ascii_control_char(e->text[0]);
|
||||
ev.has_text = e->text && !startswith_ascii_control_char(e->text);
|
||||
if (!ev.key && !ev.has_text) return 0;
|
||||
bool send_text_standalone = !ev.report_text;
|
||||
if (!ev.disambiguate && GLFW_FKEY_KP_0 <= ev.key && ev.key <= GLFW_FKEY_KP_DELETE) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue