diff options
author | Christian Duerr <contact@christianduerr.com> | 2024-09-22 16:34:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-22 14:34:14 +0000 |
commit | c74b5fa857a133298f0207c499c47cb95b27c78c (patch) | |
tree | c915fdab4cb4dd9d700c4250a078c8341f735a25 | |
parent | 8dfd2e56ad7aaeaf09aaf9f680420cc5988155b0 (diff) | |
download | alacritty-c74b5fa857a133298f0207c499c47cb95b27c78c.tar.gz alacritty-c74b5fa857a133298f0207c499c47cb95b27c78c.zip |
Ignore cursor color request with default colors
Currently when the cursor colors are requested for the default cursor
color, Alacritty always responds with #000000. Since this is most likely
incorrect, this response is misleading.
Realistically there's very little reason why any application would need
to know the color of the (often dynamically changing) default cursor. So
instead of always reporting an incorrect black value, this patch just
stops reporting values unless the cursor color was explicitly changed.
Closes #8169.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty/src/event.rs | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 20df64f0..38584ca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ Notable changes to the `alacritty_terminal` crate are documented in its - Kitty keyboard protocol reporting shifted key codes - Broken search with words broken across line boundary on the first character - Config import changes not being live reloaded +- Cursor color requests with default cursor colors ## 0.13.2 diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 72009d88..f10346af 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -34,6 +34,7 @@ use alacritty_terminal::index::{Boundary, Column, Direction, Line, Point, Side}; use alacritty_terminal::selection::{Selection, SelectionType}; use alacritty_terminal::term::search::{Match, RegexSearch}; use alacritty_terminal::term::{self, ClipboardType, Term, TermMode}; +use alacritty_terminal::vte::ansi::NamedColor; #[cfg(unix)] use crate::cli::{IpcConfig, ParsedOptions}; @@ -1737,9 +1738,12 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> { } }, TerminalEvent::ColorRequest(index, format) => { - let color = self.ctx.terminal().colors()[index] - .map(Rgb) - .unwrap_or(self.ctx.display.colors[index]); + let color = match self.ctx.terminal().colors()[index] { + Some(color) => Rgb(color), + // Ignore cursor color requests unless it was changed. + None if index == NamedColor::Cursor as usize => return, + None => self.ctx.display.colors[index], + }; self.ctx.write_to_pty(format(color.0).into_bytes()); }, TerminalEvent::TextAreaSizeRequest(format) => { |