diff options
author | Joe Wilm <joe@jwilm.com> | 2016-10-10 08:29:51 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-10-10 08:29:51 -0700 |
commit | f69ea009a3f539d320fa0e7780730bcd35bdf772 (patch) | |
tree | 29b73b864f95d80d7569f87c0be64906f72bbb36 /src/term.rs | |
parent | b80abe9a54acaea65c5ed4e676a9fbc8e211fd40 (diff) | |
download | r-alacritty-f69ea009a3f539d320fa0e7780730bcd35bdf772.tar.gz r-alacritty-f69ea009a3f539d320fa0e7780730bcd35bdf772.tar.bz2 r-alacritty-f69ea009a3f539d320fa0e7780730bcd35bdf772.zip |
Implement blank character insertion
This is used by things like Bash's reverse-i-search and things get
*very* messed up without it.
Diffstat (limited to 'src/term.rs')
-rw-r--r-- | src/term.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/term.rs b/src/term.rs index 92604b7a..7a80c6fb 100644 --- a/src/term.rs +++ b/src/term.rs @@ -500,8 +500,30 @@ impl ansi::Handler for Term { } #[inline] - fn insert_blank(&mut self, num: usize) { - err_println!("[unimplemented] insert_blank: {}", num); + fn insert_blank(&mut self, count: Column) { + // Ensure inserting within terminal bounds + let count = ::std::cmp::min(count, self.size_info.cols() - self.cursor.col); + + let source = self.cursor.col; + let destination = self.cursor.col + count; + let num_cells = (self.size_info.cols() - destination).0; + + let line = self.cursor.line; // borrowck + let line = &mut self.grid[line]; + + unsafe { + let src = line[source..].as_ptr(); + let dst = line[destination..].as_mut_ptr(); + + ptr::copy(src, dst, num_cells); + } + + // Cells were just moved out towards the end of the line; fill in + // between source and dest with blanks. + let template = self.template_cell.clone(); + for c in &mut line[source..destination] { + c.reset(&template); + } } #[inline] |