diff --git a/CHANGELOG.md b/CHANGELOG.md index 4562efa8..58abd110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): - Bulk create ([#3793]) +### Changed + +- Rename `` to `` ([#3989]) +- Remove Legacy Console Mode on Windows ([#3989]) + ## [v26.5.6] ### Added @@ -1721,3 +1726,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): [#3906]: https://github.com/sxyazi/yazi/pull/3906 [#3934]: https://github.com/sxyazi/yazi/pull/3934 [#3943]: https://github.com/sxyazi/yazi/pull/3943 +[#3989]: https://github.com/sxyazi/yazi/pull/3989 diff --git a/yazi-macro/src/stdio.rs b/yazi-macro/src/stdio.rs index 470e18bc..6956d17c 100644 --- a/yazi-macro/src/stdio.rs +++ b/yazi-macro/src/stdio.rs @@ -19,6 +19,7 @@ macro_rules! errln { macro_rules! writef { ($dst:expr, $($arg:tt)*) => {{ use std::io::Write as _; - write!($dst, $($arg)*).and_then(|_| ($dst).flush()) + let dst = &mut $dst; + write!(dst, $($arg)*).and_then(|_| dst.flush()) }}; } diff --git a/yazi-term/src/parser/csi.rs b/yazi-term/src/parser/csi.rs index 27a35579..82a40b1a 100644 --- a/yazi-term/src/parser/csi.rs +++ b/yazi-term/src/parser/csi.rs @@ -190,8 +190,8 @@ impl Parser { let cb = parse_next::(&mut it)?.checked_sub(32).ok_or(ParseError::Invalid)?; let (kind, modifiers) = MouseEventKind::from_cb(cb)?; - let column = parse_next::(&mut it)? - 1; - let row = parse_next::(&mut it)? - 1; + let column = parse_next::(&mut it)?.checked_sub(1).ok_or(ParseError::Invalid)?; + let row = parse_next::(&mut it)?.checked_sub(1).ok_or(ParseError::Invalid)?; Ok(Event::Mouse(MouseEvent { kind, column, row, modifiers })) } @@ -212,8 +212,8 @@ impl Parser { // Mouse positions are encoded as (value + 32), but the upper left // character position on the terminal is denoted as 1,1. // So, we need to subtract 32 + 1 (33) to keep it synced with the cursor. - let column = u16::from(seq[4].saturating_sub(33)); - let row = u16::from(seq[5].saturating_sub(33)); + let column = u16::from(seq[4].checked_sub(33).ok_or(ParseError::Invalid)?); + let row = u16::from(seq[5].checked_sub(33).ok_or(ParseError::Invalid)?); Ok(Event::Mouse(MouseEvent { kind, column, row, modifiers })) } diff --git a/yazi-term/src/terminal/windows.rs b/yazi-term/src/terminal/windows.rs index 495546fd..cbe0d5af 100644 --- a/yazi-term/src/terminal/windows.rs +++ b/yazi-term/src/terminal/windows.rs @@ -48,36 +48,32 @@ impl<'a> Terminal<'a> { } pub fn enter_raw_mode(&self) -> io::Result<()> { - _ = self.set_input_mode( + self.set_input_mode( (self.restorer.input_mode & !(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT)) | ENABLE_VIRTUAL_TERMINAL_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT, - ); + )?; - _ = self.set_output_mode( + self.set_output_mode( self.restorer.output_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN, - ); - - Ok(()) + ) } pub fn enter_cooked_mode(&self) -> io::Result<()> { - _ = self.set_output_mode( + self.set_output_mode( self.restorer.output_mode & !(ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN), - ); + )?; - _ = self.set_input_mode( + self.set_input_mode( (self.restorer.input_mode & !(ENABLE_VIRTUAL_TERMINAL_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT)) | ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT, - ); - - Ok(()) + ) } fn set_input_cp(&self, cp: u32) -> io::Result<()> { bool_ok(unsafe { SetConsoleCP(cp) }) }