diff --git a/config/src/config.rs b/config/src/config.rs index 95e68779e..cc2f6a16d 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -77,6 +77,9 @@ pub struct Config { #[dynamic(default)] pub window_decorations: WindowDecorations, + #[dynamic(default)] + pub log_unknown_escape_sequences: bool, + /// When using FontKitXXX font systems, a set of directories to /// search ahead of the standard font locations for fonts. /// Relative paths are taken to be relative to the directory diff --git a/config/src/terminal.rs b/config/src/terminal.rs index c38b55f76..607f5099c 100644 --- a/config/src/terminal.rs +++ b/config/src/terminal.rs @@ -101,6 +101,10 @@ impl wezterm_term::TerminalConfiguration for TermConfig { self.configuration().debug_key_events } + fn log_unknown_escape_sequences(&self) -> bool { + self.configuration().log_unknown_escape_sequences + } + fn normalize_output_to_unicode_nfc(&self) -> bool { self.configuration().normalize_output_to_unicode_nfc } diff --git a/docs/config/lua/config/log_unknown_escape_sequences.md b/docs/config/lua/config/log_unknown_escape_sequences.md new file mode 100644 index 000000000..7fff7c077 --- /dev/null +++ b/docs/config/lua/config/log_unknown_escape_sequences.md @@ -0,0 +1,12 @@ +# `log_unknown_escape_sequences = false` + +*Since nightly builds only* + +When set to true, wezterm will log warnings when it receives escape +sequences which it does not understand. Those warnings are harmless +and are useful primarily by the maintainer to discover new and +interesting escape sequences. + +In previous versions, there was no option to control this, +and wezterm would always log warnings for unknown escape +sequences. diff --git a/mux/src/localpane.rs b/mux/src/localpane.rs index ac86ea6e2..8bcab020a 100644 --- a/mux/src/localpane.rs +++ b/mux/src/localpane.rs @@ -804,7 +804,7 @@ impl wezterm_term::DeviceControlHandler for LocalPaneDCSHandler { // TODO: do we need to proactively list available tabs here? // if so we should arrange to call domain.attach() and make // it do the right thing. - } else { + } else if configuration().log_unknown_escape_sequences { log::warn!("unknown DeviceControlMode::Enter {:?}", mode,); } } @@ -819,11 +819,13 @@ impl wezterm_term::DeviceControlHandler for LocalPaneDCSHandler { } } DeviceControlMode::Data(c) => { - log::warn!( - "unhandled DeviceControlMode::Data {:x} {}", - c, - (c as char).escape_debug() - ); + if configuration().log_unknown_escape_sequences { + log::warn!( + "unhandled DeviceControlMode::Data {:x} {}", + c, + (c as char).escape_debug() + ); + } } DeviceControlMode::TmuxEvents(events) => { if let Some(tmux) = self.tmux_domain.as_ref() { @@ -833,7 +835,9 @@ impl wezterm_term::DeviceControlHandler for LocalPaneDCSHandler { } } _ => { - log::warn!("unhandled: {:?}", control); + if configuration().log_unknown_escape_sequences { + log::warn!("unhandled: {:?}", control); + } } } } diff --git a/term/src/config.rs b/term/src/config.rs index 4519b0edd..b5a28ebff 100644 --- a/term/src/config.rs +++ b/term/src/config.rs @@ -217,6 +217,10 @@ pub trait TerminalConfiguration: std::fmt::Debug + Send + Sync { fn enable_title_reporting(&self) -> bool { false } + + fn log_unknown_escape_sequences(&self) -> bool { + false + } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/term/src/terminalstate/performer.rs b/term/src/terminalstate/performer.rs index 19847d0d4..9ffcfe050 100644 --- a/term/src/terminalstate/performer.rs +++ b/term/src/terminalstate/performer.rs @@ -297,19 +297,29 @@ impl<'a> Performer<'a> { self.writer.flush().ok(); } _ => { - log::warn!("unhandled DECRQSS {:?}", s); + if self.config.log_unknown_escape_sequences() { + log::warn!("unhandled DECRQSS {:?}", s); + } // Reply that the request is invalid write!(self.writer, "{}0$r{}", DCS, ST).ok(); self.writer.flush().ok(); } } } - _ => log::warn!("unhandled {:?}", s), + _ => { + if self.config.log_unknown_escape_sequences() { + log::warn!("unhandled {:?}", s); + } + } } } _ => match self.device_control_handler.as_mut() { Some(handler) => handler.handle_device_control(ctrl), - None => log::warn!("unhandled {:?}", ctrl), + None => { + if self.config.log_unknown_escape_sequences() { + log::warn!("unhandled {:?}", ctrl); + } + } }, } } @@ -432,7 +442,11 @@ impl<'a> Performer<'a> { ControlCode::Null => {} - _ => log::warn!("unhandled ControlCode {:?}", control), + _ => { + if self.config.log_unknown_escape_sequences() { + log::warn!("unhandled ControlCode {:?}", control); + } + } } } @@ -523,7 +537,9 @@ impl<'a> Performer<'a> { // to receive it. Just ignore it. } CSI::Unspecified(unspec) => { - log::warn!("unknown unspecified CSI: {:?}", format!("{}", unspec)) + if self.config.log_unknown_escape_sequences() { + log::warn!("unknown unspecified CSI: {:?}", format!("{}", unspec)); + } } }; } @@ -670,7 +686,11 @@ impl<'a> Performer<'a> { } } - _ => log::warn!("ESC: unhandled {:?}", esc), + _ => { + if self.config.log_unknown_escape_sequences() { + log::warn!("ESC: unhandled {:?}", esc); + } + } } } @@ -790,7 +810,11 @@ impl<'a> Performer<'a> { } } } - _ => log::warn!("unhandled iterm2: {:?}", iterm), + _ => { + if self.config.log_unknown_escape_sequences() { + log::warn!("unhandled iterm2: {:?}", iterm); + } + } }, OperatingSystemCommand::FinalTermSemanticPrompt(FinalTermSemanticPrompt::FreshLine) => {