aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2025-02-05 17:34:39 -0700
committerJosh Rahm <rahm@google.com>2025-02-05 17:34:39 -0700
commit6877a8d9f1e6cd44cecdfd268c804db193d7ece5 (patch)
tree73473bb8277c2ff9a341a8d32f3837cc53f91516 /src
parent3b3da71c34cc1256c7e20981cf03f8eb95e08ffc (diff)
downloadr-alacritty-vte-rahm.tar.gz
r-alacritty-vte-rahm.tar.bz2
r-alacritty-vte-rahm.zip
Add additional arbitrary script handler.HEADrahm
This is a custom extension OSC 117.
Diffstat (limited to 'src')
-rw-r--r--src/ansi.rs40
1 files changed, 26 insertions, 14 deletions
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),
}
}