1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

implement ANSI CSI REP (Repeat)

This commit is contained in:
Jasper Bryant-Greene 2017-09-29 14:05:19 +02:00 committed by Joe Wilm
parent 5f7885749c
commit 2bfb3f7024

View file

@ -85,7 +85,9 @@ pub struct Processor {
}
/// Internal state for VTE processor
struct ProcessorState;
struct ProcessorState {
preceding_char: Option<char>
}
/// Helper type that implements `vte::Perform`.
///
@ -116,7 +118,7 @@ impl<'a, H: Handler + TermInfo + 'a, W: io::Write> Performer<'a, H, W> {
impl Default for Processor {
fn default() -> Processor {
Processor {
state: ProcessorState,
state: ProcessorState { preceding_char: None },
parser: vte::Parser::new(),
}
}
@ -652,6 +654,7 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
#[inline]
fn print(&mut self, c: char) {
self.handler.input(c);
self._state.preceding_char = Some(c);
}
#[inline]
@ -841,6 +844,16 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
'A' => {
handler.move_up(Line(arg_or_default!(idx: 0, default: 1) as usize));
},
'b' => {
if let Some(c) = self._state.preceding_char {
for _ in 0..arg_or_default!(idx: 0, default: 1) {
handler.input(c);
}
}
else {
warn!("tried to repeat with no preceding char");
}
},
'B' | 'e' => handler.move_down(Line(arg_or_default!(idx: 0, default: 1) as usize)),
'c' => handler.identify_terminal(writer),
'C' | 'a' => handler.move_forward(Column(arg_or_default!(idx: 0, default: 1) as usize)),