Fix control-character parsing in windows (#629)
This commit is contained in:
parent
9bc5cd3527
commit
e920d0cfd7
@ -97,6 +97,13 @@ fn parse_key_event_record(key_event: &KeyEventRecord) -> Option<KeyEvent> {
|
||||
let c = character_raw as u8;
|
||||
if c <= b'\x1F' {
|
||||
character = (c | b'\x40') as char;
|
||||
// if we press something like ctrl-g, we will get `character` with value `G`.
|
||||
// in this case, convert the `character` to lowercase `g`.
|
||||
if character.is_ascii_uppercase()
|
||||
&& !modifiers.contains(KeyModifiers::SHIFT)
|
||||
{
|
||||
character.make_ascii_lowercase();
|
||||
}
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
|
@ -28,10 +28,9 @@ pub(crate) fn set_foreground_color(fg_color: Color) -> Result<()> {
|
||||
|
||||
// Notice that the color values are stored in wAttribute.
|
||||
// So we need to use bitwise operators to check if the values exists or to get current console colors.
|
||||
let mut color: u16;
|
||||
let attrs = csbi.attributes();
|
||||
let bg_color = attrs & 0x0070;
|
||||
color = color_value | bg_color;
|
||||
let mut color = color_value | bg_color;
|
||||
|
||||
// background intensity is a separate value in attrs,
|
||||
// wee need to check if this was applied to the current bg color.
|
||||
@ -53,10 +52,9 @@ pub(crate) fn set_background_color(bg_color: Color) -> Result<()> {
|
||||
|
||||
// Notice that the color values are stored in wAttribute.
|
||||
// So wee need to use bitwise operators to check if the values exists or to get current console colors.
|
||||
let mut color: u16;
|
||||
let attrs = csbi.attributes();
|
||||
let fg_color = attrs & 0x0007;
|
||||
color = fg_color | color_value;
|
||||
let mut color = fg_color | color_value;
|
||||
|
||||
// Foreground intensity is a separate value in attrs,
|
||||
// So we need to check if this was applied to the current fg color.
|
||||
|
Loading…
Reference in New Issue
Block a user