diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-01-31 00:00:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-31 00:00:23 +0000 |
commit | 2ef5e47b8e8591d9df5e3198daad9308b7851343 (patch) | |
tree | 5c1d4b9c6f7e88380c396e638666e3b58e25f2da /alacritty_terminal | |
parent | 7f4dce2ee04859fb0b48f15cf808b60065778703 (diff) |
Mirror OSC query terminator
Fixes #3091.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/Cargo.toml | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/ansi.rs | 16 | ||||
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 16 |
3 files changed, 23 insertions, 11 deletions
diff --git a/alacritty_terminal/Cargo.toml b/alacritty_terminal/Cargo.toml index 47510dff..a4d0b044 100644 --- a/alacritty_terminal/Cargo.toml +++ b/alacritty_terminal/Cargo.toml @@ -16,7 +16,7 @@ font = { path = "../font" } parking_lot = "0.9" serde = { version = "1", features = ["derive"] } serde_yaml = "0.8" -vte = { version = "0.5.0", default-features = false } +vte = { version = "0.6.0", default-features = false } mio = "0.6.20" mio-extras = "2" log = "0.4" diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs index 94331992..bac7e0c7 100644 --- a/alacritty_terminal/src/ansi.rs +++ b/alacritty_terminal/src/ansi.rs @@ -317,7 +317,7 @@ pub trait Handler { 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) {} + fn dynamic_color_sequence<W: io::Write>(&mut self, _: &mut W, _: u8, _: usize, _: &str) {} /// Reset an indexed color to original value fn reset_color(&mut self, _: usize) {} @@ -326,7 +326,7 @@ pub trait Handler { fn set_clipboard(&mut self, _: u8, _: &[u8]) {} /// Write clipboard data to child. - fn write_clipboard<W: io::Write>(&mut self, _: u8, _: &mut W) {} + fn write_clipboard<W: io::Write>(&mut self, _: u8, _: &mut W, _: &str) {} /// Run the decaln routine. fn decaln(&mut self) {} @@ -743,8 +743,9 @@ where // TODO replace OSC parsing with parser combinators #[inline] - fn osc_dispatch(&mut self, params: &[&[u8]]) { + fn osc_dispatch(&mut self, params: &[&[u8]], bell_terminated: bool) { let writer = &mut self.writer; + let terminator = if bell_terminated { "\x07" } else { "\x1b\\" }; fn unhandled(params: &[&[u8]]) { let mut buf = String::new(); @@ -814,7 +815,12 @@ where if let Some(color) = xparse_color(param) { self.handler.set_color(index, color); } else if param == b"?" { - self.handler.dynamic_color_sequence(writer, dynamic_code, index); + self.handler.dynamic_color_sequence( + writer, + dynamic_code, + index, + terminator, + ); } else { unhandled(params); } @@ -852,7 +858,7 @@ where let clipboard = params[1].get(0).unwrap_or(&b'c'); match params[2] { - b"?" => self.handler.write_clipboard(*clipboard, writer), + b"?" => self.handler.write_clipboard(*clipboard, writer, terminator), base64 => self.handler.set_clipboard(*clipboard, base64), } }, diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index eeacbf7f..ddba07ef 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -1739,12 +1739,18 @@ impl<T: EventListener> Handler for Term<T> { /// Write a foreground/background color escape sequence with the current color #[inline] - fn dynamic_color_sequence<W: io::Write>(&mut self, writer: &mut W, code: u8, index: usize) { + fn dynamic_color_sequence<W: io::Write>( + &mut self, + writer: &mut W, + code: u8, + index: usize, + terminator: &str, + ) { trace!("Writing escape sequence for dynamic color code {}: color[{}]", code, index); let color = self.colors[index]; 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 + "\x1b]{};rgb:{1:02x}{1:02x}/{2:02x}{2:02x}/{3:02x}{3:02x}{4}", + code, color.r, color.g, color.b, terminator ); let _ = writer.write_all(response.as_bytes()); } @@ -1775,7 +1781,7 @@ impl<T: EventListener> Handler for Term<T> { /// Write clipboard data to child. #[inline] - fn write_clipboard<W: io::Write>(&mut self, clipboard: u8, writer: &mut W) { + fn write_clipboard<W: io::Write>(&mut self, clipboard: u8, writer: &mut W, terminator: &str) { let clipboard_type = match clipboard { b'c' => ClipboardType::Clipboard, b'p' | b's' => ClipboardType::Selection, @@ -1784,7 +1790,7 @@ impl<T: EventListener> Handler for Term<T> { let text = self.clipboard.load(clipboard_type); let base64 = base64::encode(&text); - let escape = format!("\x1b]52;{};{}\x07", clipboard as char, base64); + let escape = format!("\x1b]52;{};{}{}", clipboard as char, base64, terminator); let _ = writer.write_all(escape.as_bytes()); } |