mirror of
https://github.com/lotabout/skim.git
synced 2026-09-10 07:16:23 -04:00
fix: do not panic on push/pop keyboard enhancement flags failure
This commit is contained in:
parent
3644242897
commit
0415ea7bcd
|
|
@ -294,10 +294,12 @@ where
|
||||||
if self.is_fullscreen {
|
if self.is_fullscreen {
|
||||||
crossterm::execute!(stderr(), EnterAlternateScreen, cursor::Hide)?;
|
crossterm::execute!(stderr(), EnterAlternateScreen, cursor::Hide)?;
|
||||||
}
|
}
|
||||||
crossterm::execute!(
|
if let Err(e) = crossterm::execute!(
|
||||||
stderr(),
|
stderr(),
|
||||||
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES)
|
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES)
|
||||||
)?;
|
) {
|
||||||
|
warn!("Failed to enable keyboard enhancement flags: {e}");
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,7 +308,9 @@ where
|
||||||
if self.enable_mouse {
|
if self.enable_mouse {
|
||||||
crossterm::execute!(stderr(), DisableMouseCapture)?;
|
crossterm::execute!(stderr(), DisableMouseCapture)?;
|
||||||
}
|
}
|
||||||
crossterm::execute!(stderr(), PopKeyboardEnhancementFlags)?;
|
if let Err(e) = crossterm::execute!(stderr(), PopKeyboardEnhancementFlags) {
|
||||||
|
warn!("Failed to remove keyboard enhancement flags: {e}");
|
||||||
|
}
|
||||||
if self.is_fullscreen {
|
if self.is_fullscreen {
|
||||||
crossterm::execute!(stderr(), LeaveAlternateScreen, cursor::Show)?;
|
crossterm::execute!(stderr(), LeaveAlternateScreen, cursor::Show)?;
|
||||||
}
|
}
|
||||||
|
|
@ -430,11 +434,13 @@ fn set_panic_hook() {
|
||||||
/// - Escape sequences are written atomically to stderr
|
/// - Escape sequences are written atomically to stderr
|
||||||
/// - `SetConsoleMode` (used by `disable_raw_mode`) is thread-safe on Windows
|
/// - `SetConsoleMode` (used by `disable_raw_mode`) is thread-safe on Windows
|
||||||
pub(crate) fn cleanup_terminal() -> std::io::Result<()> {
|
pub(crate) fn cleanup_terminal() -> std::io::Result<()> {
|
||||||
|
if let Err(e) = crossterm::execute!(stderr(), PopKeyboardEnhancementFlags) {
|
||||||
|
warn!("Failed to remove keyboard enhancement flags: {e}");
|
||||||
|
}
|
||||||
crossterm::execute!(
|
crossterm::execute!(
|
||||||
stderr(),
|
stderr(),
|
||||||
DisableMouseCapture,
|
DisableMouseCapture,
|
||||||
DisableBracketedPaste,
|
DisableBracketedPaste,
|
||||||
PopKeyboardEnhancementFlags,
|
|
||||||
LeaveAlternateScreen,
|
LeaveAlternateScreen,
|
||||||
cursor::Show
|
cursor::Show
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue