diff options
author | Jasper Bryant-Greene <jbg@rf.net.nz> | 2017-09-29 14:05:19 +0200 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-09-30 16:30:04 -0700 |
commit | 2bfb3f70248f3b8209917b7e0ff9a0b47459f608 (patch) | |
tree | 8e663d658fc4462bf84303af6b12b9263f1b1c4d | |
parent | 5f7885749c4d7e48869b1fc0be4d430601cdbbfa (diff) | |
download | alacritty-2bfb3f70248f3b8209917b7e0ff9a0b47459f608.tar.gz alacritty-2bfb3f70248f3b8209917b7e0ff9a0b47459f608.zip |
implement ANSI CSI REP (Repeat)
-rw-r--r-- | src/ansi.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ansi.rs b/src/ansi.rs index 9e682cd3..0e12736d 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -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)), |