From 155ba654c0f03cd08f0b1be9b8e577595a98b685 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Sun, 17 Oct 2021 23:28:28 +0100 Subject: [PATCH] only update terminal update area --- core/src/terminal.rs | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/core/src/terminal.rs b/core/src/terminal.rs index 80bd7736..516b2ac8 100644 --- a/core/src/terminal.rs +++ b/core/src/terminal.rs @@ -282,8 +282,22 @@ pub fn run(&mut self, receiver: Receiver) -> 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, + 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(), } } }