diff options
author | Taylor Blau <ttaylorr@github.com> | 2020-10-10 17:24:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-10 21:24:40 +0000 |
commit | 56e0f5bb05cab709f815ef9cce027b379ce964b8 (patch) | |
tree | 997c1459bd547efd3a3486a2127d06ce63cdfa1b /alacritty_terminal | |
parent | 860adde457c64f4b0e432dd8c90d5b320f3f479f (diff) | |
download | alacritty-56e0f5bb05cab709f815ef9cce027b379ce964b8.tar.gz alacritty-56e0f5bb05cab709f815ef9cce027b379ce964b8.zip |
Add support for urgency hints CSI
Teach Alacritty to stop setting the window as urgent upon a bell by
emulating xterm's 'bellIsUrgent' resource and relevant CSI. When this
resource is enabled (with 'CSI ? 1042 h'), a bell event causes the
window to be marked as urgent. When the resource is disabled (with 'CSI
? 1042 l'), the window is not marked urgent in the event of a bell.
There are two wrinkles worth noting here:
- The 'TermMode::URGENCY_HINTS' does _not_ affect the terminal's
configured bell command, since we only want to control whether or
not the window is marked as urgent, not anything else.
- In xterm, the 'bellIsUrgent' resource is _disabled_ by default.
Since bouncing the dock icon has been the default in Alacritty on
macOS thus far, do not make an effort to change that in this patch.
This allows users to emit "\e[?1042l" and disable bouncing the dock
icon.
Fixes #2950.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/ansi.rs | 3 | ||||
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs index 91dd5f77..5c2c9e57 100644 --- a/alacritty_terminal/src/ansi.rs +++ b/alacritty_terminal/src/ansi.rs @@ -402,6 +402,8 @@ pub enum Mode { SgrMouse = 1006, /// ?1007 AlternateScroll = 1007, + /// ?1042 + UrgencyHints = 1042, /// ?1049 SwapScreenAndSetRestoreCursor = 1049, /// ?2004 @@ -434,6 +436,7 @@ impl Mode { 1005 => Mode::Utf8Mouse, 1006 => Mode::SgrMouse, 1007 => Mode::AlternateScroll, + 1042 => Mode::UrgencyHints, 1049 => Mode::SwapScreenAndSetRestoreCursor, 2004 => Mode::BracketedPaste, _ => { diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index a33ac919..59549106 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -480,13 +480,17 @@ pub mod mode { const UTF8_MOUSE = 0b0000_0100_0000_0000_0000; const ALTERNATE_SCROLL = 0b0000_1000_0000_0000_0000; const VI = 0b0001_0000_0000_0000_0000; + const URGENCY_HINTS = 0b0010_0000_0000_0000_0000; const ANY = std::u32::MAX; } } impl Default for TermMode { fn default() -> TermMode { - TermMode::SHOW_CURSOR | TermMode::LINE_WRAP | TermMode::ALTERNATE_SCROLL + TermMode::SHOW_CURSOR + | TermMode::LINE_WRAP + | TermMode::ALTERNATE_SCROLL + | TermMode::URGENCY_HINTS } } } @@ -2132,6 +2136,7 @@ impl<T: EventListener> Handler for Term<T> { fn set_mode(&mut self, mode: ansi::Mode) { trace!("Setting mode: {:?}", mode); match mode { + ansi::Mode::UrgencyHints => self.mode.insert(TermMode::URGENCY_HINTS), ansi::Mode::SwapScreenAndSetRestoreCursor => { if !self.mode.contains(TermMode::ALT_SCREEN) { self.swap_alt(); @@ -2182,6 +2187,7 @@ impl<T: EventListener> Handler for Term<T> { fn unset_mode(&mut self, mode: ansi::Mode) { trace!("Unsetting mode: {:?}", mode); match mode { + ansi::Mode::UrgencyHints => self.mode.remove(TermMode::URGENCY_HINTS), ansi::Mode::SwapScreenAndSetRestoreCursor => { if self.mode.contains(TermMode::ALT_SCREEN) { self.swap_alt(); |