only update terminal update area

This commit is contained in:
Dongdong Zhou 2021-10-17 23:28:28 +01:00
parent 0ff6b4534f
commit 155ba654c0
1 changed files with 23 additions and 7 deletions

View File

@ -282,8 +282,22 @@ pub fn run(&mut self, receiver: Receiver<TerminalEvent>) -> Result<()> {
}
alacritty_terminal::event::Event::CursorBlinkingChange(_) => {}
alacritty_terminal::event::Event::Wakeup => {
let mut cells = Vec::new();
for cell in self.term.grid().display_iter() {
let c = cell.cell.c;
if c != ' '
&& c != '\t'
&& cell.bg
== ansi::Color::Named(
ansi::NamedColor::Background,
)
{
cells.push((cell.point.clone(), cell.cell.clone()));
}
}
let content = Arc::new(TerminalContent {
grid: self.term.grid().clone(),
cells,
cursor_point: self.term.grid().cursor.point,
});
self.event_sink.submit_command(
LAPCE_UI_COMMAND,
@ -573,7 +587,7 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
let terminal = data.terminal.terminals.get(&self.term_id).unwrap();
let cursor_point = &terminal.content.grid.cursor.point;
let cursor_point = &terminal.content.cursor_point;
let rect =
Size::new(char_width, line_height)
.to_rect()
@ -594,9 +608,9 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
);
}
for cell in terminal.content.grid.display_iter() {
let x = cell.point.column.0 as f64 * char_width;
let y = cell.point.line.0 as f64 * line_height + y_shift;
for (point, cell) in &terminal.content.cells {
let x = point.column.0 as f64 * char_width;
let y = point.line.0 as f64 * line_height + y_shift;
let text_layout = ctx
.text()
.new_text_layout(cell.c.to_string())
@ -709,13 +723,15 @@ pub enum TerminalHostEvent {
#[derive(Debug)]
pub struct TerminalContent {
grid: Grid<Cell>,
cells: Vec<(alacritty_terminal::index::Point, Cell)>,
cursor_point: alacritty_terminal::index::Point,
}
impl TerminalContent {
pub fn new() -> Self {
Self {
grid: Grid::new(1, 1, 0),
cells: Vec::new(),
cursor_point: alacritty_terminal::index::Point::default(),
}
}
}