diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ansi.rs | 40 |
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), } } |