BLT: Use bearlibterminal char function (#496)

It already handles shift, capslock and user keymap
Leave fallback for when it doesnt work (CTRL pressed?)
This commit is contained in:
Asad Mehmood 2020-08-25 18:57:19 +01:00 committed by GitHub
parent 792c4f1638
commit 049919b609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -369,8 +369,17 @@ fn colour_to_blt_colour(clr: Color, role: ColorRole) -> BltColor {
BltColor::from_rgb(r, g, b) BltColor::from_rgb(r, g, b)
} }
#[allow(clippy::cognitive_complexity)]
fn blt_keycode_to_char(kc: KeyCode, shift: bool) -> char { fn blt_keycode_to_char(kc: KeyCode, shift: bool) -> char {
let bltchar = bear_lib_terminal::terminal::state::char();
if bltchar == '\u{0}' {
return blt_keycode_to_char_impl(kc, shift);
} else {
return bltchar;
}
}
#[allow(clippy::cognitive_complexity)]
fn blt_keycode_to_char_impl(kc: KeyCode, shift: bool) -> char {
match kc { match kc {
KeyCode::A if shift => 'A', KeyCode::A if shift => 'A',
KeyCode::A => 'a', KeyCode::A => 'a',