diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-11-17 07:13:20 +0400 |
---|---|---|
committer | Kirill Chibisov <contact@kchibisov.com> | 2023-11-23 16:28:15 +0400 |
commit | 0589b7189445e5ee236a7ab17b4f3a2047543481 (patch) | |
tree | 4e0137a2d541a7219828eecc25a42eff27271575 /alacritty_terminal | |
parent | 8240a9b90d4d4551404afaba1814982761e27a61 (diff) | |
download | alacritty-0589b7189445e5ee236a7ab17b4f3a2047543481.tar.gz alacritty-0589b7189445e5ee236a7ab17b4f3a2047543481.zip |
Add support for DECRPM/DECRQM
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index e66c914f..3df1d128 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -1922,6 +1922,58 @@ impl<T: EventListener> Handler for Term<T> { } #[inline] + fn report_private_mode(&mut self, mode: PrivateMode) { + trace!("Reporting private mode {mode:?}"); + let state = match mode { + PrivateMode::Named(mode) => match mode { + NamedPrivateMode::CursorKeys => self.mode.contains(TermMode::APP_CURSOR).into(), + NamedPrivateMode::Origin => self.mode.contains(TermMode::ORIGIN).into(), + NamedPrivateMode::LineWrap => self.mode.contains(TermMode::LINE_WRAP).into(), + NamedPrivateMode::BlinkingCursor => { + let style = self.cursor_style.get_or_insert(self.config.default_cursor_style); + style.blinking.into() + }, + NamedPrivateMode::ShowCursor => self.mode.contains(TermMode::SHOW_CURSOR).into(), + NamedPrivateMode::ReportMouseClicks => { + self.mode.contains(TermMode::MOUSE_REPORT_CLICK).into() + }, + NamedPrivateMode::ReportCellMouseMotion => { + self.mode.contains(TermMode::MOUSE_DRAG).into() + }, + NamedPrivateMode::ReportAllMouseMotion => { + self.mode.contains(TermMode::MOUSE_MOTION).into() + }, + NamedPrivateMode::ReportFocusInOut => { + self.mode.contains(TermMode::FOCUS_IN_OUT).into() + }, + NamedPrivateMode::Utf8Mouse => self.mode.contains(TermMode::UTF8_MOUSE).into(), + NamedPrivateMode::SgrMouse => self.mode.contains(TermMode::SGR_MOUSE).into(), + NamedPrivateMode::AlternateScroll => { + self.mode.contains(TermMode::ALTERNATE_SCROLL).into() + }, + NamedPrivateMode::UrgencyHints => { + self.mode.contains(TermMode::URGENCY_HINTS).into() + }, + NamedPrivateMode::SwapScreenAndSetRestoreCursor => { + self.mode.contains(TermMode::ALT_SCREEN).into() + }, + NamedPrivateMode::BracketedPaste => { + self.mode.contains(TermMode::BRACKETED_PASTE).into() + }, + NamedPrivateMode::SyncUpdate => ModeState::Reset, + NamedPrivateMode::ColumnMode => ModeState::NotSupported, + }, + PrivateMode::Unknown(_) => ModeState::NotSupported, + }; + + self.event_proxy.send_event(Event::PtyWrite(format!( + "\x1b[?{};{}$p", + mode.raw(), + state as u8, + ))); + } + + #[inline] fn set_mode(&mut self, mode: ansi::Mode) { let mode = match mode { ansi::Mode::Named(mode) => mode, @@ -1959,6 +2011,26 @@ impl<T: EventListener> Handler for Term<T> { } #[inline] + fn report_mode(&mut self, mode: ansi::Mode) { + trace!("Reporting mode {mode:?}"); + let state = match mode { + ansi::Mode::Named(mode) => match mode { + NamedMode::Insert => self.mode.contains(TermMode::INSERT).into(), + NamedMode::LineFeedNewLine => { + self.mode.contains(TermMode::LINE_FEED_NEW_LINE).into() + }, + }, + ansi::Mode::Unknown(_) => ModeState::NotSupported, + }; + + self.event_proxy.send_event(Event::PtyWrite(format!( + "\x1b[{};{}$p", + mode.raw(), + state as u8, + ))); + } + + #[inline] fn set_scrolling_region(&mut self, top: usize, bottom: Option<usize>) { // Fallback to the last line as default. let bottom = bottom.unwrap_or_else(|| self.screen_lines()); @@ -2079,6 +2151,28 @@ impl<T: EventListener> Handler for Term<T> { } } +/// The state of the [`Mode`] and [`PrivateMode`]. +#[repr(u8)] +#[derive(Debug, Clone, Copy)] +enum ModeState { + /// The mode is not supported. + NotSupported = 0, + /// The mode is currently set. + Set = 1, + /// The mode is currently not set. + Reset = 2, +} + +impl From<bool> for ModeState { + fn from(value: bool) -> Self { + if value { + Self::Set + } else { + Self::Reset + } + } +} + /// Terminal version for escape sequence reports. /// /// This returns the current terminal version as a unique number based on alacritty_terminal's |