diff --git a/src/render/mod.rs b/src/render/mod.rs index 50f75e2..6bb88ce 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -78,22 +78,3 @@ pub fn shape_dirty(ctx: &context::Context, ui_model: &mut ui_model::UiModel) { } } -//pub fn render_test(ctx: &cairo::Context, font_desc: pango::FontDescription) { -//let font_map = FontMap::get_default(); -//let pango_context = font_map.create_context().unwrap(); -//pango_context.set_font_description(&font_desc); - -//let text = "TEST String".to_owned(); -//let attr_list = pango::AttrList::new(); - -//ctx.move_to(0.0, 50.0); -//let items = pango_itemize(&pango_context, &text, &attr_list); -//for item in items { -//let mut glyphs = pango::GlyphString::new(); -//let analysis = item.analysis(); -//pango_shape(&text, &analysis, &mut glyphs); -//let font = analysis.font(); -//let (ink, logical) = glyphs.extents(&font); -//ctx.show_glyph_string(&font, &glyphs); -//} -//} diff --git a/src/shell.rs b/src/shell.rs index 894c7d5..5f09e3f 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -154,6 +154,7 @@ impl State { self.font_desc = FontDescription::from_string(desc); self.line_height = None; self.char_width = None; + self.model.clear_draw_cache(); } pub fn open_file(&self, path: &str) { @@ -608,7 +609,6 @@ fn gtk_draw(state_arc: &Arc>, ctx: &cairo::Context) -> Inhibit { let mut state = state_arc.borrow_mut(); if state.nvim.borrow().is_initialized() { - // draw(&*state, ctx); render(&mut *state, ctx); request_window_resize(&mut *state); } else if state.nvim.borrow().is_initializing() { @@ -792,7 +792,7 @@ fn draw_initializing(state: &State, ctx: &cairo::Context) { ctx.paint(); layout.set_font_description(&desc); - layout.set_text("Loading.."); + layout.set_text("Loading->"); let (width, height) = layout.get_pixel_size(); let x = alloc.width as f64 / 2.0 - width as f64 / 2.0; diff --git a/src/ui_model/line.rs b/src/ui_model/line.rs index ea0fa1e..ac04013 100644 --- a/src/ui_model/line.rs +++ b/src/ui_model/line.rs @@ -89,6 +89,14 @@ impl Line { self.dirty_line = true; } + pub fn clear_draw_cache(&mut self) { + for i in 0..self.item_line.len() { + self.item_line[i] = None; + self.cell_to_item[i] = -1; + } + self.dirty_line = true; + } + fn set_cell_to_empty(&mut self, cell_idx: usize) -> bool { if self.item_line[cell_idx].is_some() { self.item_line[cell_idx] = None; diff --git a/src/ui_model/mod.rs b/src/ui_model/mod.rs index 342fa64..fd07fb1 100644 --- a/src/ui_model/mod.rs +++ b/src/ui_model/mod.rs @@ -182,6 +182,12 @@ impl UiModel { row.clear(left, right); } } + + pub fn clear_draw_cache(&mut self) { + for row in &mut self.model.iter_mut() { + row.clear_draw_cache(); + } + } } #[derive(Clone, Debug)]