kitty keeb: fixup shifted character encoding

refs: https://github.com/wez/wezterm/issues/3474
This commit is contained in:
Wez Furlong committed 2023-04-08 20:01:10 -07:00
1 parent 0540301121
commit 397593be5c
1 file changed
+34 -1
+34 -1
View File
@@ -385,7 +385,12 @@ impl KeyCode {
// Note: we don't have enough information here to know what the base-layout key
// should really be.
let base_layout = c;
format!("{}:{}:{}", c, shifted_key, base_layout)
format!(
"{}:{}:{}",
(c as u32),
(shifted_key as u32),
(base_layout as u32)
)
} else {
(c as u32).to_string()
};
@@ -2157,4 +2162,32 @@ mod test {
"\x1b[49;4u".to_string()
);
}
#[test]
fn encode_issue_3474() {
let mode = KeyCodeEncodeModes {
encoding: KeyboardEncoding::Kitty(
KittyKeyboardFlags::DISAMBIGUATE_ESCAPE_CODES
| KittyKeyboardFlags::REPORT_EVENT_TYPES
| KittyKeyboardFlags::REPORT_ALTERNATE_KEYS
| KittyKeyboardFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES,
),
newline_mode: false,
application_cursor_keys: false,
modify_other_keys: None,
};
assert_eq!(
KeyCode::Char('A')
.encode(Modifiers::NONE, mode, true)
.unwrap(),
"\u{1b}[97:65:97;1u".to_string()
);
assert_eq!(
KeyCode::Char('A')
.encode(Modifiers::NONE, mode, false)
.unwrap(),
"\u{1b}[97:65:97;1:3u".to_string()
);
}
}