diff --git a/src/cmd_line.rs b/src/cmd_line.rs index 352afd0..cb1f0e0 100644 --- a/src/cmd_line.rs +++ b/src/cmd_line.rs @@ -164,8 +164,12 @@ impl State { let block = self.block.as_ref(); let level = self.levels.last(); - let (block_width, block_height) = block.map(|b| (b.preferred_width, b.preferred_height)).unwrap_or((0, 0)); - let (level_width, level_height) = level.map(|l| (l.preferred_width, l.preferred_height)).unwrap_or((0, 0)); + let (block_width, block_height) = block + .map(|b| (b.preferred_width, b.preferred_height)) + .unwrap_or((0, 0)); + let (level_width, level_height) = level + .map(|l| (l.preferred_width, l.preferred_height)) + .unwrap_or((0, 0)); drawing_area.set_size_request( max(level_width, block_width), @@ -268,16 +272,19 @@ impl CmdLine { } - pub fn block_append(&mut self, content: &Vec, String)>>) { + pub fn block_append(&mut self, content: &Vec<(HashMap, String)>) { let mut state = self.state.borrow_mut(); let render_state = state.render_state.clone(); { + let attr_content = content + .iter() + .map(|c| { + (Some(Attrs::from_value_map(&c.0)), c.1.chars().collect()) + }) + .collect(); + let block = state.block.as_mut().unwrap(); - block.replace_line( - &Level::to_attributed_content(content), - &*render_state.borrow(), - true, - ); + block.replace_line(&vec![attr_content], &*render_state.borrow(), true); block.update_cache(&*render_state.borrow()); } state.request_area_size(); @@ -297,7 +304,7 @@ fn gtk_draw( let level = state.levels.last(); let block = state.block.as_ref(); - let preferred_height = level.map(|l| l.preferred_height).unwrap_or(0) + let preferred_height = level.map(|l| l.preferred_height).unwrap_or(0) + block.as_ref().map(|b| b.preferred_height).unwrap_or(0); let render_state = state.render_state.borrow(); diff --git a/src/nvim/redraw_handler.rs b/src/nvim/redraw_handler.rs index 3db3da2..1e6feb6 100644 --- a/src/nvim/redraw_handler.rs +++ b/src/nvim/redraw_handler.rs @@ -86,7 +86,7 @@ pub trait RedrawEvents { fn cmdline_block_append( &mut self, - content: Vec, String)>>, + content: Vec<(HashMap, String)>, ) -> RepaintMode; fn cmdline_block_hide(&mut self) -> RepaintMode; diff --git a/src/render/model_clip_iterator.rs b/src/render/model_clip_iterator.rs index b849333..452cb1f 100644 --- a/src/render/model_clip_iterator.rs +++ b/src/render/model_clip_iterator.rs @@ -1,4 +1,6 @@ +use std::cmp::min; use std::slice::Iter; + use cairo; use super::context::CellMetrics; @@ -76,17 +78,17 @@ impl ModelClipIteratorFactory for ui_model::UiModel { let model = self.model(); let (x1, y1, x2, y2) = ctx.clip_extents(); - let model_clip = ui_model::ModelRect::from_area(cell_metrics, x1, y1, x2, y2); - let model_clip_top = if model_clip.top <= 0 { + + // in case ctx.translate is used y1 can be less then 0 + // in this case just use 0 as top value + let model_clip = ui_model::ModelRect::from_area(cell_metrics, x1, y1.max(0.0), x2, y2); + + let model_clip_top = if model_clip.top == 0 { 0 } else { model_clip.top - 1 }; - let model_clip_bot = if model_clip.bot >= model.len() - 1 { - model.len() - 1 - } else { - model_clip.bot + 1 - }; + let model_clip_bot = min(model.len() - 1, model_clip.bot + 1); ModelClipIterator { model_idx: model_clip_top, diff --git a/src/shell.rs b/src/shell.rs index 2b94aed..5bdab2c 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -1227,7 +1227,7 @@ impl RedrawEvents for State { fn cmdline_block_append( &mut self, - content: Vec, String)>>, + content: Vec<(HashMap, String)>, ) -> RepaintMode { self.cmd_line.block_append(&content); RepaintMode::Nothing