diff options
author | Mohammad AlSaleh <CE.Mohammad.Alsaleh@gmail.com> | 2024-04-01 15:38:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-01 12:38:46 +0000 |
commit | a971e86f8545cd4fe9ed4fd28e31758e9460c6ed (patch) | |
tree | 3b20fc5ddae95f261e470220153ee2ea32ff4f81 | |
parent | ed51aa19b7ad060f62a75ec55ebb802ced850b1a (diff) | |
download | r-alacritty-vte-a971e86f8545cd4fe9ed4fd28e31758e9460c6ed.tar.gz r-alacritty-vte-a971e86f8545cd4fe9ed4fd28e31758e9460c6ed.tar.bz2 r-alacritty-vte-a971e86f8545cd4fe9ed4fd28e31758e9460c6ed.zip |
Add SCP control support
Modern usage of this control function comes from the BiDi draft
proposal:
https://terminal-wg.pages.freedesktop.org/bidi/recommendation/escape-sequences.html
The draft slightly extends the definition in ECMA-48.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
-rw-r--r-- | src/ansi.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/ansi.rs b/src/ansi.rs index e5011e9..59b17e6 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -677,6 +677,9 @@ pub trait Handler { /// /// The output is of form `CSI > 4 ; mode m`. fn report_modify_other_keys(&mut self) {} + + // Set SCP control. + fn set_scp(&mut self, _char_path: ScpCharPath, _update_mode: ScpUpdateMode) {} } bitflags! { @@ -1195,6 +1198,32 @@ impl StandardCharset { } } +/// SCP control's first parameter which determines character path. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum ScpCharPath { + /// SCP's first parameter value of 0. Behavior is implementation defined. + Default, + /// SCP's first parameter value of 1 which sets character path to LEFT-TO-RIGHT. + LTR, + /// SCP's first parameter value of 2 which sets character path to RIGHT-TO-LEFT. + RTL, +} + +/// SCP control's second parameter which determines update mode/direction between components. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum ScpUpdateMode { + /// SCP's second parameter value of 0 (the default). Implementation dependant update. + ImplementationDependant, + /// SCP's second parameter value of 1. + /// + /// Reflect data component changes in the presentation component. + DataToPresentation, + /// SCP's second parameter value of 2. + /// + /// Reflect presentation component changes in the data component. + PresentationToData, +} + impl<'a, H, T> crate::Perform for Performer<'a, H, T> where H: Handler + 'a, @@ -1551,6 +1580,30 @@ where handler.clear_line(mode); }, + ('k', [b' ']) => { + // SCP control. + let char_path = match next_param_or(0) { + 0 => ScpCharPath::Default, + 1 => ScpCharPath::LTR, + 2 => ScpCharPath::RTL, + _ => { + unhandled!(); + return; + }, + }; + + let update_mode = match next_param_or(0) { + 0 => ScpUpdateMode::ImplementationDependant, + 1 => ScpUpdateMode::DataToPresentation, + 2 => ScpUpdateMode::PresentationToData, + _ => { + unhandled!(); + return; + }, + }; + + handler.set_scp(char_path, update_mode); + }, ('L', []) => handler.insert_blank_lines(next_param_or(1) as usize), ('l', []) => { for param in params_iter.map(|param| param[0]) { |