Accept colors in styling runs passed to layout_str

Also move from the runs being expressed as ranges to the runs being expressed as a sequence of contiguous scalar lengths.
This commit is contained in:
Nathan Sobo
2021-05-21 14:10:38 -06:00
parent b42f5142f7
commit 92ff7f4e5e
7 changed files with 187 additions and 173 deletions
+6 -11
View File
@@ -82,11 +82,11 @@ impl gpui::Element for TextElement {
text,
font_size,
&[
(0..1, normal),
(1..2, bold),
(2..3, normal),
(3..4, bold),
(4..text.len(), normal),
(1, normal, ColorU::default()),
(1, bold, ColorU::default()),
(1, normal, ColorU::default()),
(1, bold, ColorU::default()),
(text.len() - 4, normal, ColorU::default()),
],
);
@@ -95,12 +95,7 @@ impl gpui::Element for TextElement {
background: Some(ColorU::white()),
..Default::default()
});
line.paint(
bounds.origin(),
bounds,
&[(0..text.len(), ColorU::black())],
ctx,
);
line.paint(bounds.origin(), bounds, ctx);
}
fn dispatch_event(