diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-19 14:24:30 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-19 14:24:30 +0300 |
| commit | d616bcd6b86742762fec5f0696a5c13701fe717c (patch) | |
| tree | 44e20df741c3c587168a351e422a67ede524ca2d /src/main.rs | |
| parent | 6cbdba434fd15fc3818302a5843593da47db2eb4 (diff) | |
fix: preserve modified enter input
refs #168
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index efdd08b0..744d4368 100644 --- a/src/main.rs +++ b/src/main.rs @@ -453,13 +453,17 @@ fn main() -> io::Result<()> { Err(err) => return Err(err), }; - let in_tmux = std::env::var("TMUX").is_ok(); + let modify_other_keys_mode = crate::input::host_modify_other_keys_mode( + std::env::var("TMUX").is_ok(), + std::env::var("TERM_PROGRAM").ok().as_deref(), + std::env::var_os("WEZTERM_PANE").is_some(), + ); let original_hook = std::panic::take_hook(); - let panic_in_tmux = in_tmux; + let panic_resets_modify_other_keys = modify_other_keys_mode.is_some(); std::panic::set_hook(Box::new(move |info| { tracing::error!("PANIC: {info}"); - if panic_in_tmux { + if panic_resets_modify_other_keys { let _ = std::io::Write::write_all(&mut io::stdout(), b"\x1b[>4;0m"); } if crate::kitty_graphics::is_enabled() { @@ -503,12 +507,12 @@ fn main() -> io::Result<()> { PushKeyboardEnhancementFlags(crate::input::ime_compatible_keyboard_enhancement_flags()) )?; - // tmux doesn't understand kitty keyboard protocol push (\e[>1u). - // It uses modifyOtherKeys mode to send CSI u sequences for modified keys. - // Enable modifyOtherKeys mode 2 so tmux sends Shift+Enter as \e[13;2u etc. - if in_tmux { + // Some hosts do not honor Kitty keyboard enhancement pushes for + // Shift+Enter. Enable xterm modifyOtherKeys only on hosts where we + // know it is needed and parseable, so modified Enter stays distinct. + if let Some(mode) = modify_other_keys_mode { use std::io::Write; - std::io::stdout().write_all(b"\x1b[>4;2m")?; + std::io::stdout().write_all(mode.set_sequence())?; std::io::stdout().flush()?; } @@ -524,8 +528,8 @@ fn main() -> io::Result<()> { ); let result = app.run(&mut terminal).await; - // Reset modifyOtherKeys if we enabled it - if in_tmux { + // Reset modifyOtherKeys if we enabled it. + if modify_other_keys_mode.is_some() { use std::io::Write; std::io::stdout().write_all(b"\x1b[>4;0m")?; std::io::stdout().flush()?; |
