Numver of fixes
This commit is contained in:
parent
6a782ffc9d
commit
29cf31914d
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user