mirror of
https://github.com/alacritty/alacritty.git
synced 2025-04-14 17:53:03 -04:00
Implement delete_chars
Among other issues, this fixes a very vissible issue with typing in the middle of a shell command.
This commit is contained in:
parent
6c9989819b
commit
c5bc39fe26
1 changed files with 24 additions and 1 deletions
25
src/term.rs
25
src/term.rs
|
@ -15,6 +15,7 @@
|
|||
//! Exports the `Term` type which is a high-level API for the Grid
|
||||
use std::mem;
|
||||
use std::ops::{Deref, Range};
|
||||
use std::ptr;
|
||||
|
||||
use ansi::{self, Attr, Handler};
|
||||
use grid::{Grid, ClearRegion};
|
||||
|
@ -651,7 +652,29 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn delete_chars(&mut self, count: Column) {
|
||||
err_println!("[unimplemented] delete_chars: {}", count);
|
||||
// Ensure deleting within terminal bounds
|
||||
let count = ::std::cmp::min(count, self.size_info.cols());
|
||||
|
||||
let start = self.cursor.col;
|
||||
let end = self.cursor.col + count;
|
||||
let n = (self.size_info.cols() - end).0;
|
||||
|
||||
let line = self.cursor.line; // borrowck
|
||||
let line = &mut self.grid[line];
|
||||
|
||||
unsafe {
|
||||
let src = line[end..].as_ptr();
|
||||
let dst = line[start..].as_mut_ptr();
|
||||
|
||||
ptr::copy(src, dst, n);
|
||||
}
|
||||
|
||||
// Clear last `count` cells in line. If deleting 1 char, need to delete 1 cell.
|
||||
let template = self.template_cell.clone();
|
||||
let end = self.size_info.cols() - count;
|
||||
for c in &mut line[end..] {
|
||||
c.reset(&template);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Reference in a new issue