mirror of
https://github.com/wez/wezterm.git
synced 2024-09-11 14:25:57 +03:00
termwiz/unix: restore keyboard encoding on cooked mode
Don't override saved encoding
This commit is contained in:
parent
c058178604
commit
0bc975e557
@ -333,6 +333,12 @@ impl UnixTerminal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Restores the keyboard encoding to its original state, if it had been changed
|
||||||
|
pub fn restore_keyboard_encoding(&mut self) -> Result<()> {
|
||||||
|
self.saved_keyboard_encoding
|
||||||
|
.map_or(Ok(()), |enc| self.set_keyboard_encoding(enc))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -381,7 +387,10 @@ impl Terminal for UnixTerminal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.caps.probe_for_enhanced_keyboard() && self.keyboard_enhancement_supported()? {
|
if self.caps.probe_for_enhanced_keyboard() && self.keyboard_enhancement_supported()? {
|
||||||
self.saved_keyboard_encoding = Some(self.get_keyboard_encoding()?);
|
if self.saved_keyboard_encoding.is_none() {
|
||||||
|
// don't override the original state if this is called multiple times
|
||||||
|
self.saved_keyboard_encoding = Some(self.get_keyboard_encoding()?);
|
||||||
|
}
|
||||||
self.set_keyboard_encoding(KeyboardEncoding::Kitty(KittyKeyboardFlags::all()))?;
|
self.set_keyboard_encoding(KeyboardEncoding::Kitty(KittyKeyboardFlags::all()))?;
|
||||||
} else {
|
} else {
|
||||||
self.write
|
self.write
|
||||||
@ -393,6 +402,7 @@ impl Terminal for UnixTerminal {
|
|||||||
fn set_cooked_mode(&mut self) -> Result<()> {
|
fn set_cooked_mode(&mut self) -> Result<()> {
|
||||||
self.write
|
self.write
|
||||||
.modify_other_keys(XtermModifyOtherKeys::Partial)?;
|
.modify_other_keys(XtermModifyOtherKeys::Partial)?;
|
||||||
|
self.restore_keyboard_encoding()?;
|
||||||
// FIXME: this only works if the original mode was cooked.
|
// FIXME: this only works if the original mode was cooked.
|
||||||
// There's no `termios::cfmakesane()`, so we'd have to set the flags manually
|
// There's no `termios::cfmakesane()`, so we'd have to set the flags manually
|
||||||
self.write.restore_termios()
|
self.write.restore_termios()
|
||||||
@ -607,9 +617,7 @@ impl Drop for UnixTerminal {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(keyboard_encoding) = self.saved_keyboard_encoding {
|
self.restore_keyboard_encoding().unwrap();
|
||||||
self.set_keyboard_encoding(keyboard_encoding).unwrap();
|
|
||||||
}
|
|
||||||
self.render(&[Change::CursorVisibility(
|
self.render(&[Change::CursorVisibility(
|
||||||
crate::surface::CursorVisibility::Visible,
|
crate::surface::CursorVisibility::Visible,
|
||||||
)])
|
)])
|
||||||
@ -621,9 +629,6 @@ impl Drop for UnixTerminal {
|
|||||||
decreset!(SGRMouse);
|
decreset!(SGRMouse);
|
||||||
decreset!(AnyEventMouse);
|
decreset!(AnyEventMouse);
|
||||||
}
|
}
|
||||||
if self.caps.probe_for_enhanced_keyboard() {
|
|
||||||
write!(self.write, "{}", CSI::Keyboard(Keyboard::PopKittyState(1))).unwrap();
|
|
||||||
}
|
|
||||||
self.write
|
self.write
|
||||||
.modify_other_keys(XtermModifyOtherKeys::Disabled)
|
.modify_other_keys(XtermModifyOtherKeys::Disabled)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user