Numver of fixes

This commit is contained in:
daa 2018-01-21 14:14:07 +03:00
parent 6a782ffc9d
commit 29cf31914d
4 changed files with 27 additions and 18 deletions

View File

@ -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<Vec<(HashMap<String, Value>, String)>>) {
pub fn block_append(&mut self, content: &Vec<(HashMap<String, Value>, 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();

View File

@ -86,7 +86,7 @@ pub trait RedrawEvents {
fn cmdline_block_append(
&mut self,
content: Vec<Vec<(HashMap<String, Value>, String)>>,
content: Vec<(HashMap<String, Value>, String)>,
) -> RepaintMode;
fn cmdline_block_hide(&mut self) -> RepaintMode;

View File

@ -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,

View File

@ -1227,7 +1227,7 @@ impl RedrawEvents for State {
fn cmdline_block_append(
&mut self,
content: Vec<Vec<(HashMap<String, Value>, String)>>,
content: Vec<(HashMap<String, Value>, String)>,
) -> RepaintMode {
self.cmd_line.block_append(&content);
RepaintMode::Nothing