diff options
author | rbong <rbong@users.noreply.github.com> | 2019-06-02 09:16:38 -0400 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-06-02 13:16:38 +0000 |
commit | f79007035ccc8d52f5f491d35d3d4132aa29898d (patch) | |
tree | b48daf6974d0ad6bd2411ca41c08481a0369f371 /alacritty_terminal/src/ansi.rs | |
parent | dea7a0890a724c50bc5767039f45a2e3d071ee1c (diff) | |
download | alacritty-f79007035ccc8d52f5f491d35d3d4132aa29898d.tar.gz alacritty-f79007035ccc8d52f5f491d35d3d4132aa29898d.zip |
Add foreground/background request escape codes
Diffstat (limited to 'alacritty_terminal/src/ansi.rs')
-rw-r--r-- | alacritty_terminal/src/ansi.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs index c0ebb79c..bff59de5 100644 --- a/alacritty_terminal/src/ansi.rs +++ b/alacritty_terminal/src/ansi.rs @@ -332,6 +332,9 @@ pub trait Handler { /// Set an indexed color value fn set_color(&mut self, _: usize, _: Rgb) {} + /// Write a foreground/background color escape sequence with the current color + fn dynamic_color_sequence<W: io::Write>(&mut self, _: &mut W, _: u8, _: usize) {} + /// Reset an indexed color to original value fn reset_color(&mut self, _: usize) {} @@ -741,6 +744,8 @@ where // TODO replace OSC parsing with parser combinators #[inline] fn osc_dispatch(&mut self, params: &[&[u8]]) { + let writer = &mut self.writer; + fn unhandled(params: &[&[u8]]) { let mut buf = String::new(); for items in params { @@ -788,23 +793,37 @@ where unhandled(params); }, - // Set foreground color + // Get/set foreground color b"10" => { if params.len() >= 2 { if let Some(color) = parse_rgb_color(params[1]) { self.handler.set_color(NamedColor::Foreground as usize, color); return; + } else if params[1] == b"?" { + self.handler.dynamic_color_sequence( + writer, + 10, + NamedColor::Foreground as usize, + ); + return; } } unhandled(params); }, - // Set background color + // Get/set background color b"11" => { if params.len() >= 2 { if let Some(color) = parse_rgb_color(params[1]) { self.handler.set_color(NamedColor::Background as usize, color); return; + } else if params[1] == b"?" { + self.handler.dynamic_color_sequence( + writer, + 11, + NamedColor::Background as usize, + ); + return; } } unhandled(params); |