summaryrefslogtreecommitdiffstats
path: root/alacritty_terminal/src
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-06-15 16:52:23 +0000
committerGitHub <noreply@github.com>2019-06-15 16:52:23 +0000
commitd3cc9743b7cd994bc04966b4de6a87e8714a6ebb (patch)
tree58dfcfdb4e301a7ff5a0f803900af9fdc139ff21 /alacritty_terminal/src
parent6cd0f12efb7664bb99a4b79732b8f4f63e42b033 (diff)
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 (limited to 'alacritty_terminal/src')
-rw-r--r--alacritty_terminal/src/term/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 5cfd503d..f936b080 100644
--- 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