summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <ttaylorr@github.com>2020-10-10 17:24:40 -0400
committerGitHub <noreply@github.com>2020-10-10 21:24:40 +0000
commit56e0f5bb05cab709f815ef9cce027b379ce964b8 (patch)
tree997c1459bd547efd3a3486a2127d06ce63cdfa1b
parent860adde457c64f4b0e432dd8c90d5b320f3f479f (diff)
downloadalacritty-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.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/event.rs4
-rw-r--r--alacritty_terminal/src/ansi.rs3
-rw-r--r--alacritty_terminal/src/term/mod.rs8
-rw-r--r--docs/escape_support.md3
5 files changed, 16 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5aa9806d..a849fbc6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Escape sequences to report text area size in pixels (`CSI 14 t`) and in characters (`CSI 18 t`)
- Support for single line terminals dimensions
- Right clicking on Wayland's client side decorations will show application menu
+- Escape sequences to enable and disable window urgency hints (`CSI ? 1042 h`, `CSI ? 1042 l`)
### Changed
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index e45795dd..a4437f6f 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -943,7 +943,9 @@ impl<N: Notify + OnResize> Processor<N> {
TerminalEvent::Bell => {
let bell_command = processor.ctx.config.bell().command.as_ref();
let _ = bell_command.map(|cmd| start_daemon(cmd.program(), cmd.args()));
- processor.ctx.window.set_urgent(!processor.ctx.terminal.is_focused);
+ if processor.ctx.terminal.mode().contains(TermMode::URGENCY_HINTS) {
+ processor.ctx.window.set_urgent(!processor.ctx.terminal.is_focused);
+ }
},
TerminalEvent::ClipboardStore(clipboard_type, content) => {
processor.ctx.clipboard.store(clipboard_type, content);
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();
diff --git a/docs/escape_support.md b/docs/escape_support.md
index 64ffef89..f1a0337c 100644
--- a/docs/escape_support.md
+++ b/docs/escape_support.md
@@ -56,7 +56,8 @@ brevity.
| `CSI h` | PARTIAL | Only modes `4` and `20` are supported |
| `CSI ? h` | PARTIAL | Supported modes: |
| | | `1`, `3`, `6`, `7`, `12`, `25`, `1000`, `1002` |
-| | | `1004`, `1005`, `1006`, `1007`, `1049`, `2004` |
+| | | `1004`, `1005`, `1006`, `1007`, `1042`, `1049` |
+| | | `2004` |
| `CSI I` | IMPLEMENTED | |
| `CSI J` | IMPLEMENTED | |
| `CSI K` | IMPLEMENTED | |