From 82ecb5923ed0bbe993296f1b4ebf80f4709b063d Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 3 Aug 2022 14:54:45 -0700 Subject: [PATCH] Much better rectangle fiddling --- crates/terminal/src/connected_el.rs | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/crates/terminal/src/connected_el.rs b/crates/terminal/src/connected_el.rs index 36d75e30b7..76def7dba0 100644 --- a/crates/terminal/src/connected_el.rs +++ b/crates/terminal/src/connected_el.rs @@ -53,6 +53,7 @@ pub struct LayoutState { display_offset: usize, } +#[derive(Debug)] struct IndexedCell { point: Point, cell: Cell, @@ -108,7 +109,14 @@ impl LayoutCell { visible_bounds: RectF, cx: &mut PaintContext, ) { - let pos = point_to_absolute(origin, self.point, layout); + let pos = { + let point = self.point; + vec2f( + (origin.x() + point.column as f32 * layout.size.cell_width).floor(), + origin.y() + point.line as f32 * layout.size.line_height, + ) + }; + self.text .paint(pos, visible_bounds, layout.size.line_height, cx); } @@ -139,10 +147,15 @@ impl LayoutRect { } fn paint(&self, origin: Vector2F, layout: &LayoutState, cx: &mut PaintContext) { - let position = point_to_absolute(origin, self.point, layout); - + let position = { + let point = self.point; + vec2f( + (origin.x() + point.column as f32 * layout.size.cell_width).floor(), + origin.y() + point.line as f32 * layout.size.line_height, + ) + }; let size = vec2f( - (layout.size.cell_width.ceil() * self.num_of_cells as f32).ceil(), + (layout.size.cell_width * self.num_of_cells as f32).ceil(), layout.size.line_height, ); @@ -155,13 +168,6 @@ impl LayoutRect { } } -fn point_to_absolute(origin: Vector2F, point: Point, layout: &LayoutState) -> Vector2F { - vec2f( - (origin.x() + point.column as f32 * layout.size.cell_width).floor(), - origin.y() + point.line as f32 * layout.size.line_height, - ) -} - #[derive(Clone, Debug, Default)] struct RelativeHighlightedRange { line_index: usize, @@ -325,7 +331,7 @@ impl TerminalEl { rects.push(cur_rect.take().unwrap()); } } - + dbg!(&rects); (cells, rects, highlight_ranges) } @@ -366,6 +372,7 @@ impl TerminalEl { font_cache: &FontCache, modal: bool, ) -> RunStyle { + dbg!(indexed); let flags = indexed.cell.flags; let fg = convert_color(&fg, &style.colors, modal);