From 47ccbdcec555e14bec7df71b2054cc11bd05ccf8 Mon Sep 17 00:00:00 2001 From: daa Date: Sat, 9 Sep 2017 22:44:28 +0300 Subject: [PATCH] Fix repaint issue --- src/shell.rs | 9 ++++++--- src/ui_model/line.rs | 19 ++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/shell.rs b/src/shell.rs index 011f4da..0209c73 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -575,6 +575,7 @@ fn gtk_draw(state_arc: &Arc>, ctx: &cairo::Context) -> Inhibit { let mut state = state_arc.borrow_mut(); if state.nvim.borrow().is_initialized() { + request_window_resize(&mut *state); render::render( ctx, state.cursor.as_ref().unwrap(), @@ -583,7 +584,6 @@ fn gtk_draw(state_arc: &Arc>, ctx: &cairo::Context) -> Inhibit { &state.color_model, &state.mode, ); - request_window_resize(&mut *state); } else if state.nvim.borrow().is_initializing() { draw_initializing(&*state, ctx); } @@ -995,12 +995,15 @@ impl RedrawEvents for State { fn on_resize(&mut self, columns: u64, rows: u64) -> RepaintMode { self.model = UiModel::new(rows, columns); self.request_resize(); - RepaintMode::All + RepaintMode::Nothing } fn on_redraw(&mut self, mode: &RepaintMode) { match *mode { - RepaintMode::All => self.drawing_area.queue_draw(), + RepaintMode::All => { + self.update_dirty_glyphs(); + self.drawing_area.queue_draw(); + }, RepaintMode::Area(ref rect) => self.queue_draw_area(&[rect]), RepaintMode::AreaList(ref list) => self.queue_draw_area(&list.list), RepaintMode::Nothing => (), diff --git a/src/ui_model/line.rs b/src/ui_model/line.rs index b3b2cd6..29841e9 100644 --- a/src/ui_model/line.rs +++ b/src/ui_model/line.rs @@ -20,18 +20,9 @@ pub struct Line { impl Line { pub fn new(columns: usize) -> Self { - let mut line = Vec::with_capacity(columns); - for _ in 0..columns { - line.push(Cell::new(' ')); - } - let mut item_line = Vec::with_capacity(columns); - for _ in 0..columns { - item_line.push(None); - } - Line { - line: line.into_boxed_slice(), - item_line: item_line.into_boxed_slice(), + line: vec![Cell::new(' '); columns].into_boxed_slice(), + item_line: vec![None; columns].into_boxed_slice(), cell_to_item: vec![-1; columns].into_boxed_slice(), dirty_line: true, } @@ -48,6 +39,12 @@ impl Line { for cell in &mut self.line[left..right + 1] { cell.clear(); } + for item in &mut self.item_line[left..right + 1] { + item.clone_from(&None); + } + for i in left..right + 1 { + self.cell_to_item[i] = -1; + } self.dirty_line = true; }