diff options
author | Josh Rahm <rahm@google.com> | 2025-02-05 17:34:39 -0700 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2025-02-05 17:34:39 -0700 |
commit | 6877a8d9f1e6cd44cecdfd268c804db193d7ece5 (patch) | |
tree | 73473bb8277c2ff9a341a8d32f3837cc53f91516 | |
parent | 3b3da71c34cc1256c7e20981cf03f8eb95e08ffc (diff) | |
download | r-alacritty-vte-rahm.tar.gz r-alacritty-vte-rahm.tar.bz2 r-alacritty-vte-rahm.zip |
This is a custom extension OSC 117.
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/ansi.rs | 40 |
2 files changed, 28 insertions, 16 deletions
@@ -1,7 +1,7 @@ [package] authors = ["Joe Wilm <joe@jwilm.com>", "Christian Duerr <contact@christianduerr.com>"] description = "Parser for implementing terminal emulators" -repository = "https://github.com/alacritty/vte" +repository = "git@git.josher.dev:r-alacritty-vte.git" documentation = "https://docs.rs/vte/" keywords = ["ansi", "vte", "parser", "terminal"] categories = ["parsing", "no-std"] @@ -15,7 +15,7 @@ rust-version = "1.62.1" [features] ansi = ["log", "cursor-icon", "bitflags"] -default = ["std"] +default = ["std", "ansi"] std = ["memchr/std"] serde = ["dep:serde"] diff --git a/src/ansi.rs b/src/ansi.rs index 592266e..d917804 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -727,6 +727,9 @@ pub trait Handler { /// The output is of form `CSI > 4 ; mode m`. fn report_modify_other_keys(&mut self) {} + /// Extension to call a specific script with parameters. + fn extension_script(&mut self, _params: &Vec<String>) {} + // Set SCP control. fn set_scp(&mut self, _char_path: ScpCharPath, _update_mode: ScpUpdateMode) {} } @@ -1370,21 +1373,22 @@ where } for chunk in params[1..].chunks(2) { - let index = match parse_number(chunk[0]) { - Some(index) => index, - None => { - unhandled(params); - continue; + match parse_number(chunk[0]) { + Some(index) => { + if let Some(c) = xparse_color(chunk[1]) { + self.handler.set_color(index as usize, c); + } else if chunk[1] == b"?" { + let prefix = alloc::format!("4;{index}"); + self.handler.dynamic_color_sequence( + prefix, + index as usize, + terminator, + ); + } else { + unhandled(params); + } }, - }; - - if let Some(c) = xparse_color(chunk[1]) { - self.handler.set_color(index as usize, c); - } else if chunk[1] == b"?" { - let prefix = alloc::format!("4;{index}"); - self.handler.dynamic_color_sequence(prefix, index as usize, terminator); - } else { - unhandled(params); + None => unhandled(params), } } }, @@ -1520,6 +1524,14 @@ where // Reset text cursor color. b"112" => self.handler.reset_color(NamedColor::Cursor as usize), + b"117" => { + let strvec: Vec<String> = params + .iter() + .map(|&bytes| String::from_utf8_lossy(bytes).to_string()) + .collect(); + self.handler.extension_script(&strvec) + }, + _ => unhandled(params), } } |