1use std::{iter, mem, ops::Range};
2
3use crate::{
4 black, phi, point, quad, rems, AbsoluteLength, Bounds, ContentMask, Corners, CornersRefinement,
5 CursorStyle, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures, FontStyle, FontWeight,
6 Hsla, Length, Pixels, Point, PointRefinement, Rgba, SharedString, Size, SizeRefinement, Styled,
7 TextRun, WindowContext,
8};
9use collections::HashSet;
10use refineable::Refineable;
11use smallvec::SmallVec;
12pub use taffy::style::{
13 AlignContent, AlignItems, AlignSelf, Display, FlexDirection, FlexWrap, JustifyContent,
14 Overflow, Position,
15};
16
17/// Use this struct for interfacing with the 'debug_below' styling from your own elements.
18/// If a parent element has this style set on it, then this struct will be set as a global in
19/// GPUI.
20#[cfg(debug_assertions)]
21pub struct DebugBelow;
22
23#[cfg(debug_assertions)]
24impl crate::Global for DebugBelow {}
25
26/// The CSS styling that can be applied to an element via the `Styled` trait
27#[derive(Clone, Refineable, Debug)]
28#[refineable(Debug)]
29pub struct Style {
30 /// What layout strategy should be used?
31 pub display: Display,
32
33 /// Should the element be painted on screen?
34 pub visibility: Visibility,
35
36 // Overflow properties
37 /// How children overflowing their container should affect layout
38 #[refineable]
39 pub overflow: Point<Overflow>,
40 /// How much space (in points) should be reserved for the scrollbars of `Overflow::Scroll` and `Overflow::Auto` nodes.
41 pub scrollbar_width: f32,
42
43 // Position properties
44 /// What should the `position` value of this struct use as a base offset?
45 pub position: Position,
46 /// How should the position of this element be tweaked relative to the layout defined?
47 #[refineable]
48 pub inset: Edges<Length>,
49
50 // Size properties
51 /// Sets the initial size of the item
52 #[refineable]
53 pub size: Size<Length>,
54 /// Controls the minimum size of the item
55 #[refineable]
56 pub min_size: Size<Length>,
57 /// Controls the maximum size of the item
58 #[refineable]
59 pub max_size: Size<Length>,
60 /// Sets the preferred aspect ratio for the item. The ratio is calculated as width divided by height.
61 pub aspect_ratio: Option<f32>,
62
63 // Spacing Properties
64 /// How large should the margin be on each side?
65 #[refineable]
66 pub margin: Edges<Length>,
67 /// How large should the padding be on each side?
68 #[refineable]
69 pub padding: Edges<DefiniteLength>,
70 /// How large should the border be on each side?
71 #[refineable]
72 pub border_widths: Edges<AbsoluteLength>,
73
74 // Alignment properties
75 /// How this node's children aligned in the cross/block axis?
76 pub align_items: Option<AlignItems>,
77 /// How this node should be aligned in the cross/block axis. Falls back to the parents [`AlignItems`] if not set
78 pub align_self: Option<AlignSelf>,
79 /// How should content contained within this item be aligned in the cross/block axis
80 pub align_content: Option<AlignContent>,
81 /// How should contained within this item be aligned in the main/inline axis
82 pub justify_content: Option<JustifyContent>,
83 /// How large should the gaps between items in a flex container be?
84 #[refineable]
85 pub gap: Size<DefiniteLength>,
86
87 // Flexbox properties
88 /// Which direction does the main axis flow in?
89 pub flex_direction: FlexDirection,
90 /// Should elements wrap, or stay in a single line?
91 pub flex_wrap: FlexWrap,
92 /// Sets the initial main axis size of the item
93 pub flex_basis: Length,
94 /// The relative rate at which this item grows when it is expanding to fill space, 0.0 is the default value, and this value must be positive.
95 pub flex_grow: f32,
96 /// The relative rate at which this item shrinks when it is contracting to fit into space, 1.0 is the default value, and this value must be positive.
97 pub flex_shrink: f32,
98
99 /// The fill color of this element
100 pub background: Option<Fill>,
101
102 /// The border color of this element
103 pub border_color: Option<Hsla>,
104
105 /// The radius of the corners of this element
106 #[refineable]
107 pub corner_radii: Corners<AbsoluteLength>,
108
109 /// Box Shadow of the element
110 pub box_shadow: SmallVec<[BoxShadow; 2]>,
111
112 /// The text style of this element
113 pub text: TextStyleRefinement,
114
115 /// The mouse cursor style shown when the mouse pointer is over an element.
116 pub mouse_cursor: Option<CursorStyle>,
117
118 /// Whether to draw a red debugging outline around this element
119 #[cfg(debug_assertions)]
120 pub debug: bool,
121
122 /// Whether to draw a red debugging outline around this element and all of its conforming children
123 #[cfg(debug_assertions)]
124 pub debug_below: bool,
125}
126
127impl Styled for StyleRefinement {
128 fn style(&mut self) -> &mut StyleRefinement {
129 self
130 }
131}
132
133/// The value of the visibility property, similar to the CSS property `visibility`
134#[derive(Default, Clone, Copy, Debug, Eq, PartialEq)]
135pub enum Visibility {
136 /// The element should be drawn as normal.
137 #[default]
138 Visible,
139 /// The element should not be drawn, but should still take up space in the layout.
140 Hidden,
141}
142
143/// The possible values of the box-shadow property
144#[derive(Clone, Debug)]
145pub struct BoxShadow {
146 /// What color should the shadow have?
147 pub color: Hsla,
148 /// How should it be offset from its element?
149 pub offset: Point<Pixels>,
150 /// How much should the shadow be blurred?
151 pub blur_radius: Pixels,
152 /// How much should the shadow spread?
153 pub spread_radius: Pixels,
154}
155
156/// How to handle whitespace in text
157#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
158pub enum WhiteSpace {
159 /// Normal line wrapping when text overflows the width of the element
160 #[default]
161 Normal,
162 /// No line wrapping, text will overflow the width of the element
163 Nowrap,
164}
165
166/// The properties that can be used to style text in GPUI
167#[derive(Refineable, Clone, Debug, PartialEq)]
168#[refineable(Debug)]
169pub struct TextStyle {
170 /// The color of the text
171 pub color: Hsla,
172
173 /// The font family to use
174 pub font_family: SharedString,
175
176 /// The font features to use
177 pub font_features: FontFeatures,
178
179 /// The font size to use, in pixels or rems.
180 pub font_size: AbsoluteLength,
181
182 /// The line height to use, in pixels or fractions
183 pub line_height: DefiniteLength,
184
185 /// The font weight, e.g. bold
186 pub font_weight: FontWeight,
187
188 /// The font style, e.g. italic
189 pub font_style: FontStyle,
190
191 /// The background color of the text
192 pub background_color: Option<Hsla>,
193
194 /// The underline style of the text
195 pub underline: Option<UnderlineStyle>,
196
197 /// The strikethrough style of the text
198 pub strikethrough: Option<StrikethroughStyle>,
199
200 /// How to handle whitespace in the text
201 pub white_space: WhiteSpace,
202}
203
204impl Default for TextStyle {
205 fn default() -> Self {
206 TextStyle {
207 color: black(),
208 // todo(linux) make this configurable or choose better default
209 font_family: if cfg!(target_os = "linux") {
210 "FreeMono".into()
211 } else {
212 "Helvetica".into()
213 },
214 font_features: FontFeatures::default(),
215 font_size: rems(1.).into(),
216 line_height: phi(),
217 font_weight: FontWeight::default(),
218 font_style: FontStyle::default(),
219 background_color: None,
220 underline: None,
221 strikethrough: None,
222 white_space: WhiteSpace::Normal,
223 }
224 }
225}
226
227impl TextStyle {
228 /// Create a new text style with the given highlighting applied.
229 pub fn highlight(mut self, style: impl Into<HighlightStyle>) -> Self {
230 let style = style.into();
231 if let Some(weight) = style.font_weight {
232 self.font_weight = weight;
233 }
234 if let Some(style) = style.font_style {
235 self.font_style = style;
236 }
237
238 if let Some(color) = style.color {
239 self.color = self.color.blend(color);
240 }
241
242 if let Some(factor) = style.fade_out {
243 self.color.fade_out(factor);
244 }
245
246 if let Some(background_color) = style.background_color {
247 self.background_color = Some(background_color);
248 }
249
250 if let Some(underline) = style.underline {
251 self.underline = Some(underline);
252 }
253
254 if let Some(strikethrough) = style.strikethrough {
255 self.strikethrough = Some(strikethrough);
256 }
257
258 self
259 }
260
261 /// Get the font configured for this text style.
262 pub fn font(&self) -> Font {
263 Font {
264 family: self.font_family.clone(),
265 features: self.font_features.clone(),
266 weight: self.font_weight,
267 style: self.font_style,
268 }
269 }
270
271 /// Returns the rounded line height in pixels.
272 pub fn line_height_in_pixels(&self, rem_size: Pixels) -> Pixels {
273 self.line_height.to_pixels(self.font_size, rem_size).round()
274 }
275
276 /// Convert this text style into a [`TextRun`], for the given length of the text.
277 pub fn to_run(&self, len: usize) -> TextRun {
278 TextRun {
279 len,
280 font: Font {
281 family: self.font_family.clone(),
282 features: Default::default(),
283 weight: self.font_weight,
284 style: self.font_style,
285 },
286 color: self.color,
287 background_color: self.background_color,
288 underline: self.underline,
289 strikethrough: self.strikethrough,
290 }
291 }
292}
293
294/// A highlight style to apply, similar to a `TextStyle` except
295/// for a single font, uniformly sized and spaced text.
296#[derive(Copy, Clone, Debug, Default, PartialEq)]
297pub struct HighlightStyle {
298 /// The color of the text
299 pub color: Option<Hsla>,
300
301 /// The font weight, e.g. bold
302 pub font_weight: Option<FontWeight>,
303
304 /// The font style, e.g. italic
305 pub font_style: Option<FontStyle>,
306
307 /// The background color of the text
308 pub background_color: Option<Hsla>,
309
310 /// The underline style of the text
311 pub underline: Option<UnderlineStyle>,
312
313 /// The underline style of the text
314 pub strikethrough: Option<StrikethroughStyle>,
315
316 /// Similar to the CSS `opacity` property, this will cause the text to be less vibrant.
317 pub fade_out: Option<f32>,
318}
319
320impl Eq for HighlightStyle {}
321
322impl Style {
323 /// Returns true if the style is visible and the background is opaque.
324 pub fn has_opaque_background(&self) -> bool {
325 self.background
326 .as_ref()
327 .is_some_and(|fill| fill.color().is_some_and(|color| !color.is_transparent()))
328 }
329
330 /// Get the text style in this element style.
331 pub fn text_style(&self) -> Option<&TextStyleRefinement> {
332 if self.text.is_some() {
333 Some(&self.text)
334 } else {
335 None
336 }
337 }
338
339 /// Get the content mask for this element style, based on the given bounds.
340 /// If the element does not hide its overflow, this will return `None`.
341 pub fn overflow_mask(
342 &self,
343 bounds: Bounds<Pixels>,
344 rem_size: Pixels,
345 ) -> Option<ContentMask<Pixels>> {
346 match self.overflow {
347 Point {
348 x: Overflow::Visible,
349 y: Overflow::Visible,
350 } => None,
351 _ => {
352 let mut min = bounds.origin;
353 let mut max = bounds.lower_right();
354
355 if self
356 .border_color
357 .map_or(false, |color| !color.is_transparent())
358 {
359 min.x += self.border_widths.left.to_pixels(rem_size);
360 max.x -= self.border_widths.right.to_pixels(rem_size);
361 min.y += self.border_widths.top.to_pixels(rem_size);
362 max.y -= self.border_widths.bottom.to_pixels(rem_size);
363 }
364
365 let bounds = match (
366 self.overflow.x == Overflow::Visible,
367 self.overflow.y == Overflow::Visible,
368 ) {
369 // x and y both visible
370 (true, true) => return None,
371 // x visible, y hidden
372 (true, false) => Bounds::from_corners(
373 point(min.x, bounds.origin.y),
374 point(max.x, bounds.lower_right().y),
375 ),
376 // x hidden, y visible
377 (false, true) => Bounds::from_corners(
378 point(bounds.origin.x, min.y),
379 point(bounds.lower_right().x, max.y),
380 ),
381 // both hidden
382 (false, false) => Bounds::from_corners(min, max),
383 };
384
385 Some(ContentMask { bounds })
386 }
387 }
388 }
389
390 /// Paints the background of an element styled with this style.
391 pub fn paint(
392 &self,
393 bounds: Bounds<Pixels>,
394 cx: &mut WindowContext,
395 continuation: impl FnOnce(&mut WindowContext),
396 ) {
397 #[cfg(debug_assertions)]
398 if self.debug_below {
399 cx.set_global(DebugBelow)
400 }
401
402 #[cfg(debug_assertions)]
403 if self.debug || cx.has_global::<DebugBelow>() {
404 cx.paint_quad(crate::outline(bounds, crate::red()));
405 }
406
407 let rem_size = cx.rem_size();
408
409 cx.paint_shadows(
410 bounds,
411 self.corner_radii.to_pixels(bounds.size, rem_size),
412 &self.box_shadow,
413 );
414
415 let background_color = self.background.as_ref().and_then(Fill::color);
416 if background_color.map_or(false, |color| !color.is_transparent()) {
417 let mut border_color = background_color.unwrap_or_default();
418 border_color.a = 0.;
419 cx.paint_quad(quad(
420 bounds,
421 self.corner_radii.to_pixels(bounds.size, rem_size),
422 background_color.unwrap_or_default(),
423 Edges::default(),
424 border_color,
425 ));
426 }
427
428 continuation(cx);
429
430 if self.is_border_visible() {
431 let corner_radii = self.corner_radii.to_pixels(bounds.size, rem_size);
432 let border_widths = self.border_widths.to_pixels(rem_size);
433 let max_border_width = border_widths.max();
434 let max_corner_radius = corner_radii.max();
435
436 let top_bounds = Bounds::from_corners(
437 bounds.origin,
438 bounds.upper_right() + point(Pixels::ZERO, max_border_width.max(max_corner_radius)),
439 );
440 let bottom_bounds = Bounds::from_corners(
441 bounds.lower_left() - point(Pixels::ZERO, max_border_width.max(max_corner_radius)),
442 bounds.lower_right(),
443 );
444 let left_bounds = Bounds::from_corners(
445 top_bounds.lower_left(),
446 bottom_bounds.origin + point(max_border_width, Pixels::ZERO),
447 );
448 let right_bounds = Bounds::from_corners(
449 top_bounds.lower_right() - point(max_border_width, Pixels::ZERO),
450 bottom_bounds.upper_right(),
451 );
452
453 let mut background = self.border_color.unwrap_or_default();
454 background.a = 0.;
455 let quad = quad(
456 bounds,
457 corner_radii,
458 background,
459 border_widths,
460 self.border_color.unwrap_or_default(),
461 );
462
463 cx.with_content_mask(Some(ContentMask { bounds: top_bounds }), |cx| {
464 cx.paint_quad(quad.clone());
465 });
466 cx.with_content_mask(
467 Some(ContentMask {
468 bounds: right_bounds,
469 }),
470 |cx| {
471 cx.paint_quad(quad.clone());
472 },
473 );
474 cx.with_content_mask(
475 Some(ContentMask {
476 bounds: bottom_bounds,
477 }),
478 |cx| {
479 cx.paint_quad(quad.clone());
480 },
481 );
482 cx.with_content_mask(
483 Some(ContentMask {
484 bounds: left_bounds,
485 }),
486 |cx| {
487 cx.paint_quad(quad);
488 },
489 );
490 }
491
492 #[cfg(debug_assertions)]
493 if self.debug_below {
494 cx.remove_global::<DebugBelow>();
495 }
496 }
497
498 fn is_border_visible(&self) -> bool {
499 self.border_color
500 .map_or(false, |color| !color.is_transparent())
501 && self.border_widths.any(|length| !length.is_zero())
502 }
503}
504
505impl Default for Style {
506 fn default() -> Self {
507 Style {
508 display: Display::Block,
509 visibility: Visibility::Visible,
510 overflow: Point {
511 x: Overflow::Visible,
512 y: Overflow::Visible,
513 },
514 scrollbar_width: 0.0,
515 position: Position::Relative,
516 inset: Edges::auto(),
517 margin: Edges::<Length>::zero(),
518 padding: Edges::<DefiniteLength>::zero(),
519 border_widths: Edges::<AbsoluteLength>::zero(),
520 size: Size::auto(),
521 min_size: Size::auto(),
522 max_size: Size::auto(),
523 aspect_ratio: None,
524 gap: Size::default(),
525 // Alignment
526 align_items: None,
527 align_self: None,
528 align_content: None,
529 justify_content: None,
530 // Flexbox
531 flex_direction: FlexDirection::Row,
532 flex_wrap: FlexWrap::NoWrap,
533 flex_grow: 0.0,
534 flex_shrink: 1.0,
535 flex_basis: Length::Auto,
536 background: None,
537 border_color: None,
538 corner_radii: Corners::default(),
539 box_shadow: Default::default(),
540 text: TextStyleRefinement::default(),
541 mouse_cursor: None,
542
543 #[cfg(debug_assertions)]
544 debug: false,
545 #[cfg(debug_assertions)]
546 debug_below: false,
547 }
548 }
549}
550
551/// The properties that can be applied to an underline.
552#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq)]
553#[refineable(Debug)]
554pub struct UnderlineStyle {
555 /// The thickness of the underline.
556 pub thickness: Pixels,
557
558 /// The color of the underline.
559 pub color: Option<Hsla>,
560
561 /// Whether the underline should be wavy, like in a spell checker.
562 pub wavy: bool,
563}
564
565/// The properties that can be applied to a strikethrough.
566#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq)]
567#[refineable(Debug)]
568pub struct StrikethroughStyle {
569 /// The thickness of the strikethrough.
570 pub thickness: Pixels,
571
572 /// The color of the strikethrough.
573 pub color: Option<Hsla>,
574}
575
576/// The kinds of fill that can be applied to a shape.
577#[derive(Clone, Debug)]
578pub enum Fill {
579 /// A solid color fill.
580 Color(Hsla),
581}
582
583impl Fill {
584 /// Unwrap this fill into a solid color, if it is one.
585 pub fn color(&self) -> Option<Hsla> {
586 match self {
587 Fill::Color(color) => Some(*color),
588 }
589 }
590}
591
592impl Default for Fill {
593 fn default() -> Self {
594 Self::Color(Hsla::default())
595 }
596}
597
598impl From<Hsla> for Fill {
599 fn from(color: Hsla) -> Self {
600 Self::Color(color)
601 }
602}
603
604impl From<Rgba> for Fill {
605 fn from(color: Rgba) -> Self {
606 Self::Color(color.into())
607 }
608}
609
610impl From<TextStyle> for HighlightStyle {
611 fn from(other: TextStyle) -> Self {
612 Self::from(&other)
613 }
614}
615
616impl From<&TextStyle> for HighlightStyle {
617 fn from(other: &TextStyle) -> Self {
618 Self {
619 color: Some(other.color),
620 font_weight: Some(other.font_weight),
621 font_style: Some(other.font_style),
622 background_color: other.background_color,
623 underline: other.underline,
624 strikethrough: other.strikethrough,
625 fade_out: None,
626 }
627 }
628}
629
630impl HighlightStyle {
631 /// Create a highlight style with just a color
632 pub fn color(color: Hsla) -> Self {
633 Self {
634 color: Some(color),
635 ..Default::default()
636 }
637 }
638 /// Blend this highlight style with another.
639 /// Non-continuous properties, like font_weight and font_style, are overwritten.
640 pub fn highlight(&mut self, other: HighlightStyle) {
641 match (self.color, other.color) {
642 (Some(self_color), Some(other_color)) => {
643 self.color = Some(Hsla::blend(other_color, self_color));
644 }
645 (None, Some(other_color)) => {
646 self.color = Some(other_color);
647 }
648 _ => {}
649 }
650
651 if other.font_weight.is_some() {
652 self.font_weight = other.font_weight;
653 }
654
655 if other.font_style.is_some() {
656 self.font_style = other.font_style;
657 }
658
659 if other.background_color.is_some() {
660 self.background_color = other.background_color;
661 }
662
663 if other.underline.is_some() {
664 self.underline = other.underline;
665 }
666
667 if other.strikethrough.is_some() {
668 self.strikethrough = other.strikethrough;
669 }
670
671 match (other.fade_out, self.fade_out) {
672 (Some(source_fade), None) => self.fade_out = Some(source_fade),
673 (Some(source_fade), Some(dest_fade)) => {
674 self.fade_out = Some((dest_fade * (1. + source_fade)).clamp(0., 1.));
675 }
676 _ => {}
677 }
678 }
679}
680
681impl From<Hsla> for HighlightStyle {
682 fn from(color: Hsla) -> Self {
683 Self {
684 color: Some(color),
685 ..Default::default()
686 }
687 }
688}
689
690impl From<FontWeight> for HighlightStyle {
691 fn from(font_weight: FontWeight) -> Self {
692 Self {
693 font_weight: Some(font_weight),
694 ..Default::default()
695 }
696 }
697}
698
699impl From<FontStyle> for HighlightStyle {
700 fn from(font_style: FontStyle) -> Self {
701 Self {
702 font_style: Some(font_style),
703 ..Default::default()
704 }
705 }
706}
707
708impl From<Rgba> for HighlightStyle {
709 fn from(color: Rgba) -> Self {
710 Self {
711 color: Some(color.into()),
712 ..Default::default()
713 }
714 }
715}
716
717/// Combine and merge the highlights and ranges in the two iterators.
718pub fn combine_highlights(
719 a: impl IntoIterator<Item = (Range<usize>, HighlightStyle)>,
720 b: impl IntoIterator<Item = (Range<usize>, HighlightStyle)>,
721) -> impl Iterator<Item = (Range<usize>, HighlightStyle)> {
722 let mut endpoints = Vec::new();
723 let mut highlights = Vec::new();
724 for (range, highlight) in a.into_iter().chain(b) {
725 if !range.is_empty() {
726 let highlight_id = highlights.len();
727 endpoints.push((range.start, highlight_id, true));
728 endpoints.push((range.end, highlight_id, false));
729 highlights.push(highlight);
730 }
731 }
732 endpoints.sort_unstable_by_key(|(position, _, _)| *position);
733 let mut endpoints = endpoints.into_iter().peekable();
734
735 let mut active_styles = HashSet::default();
736 let mut ix = 0;
737 iter::from_fn(move || {
738 while let Some((endpoint_ix, highlight_id, is_start)) = endpoints.peek() {
739 let prev_index = mem::replace(&mut ix, *endpoint_ix);
740 if ix > prev_index && !active_styles.is_empty() {
741 let mut current_style = HighlightStyle::default();
742 for highlight_id in &active_styles {
743 current_style.highlight(highlights[*highlight_id]);
744 }
745 return Some((prev_index..ix, current_style));
746 }
747
748 if *is_start {
749 active_styles.insert(*highlight_id);
750 } else {
751 active_styles.remove(highlight_id);
752 }
753 endpoints.next();
754 }
755 None
756 })
757}
758
759#[cfg(test)]
760mod tests {
761 use crate::{blue, green, red, yellow};
762
763 use super::*;
764
765 #[test]
766 fn test_combine_highlights() {
767 assert_eq!(
768 combine_highlights(
769 [
770 (0..5, green().into()),
771 (4..10, FontWeight::BOLD.into()),
772 (15..20, yellow().into()),
773 ],
774 [
775 (2..6, FontStyle::Italic.into()),
776 (1..3, blue().into()),
777 (21..23, red().into()),
778 ]
779 )
780 .collect::<Vec<_>>(),
781 [
782 (
783 0..1,
784 HighlightStyle {
785 color: Some(green()),
786 ..Default::default()
787 }
788 ),
789 (
790 1..2,
791 HighlightStyle {
792 color: Some(green()),
793 ..Default::default()
794 }
795 ),
796 (
797 2..3,
798 HighlightStyle {
799 color: Some(green()),
800 font_style: Some(FontStyle::Italic),
801 ..Default::default()
802 }
803 ),
804 (
805 3..4,
806 HighlightStyle {
807 color: Some(green()),
808 font_style: Some(FontStyle::Italic),
809 ..Default::default()
810 }
811 ),
812 (
813 4..5,
814 HighlightStyle {
815 color: Some(green()),
816 font_weight: Some(FontWeight::BOLD),
817 font_style: Some(FontStyle::Italic),
818 ..Default::default()
819 }
820 ),
821 (
822 5..6,
823 HighlightStyle {
824 font_weight: Some(FontWeight::BOLD),
825 font_style: Some(FontStyle::Italic),
826 ..Default::default()
827 }
828 ),
829 (
830 6..10,
831 HighlightStyle {
832 font_weight: Some(FontWeight::BOLD),
833 ..Default::default()
834 }
835 ),
836 (
837 15..20,
838 HighlightStyle {
839 color: Some(yellow()),
840 ..Default::default()
841 }
842 ),
843 (
844 21..23,
845 HighlightStyle {
846 color: Some(red()),
847 ..Default::default()
848 }
849 )
850 ]
851 );
852 }
853}