From 428519994c082f2bddfc5e66ce86a31599c297ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hlavat=C3=BD?= Date: Sat, 4 Apr 2020 09:19:20 +0200 Subject: [PATCH] Fix handling of unicode characters > 255 (#411) --- src/event/sys/windows/parse.rs | 5 ++++- src/style/sys/windows.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/event/sys/windows/parse.rs b/src/event/sys/windows/parse.rs index 486cb61..f594550 100644 --- a/src/event/sys/windows/parse.rs +++ b/src/event/sys/windows/parse.rs @@ -108,7 +108,10 @@ fn parse_key_event_record(key_event: &KeyEventRecord) -> Option { Some(KeyCode::Char(character)) } } else { - None + match std::char::from_u32(character_raw as u32) { + Some(ch) => Some(KeyCode::Char(ch)), + None => None, + } } } }; diff --git a/src/style/sys/windows.rs b/src/style/sys/windows.rs index 562618a..2b330a3 100644 --- a/src/style/sys/windows.rs +++ b/src/style/sys/windows.rs @@ -133,7 +133,7 @@ impl From for u16 { const REMOVE_BG_MASK: u16 = BG_INTENSITY | BG_RED | BG_GREEN | BG_BLUE; // remove all background values from the original color, we don't want to reset those. - (original_color & !(REMOVE_BG_MASK)) + original_color & !REMOVE_BG_MASK } /* WinApi will be used for systems that do not support ANSI, those are windows version less then 10. RGB and 255 (AnsiBValue) colors are not supported in that case.*/ @@ -165,7 +165,7 @@ impl From for u16 { const REMOVE_FG_MASK: u16 = FG_INTENSITY | FG_RED | FG_GREEN | FG_BLUE; // remove all foreground values from the original color, we don't want to reset those. - (original_color & !(REMOVE_FG_MASK)) + original_color & !REMOVE_FG_MASK } /* WinApi will be used for systems that do not support ANSI, those are windows version less then 10. RGB and 255 (AnsiBValue) colors are not supported in that case.*/ Color::Rgb { .. } => 0,