alacritty

fork of https://github.com/jwilm/alacritty, experimental
git clone git://git.thc420.xyz/alacritty
Log | Files | Refs | README

commit d3cc9743b7cd994bc04966b4de6a87e8714a6ebb
parent 6cd0f12efb7664bb99a4b79732b8f4f63e42b033
Author: Christian Duerr <chrisduerr@users.noreply.github.com>
Date:   Sat, 15 Jun 2019 16:52:23 +0000

Fix dynamic color escape response

The dynamic color escape response would answer to requests with
rgb:0/0/0 when the color was completely black, instead of properly
responding with double-digit hex colors. This has been changed so that
Alacritty now always properly responds with the same number of hex
digits for all colors.

The number of digits has also been changed from two to four digits per
color, since that is the more commonly used format.

Using the `write!` macro was also causing problems with NeoVim,
since it caused Alacritty to write the dynamic color escape in multiple
write calls, switching to `write_all` fixed that.

Fixes #2543.

Diffstat:
Malacritty_terminal/src/term/mod.rs | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs @@ -1602,7 +1602,8 @@ impl ansi::Handler for Term { }, 6 => { let pos = self.cursor.point; - let _ = write!(writer, "\x1b[{};{}R", pos.line + 1, pos.col + 1); + let response = format!("\x1b[{};{}R", pos.line + 1, pos.col + 1); + let _ = writer.write_all(response.as_bytes()); }, _ => debug!("unknown device status query: {}", arg), }; @@ -1883,7 +1884,11 @@ impl ansi::Handler for Term { fn dynamic_color_sequence<W: io::Write>(&mut self, writer: &mut W, code: u8, index: usize) { trace!("Writing escape sequence for dynamic color code {}: color[{}]", code, index); let color = self.colors[index]; - let _ = write!(writer, "\x1b]{};rgb:{:x}/{:x}/{:x}\x07", code, color.r, color.g, color.b); + let response = format!( + "\x1b]{};rgb:{1:02x}{1:02x}/{2:02x}{2:02x}/{3:02x}{3:02x}\x07", + code, color.r, color.g, color.b + ); + let _ = writer.write_all(response.as_bytes()); } /// Reset the indexed color to original value