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;
|
let c = character_raw as u8;
|
||||||
if c <= b'\x1F' {
|
if c <= b'\x1F' {
|
||||||
character = (c | b'\x40') as char;
|
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 {
|
} else {
|
||||||
return None;
|
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.
|
// 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.
|
// 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 attrs = csbi.attributes();
|
||||||
let bg_color = attrs & 0x0070;
|
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,
|
// background intensity is a separate value in attrs,
|
||||||
// wee need to check if this was applied to the current bg color.
|
// 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.
|
// 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.
|
// 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 attrs = csbi.attributes();
|
||||||
let fg_color = attrs & 0x0007;
|
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,
|
// Foreground intensity is a separate value in attrs,
|
||||||
// So we need to check if this was applied to the current fg color.
|
// So we need to check if this was applied to the current fg color.
|
||||||
|
Loading…
Reference in New Issue
Block a user