Small code cleanup
This commit is contained in:
parent
37c8b48015
commit
83b5798f6f
@ -533,9 +533,7 @@ fn draw(state: &State, ctx: &cairo::Context) {
|
||||
ctx.move_to(line_x, line_y);
|
||||
|
||||
for (col_idx, cell) in line.iter() {
|
||||
let double_width = line.get(col_idx + 1)
|
||||
.map(|c| c.attrs.double_width)
|
||||
.unwrap_or(false);
|
||||
let double_width = line.is_double_width(col_idx);
|
||||
let current_point = ctx.get_current_point();
|
||||
|
||||
let (bg, fg) = state.colors(cell);
|
||||
|
@ -310,9 +310,7 @@ impl ModelRect {
|
||||
}
|
||||
|
||||
fn contains(&self, other: &ModelRect) -> bool {
|
||||
self.top <= other.top &&
|
||||
self.bot >= other.bot &&
|
||||
self.left <= other.left &&
|
||||
self.top <= other.top && self.bot >= other.bot && self.left <= other.left &&
|
||||
self.right >= other.right
|
||||
}
|
||||
|
||||
@ -435,6 +433,13 @@ impl<'a> ClipLine<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_double_width(&self, col_idx: usize) -> bool {
|
||||
self.get(col_idx + 1)
|
||||
.map(|c| c.attrs.double_width)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn get(&self, idx: usize) -> Option<&Cell> {
|
||||
self.line.get(idx)
|
||||
}
|
||||
@ -477,7 +482,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_vec_join_inside() {
|
||||
let mut list = ModelRectVec::new(ModelRect::new(0, 23, 0, 69));
|
||||
let mut list = ModelRectVec::new(ModelRect::new(0, 23, 0, 69));
|
||||
|
||||
let inside = ModelRect::new(23, 23, 68, 69);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user