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, ElementContext, Font, FontFeatures,
6 FontStyle, FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rgba, SharedString, Size,
7 SizeRefinement, Styled, TextRun,
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 /// The z-index to set for this element
119 pub z_index: Option<u16>,
120
121 /// Whether to draw a red debugging outline around this element
122 #[cfg(debug_assertions)]
123 pub debug: bool,
124
125 /// Whether to draw a red debugging outline around this element and all of it's conforming children
126 #[cfg(debug_assertions)]
127 pub debug_below: bool,
128}
129
130impl Styled for StyleRefinement {
131 fn style(&mut self) -> &mut StyleRefinement {
132 self
133 }
134}
135
136/// The value of the visibility property, similar to the CSS property `visibility`
137#[derive(Default, Clone, Copy, Debug, Eq, PartialEq)]
138pub enum Visibility {
139 /// The element should be drawn as normal.
140 #[default]
141 Visible,
142 /// The element should not be drawn, but should still take up space in the layout.
143 Hidden,
144}
145
146/// The possible values of the box-shadow property
147#[derive(Clone, Debug)]
148pub struct BoxShadow {
149 /// What color should the shadow have?
150 pub color: Hsla,
151 /// How should it be offset from it's element?
152 pub offset: Point<Pixels>,
153 /// How much should the shadow be blurred?
154 pub blur_radius: Pixels,
155 /// How much should the shadow spread?
156 pub spread_radius: Pixels,
157}
158
159/// How to handle whitespace in text
160#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
161pub enum WhiteSpace {
162 /// Normal line wrapping when text overflows the width of the element
163 #[default]
164 Normal,
165 /// No line wrapping, text will overflow the width of the element
166 Nowrap,
167}
168
169/// The properties that can be used to style text in GPUI
170#[derive(Refineable, Clone, Debug, PartialEq)]
171#[refineable(Debug)]
172pub struct TextStyle {
173 /// The color of the text
174 pub color: Hsla,
175
176 /// The font family to use
177 pub font_family: SharedString,
178
179 /// The font features to use
180 pub font_features: FontFeatures,
181
182 /// The font size to use, in pixels or rems.
183 pub font_size: AbsoluteLength,
184
185 /// The line height to use, in pixels or fractions
186 pub line_height: DefiniteLength,
187
188 /// The font weight, e.g. bold
189 pub font_weight: FontWeight,
190
191 /// The font style, e.g. italic
192 pub font_style: FontStyle,
193
194 /// The background color of the text
195 pub background_color: Option<Hsla>,
196
197 /// The underline style of the text
198 pub underline: Option<UnderlineStyle>,
199
200 /// The strikethrough style of the text
201 pub strikethrough: Option<StrikethroughStyle>,
202
203 /// How to handle whitespace in the text
204 pub white_space: WhiteSpace,
205}
206
207impl Default for TextStyle {
208 fn default() -> Self {
209 TextStyle {
210 color: black(),
211 // todo!(linux) make this configurable or choose better default
212 font_family: if cfg!(target_os = "linux") {
213 "FreeMono".into()
214 } else {
215 "Helvetica".into()
216 },
217 font_features: FontFeatures::default(),
218 font_size: rems(1.).into(),
219 line_height: phi(),
220 font_weight: FontWeight::default(),
221 font_style: FontStyle::default(),
222 background_color: None,
223 underline: None,
224 strikethrough: None,
225 white_space: WhiteSpace::Normal,
226 }
227 }
228}
229
230impl TextStyle {
231 /// Create a new text style with the given highlighting applied.
232 pub fn highlight(mut self, style: impl Into<HighlightStyle>) -> Self {
233 let style = style.into();
234 if let Some(weight) = style.font_weight {
235 self.font_weight = weight;
236 }
237 if let Some(style) = style.font_style {
238 self.font_style = style;
239 }
240
241 if let Some(color) = style.color {
242 self.color = self.color.blend(color);
243 }
244
245 if let Some(factor) = style.fade_out {
246 self.color.fade_out(factor);
247 }
248
249 if let Some(background_color) = style.background_color {
250 self.background_color = Some(background_color);
251 }
252
253 if let Some(underline) = style.underline {
254 self.underline = Some(underline);
255 }
256
257 if let Some(strikethrough) = style.strikethrough {
258 self.strikethrough = Some(strikethrough);
259 }
260
261 self
262 }
263
264 /// Get the font configured for this text style.
265 pub fn font(&self) -> Font {
266 Font {
267 family: self.font_family.clone(),
268 features: self.font_features,
269 weight: self.font_weight,
270 style: self.font_style,
271 }
272 }
273
274 /// Returns the rounded line height in pixels.
275 pub fn line_height_in_pixels(&self, rem_size: Pixels) -> Pixels {
276 self.line_height.to_pixels(self.font_size, rem_size).round()
277 }
278
279 /// Convert this text style into a [`TextRun`], for the given length of the text.
280 pub fn to_run(&self, len: usize) -> TextRun {
281 TextRun {
282 len,
283 font: Font {
284 family: self.font_family.clone(),
285 features: Default::default(),
286 weight: self.font_weight,
287 style: self.font_style,
288 },
289 color: self.color,
290 background_color: self.background_color,
291 underline: self.underline,
292 strikethrough: self.strikethrough,
293 }
294 }
295}
296
297/// A highlight style to apply, similar to a `TextStyle` except
298/// for a single font, uniformly sized and spaced text.
299#[derive(Copy, Clone, Debug, Default, PartialEq)]
300pub struct HighlightStyle {
301 /// The color of the text
302 pub color: Option<Hsla>,
303
304 /// The font weight, e.g. bold
305 pub font_weight: Option<FontWeight>,
306
307 /// The font style, e.g. italic
308 pub font_style: Option<FontStyle>,
309
310 /// The background color of the text
311 pub background_color: Option<Hsla>,
312
313 /// The underline style of the text
314 pub underline: Option<UnderlineStyle>,
315
316 /// The underline style of the text
317 pub strikethrough: Option<StrikethroughStyle>,
318
319 /// Similar to the CSS `opacity` property, this will cause the text to be less vibrant.
320 pub fade_out: Option<f32>,
321}
322
323impl Eq for HighlightStyle {}
324
325impl Style {
326 /// Get the text style in this element style.
327 pub fn text_style(&self) -> Option<&TextStyleRefinement> {
328 if self.text.is_some() {
329 Some(&self.text)
330 } else {
331 None
332 }
333 }
334
335 /// Get the content mask for this element style, based on the given bounds.
336 /// If the element does not hide it's overflow, this will return `None`.
337 pub fn overflow_mask(
338 &self,
339 bounds: Bounds<Pixels>,
340 rem_size: Pixels,
341 ) -> Option<ContentMask<Pixels>> {
342 match self.overflow {
343 Point {
344 x: Overflow::Visible,
345 y: Overflow::Visible,
346 } => None,
347 _ => {
348 let mut min = bounds.origin;
349 let mut max = bounds.lower_right();
350
351 if self
352 .border_color
353 .map_or(false, |color| !color.is_transparent())
354 {
355 min.x += self.border_widths.left.to_pixels(rem_size);
356 max.x -= self.border_widths.right.to_pixels(rem_size);
357 min.y += self.border_widths.top.to_pixels(rem_size);
358 max.y -= self.border_widths.bottom.to_pixels(rem_size);
359 }
360
361 let bounds = match (
362 self.overflow.x == Overflow::Visible,
363 self.overflow.y == Overflow::Visible,
364 ) {
365 // x and y both visible
366 (true, true) => return None,
367 // x visible, y hidden
368 (true, false) => Bounds::from_corners(
369 point(min.x, bounds.origin.y),
370 point(max.x, bounds.lower_right().y),
371 ),
372 // x hidden, y visible
373 (false, true) => Bounds::from_corners(
374 point(bounds.origin.x, min.y),
375 point(bounds.lower_right().x, max.y),
376 ),
377 // both hidden
378 (false, false) => Bounds::from_corners(min, max),
379 };
380
381 Some(ContentMask { bounds })
382 }
383 }
384 }
385
386 /// Paints the background of an element styled with this style.
387 pub fn paint(
388 &self,
389 bounds: Bounds<Pixels>,
390 cx: &mut ElementContext,
391 continuation: impl FnOnce(&mut ElementContext),
392 ) {
393 #[cfg(debug_assertions)]
394 if self.debug_below {
395 cx.set_global(DebugBelow)
396 }
397
398 #[cfg(debug_assertions)]
399 if self.debug || cx.has_global::<DebugBelow>() {
400 cx.paint_quad(crate::outline(bounds, crate::red()));
401 }
402
403 let rem_size = cx.rem_size();
404
405 cx.with_z_index(0, |cx| {
406 cx.paint_shadows(
407 bounds,
408 self.corner_radii.to_pixels(bounds.size, rem_size),
409 &self.box_shadow,
410 );
411 });
412
413 let background_color = self.background.as_ref().and_then(Fill::color);
414 if background_color.map_or(false, |color| !color.is_transparent()) {
415 cx.with_z_index(1, |cx| {
416 let mut border_color = background_color.unwrap_or_default();
417 border_color.a = 0.;
418 cx.paint_quad(quad(
419 bounds,
420 self.corner_radii.to_pixels(bounds.size, rem_size),
421 background_color.unwrap_or_default(),
422 Edges::default(),
423 border_color,
424 ));
425 });
426 }
427
428 cx.with_z_index(2, |cx| {
429 continuation(cx);
430 });
431
432 if self.is_border_visible() {
433 cx.with_z_index(3, |cx| {
434 let corner_radii = self.corner_radii.to_pixels(bounds.size, rem_size);
435 let border_widths = self.border_widths.to_pixels(rem_size);
436 let max_border_width = border_widths.max();
437 let max_corner_radius = corner_radii.max();
438
439 let top_bounds = Bounds::from_corners(
440 bounds.origin,
441 bounds.upper_right()
442 + point(Pixels::ZERO, max_border_width.max(max_corner_radius)),
443 );
444 let bottom_bounds = Bounds::from_corners(
445 bounds.lower_left()
446 - point(Pixels::ZERO, max_border_width.max(max_corner_radius)),
447 bounds.lower_right(),
448 );
449 let left_bounds = Bounds::from_corners(
450 top_bounds.lower_left(),
451 bottom_bounds.origin + point(max_border_width, Pixels::ZERO),
452 );
453 let right_bounds = Bounds::from_corners(
454 top_bounds.lower_right() - point(max_border_width, Pixels::ZERO),
455 bottom_bounds.upper_right(),
456 );
457
458 let mut background = self.border_color.unwrap_or_default();
459 background.a = 0.;
460 let quad = quad(
461 bounds,
462 corner_radii,
463 background,
464 border_widths,
465 self.border_color.unwrap_or_default(),
466 );
467
468 cx.with_content_mask(Some(ContentMask { bounds: top_bounds }), |cx| {
469 cx.paint_quad(quad.clone());
470 });
471 cx.with_content_mask(
472 Some(ContentMask {
473 bounds: right_bounds,
474 }),
475 |cx| {
476 cx.paint_quad(quad.clone());
477 },
478 );
479 cx.with_content_mask(
480 Some(ContentMask {
481 bounds: bottom_bounds,
482 }),
483 |cx| {
484 cx.paint_quad(quad.clone());
485 },
486 );
487 cx.with_content_mask(
488 Some(ContentMask {
489 bounds: left_bounds,
490 }),
491 |cx| {
492 cx.paint_quad(quad);
493 },
494 );
495 });
496 }
497
498 #[cfg(debug_assertions)]
499 if self.debug_below {
500 cx.remove_global::<DebugBelow>();
501 }
502 }
503
504 fn is_border_visible(&self) -> bool {
505 self.border_color
506 .map_or(false, |color| !color.is_transparent())
507 && self.border_widths.any(|length| !length.is_zero())
508 }
509}
510
511impl Default for Style {
512 fn default() -> Self {
513 Style {
514 display: Display::Block,
515 visibility: Visibility::Visible,
516 overflow: Point {
517 x: Overflow::Visible,
518 y: Overflow::Visible,
519 },
520 scrollbar_width: 0.0,
521 position: Position::Relative,
522 inset: Edges::auto(),
523 margin: Edges::<Length>::zero(),
524 padding: Edges::<DefiniteLength>::zero(),
525 border_widths: Edges::<AbsoluteLength>::zero(),
526 size: Size::auto(),
527 min_size: Size::auto(),
528 max_size: Size::auto(),
529 aspect_ratio: None,
530 gap: Size::default(),
531 // Alignment
532 align_items: None,
533 align_self: None,
534 align_content: None,
535 justify_content: None,
536 // Flexbox
537 flex_direction: FlexDirection::Row,
538 flex_wrap: FlexWrap::NoWrap,
539 flex_grow: 0.0,
540 flex_shrink: 1.0,
541 flex_basis: Length::Auto,
542 background: None,
543 border_color: None,
544 corner_radii: Corners::default(),
545 box_shadow: Default::default(),
546 text: TextStyleRefinement::default(),
547 mouse_cursor: None,
548 z_index: None,
549
550 #[cfg(debug_assertions)]
551 debug: false,
552 #[cfg(debug_assertions)]
553 debug_below: false,
554 }
555 }
556}
557
558/// The properties that can be applied to an underline.
559#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq)]
560#[refineable(Debug)]
561pub struct UnderlineStyle {
562 /// The thickness of the underline.
563 pub thickness: Pixels,
564
565 /// The color of the underline.
566 pub color: Option<Hsla>,
567
568 /// Whether the underline should be wavy, like in a spell checker.
569 pub wavy: bool,
570}
571
572/// The properties that can be applied to a strikethrough.
573#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq)]
574#[refineable(Debug)]
575pub struct StrikethroughStyle {
576 /// The thickness of the strikethrough.
577 pub thickness: Pixels,
578
579 /// The color of the strikethrough.
580 pub color: Option<Hsla>,
581}
582
583/// The kinds of fill that can be applied to a shape.
584#[derive(Clone, Debug)]
585pub enum Fill {
586 /// A solid color fill.
587 Color(Hsla),
588}
589
590impl Fill {
591 /// Unwrap this fill into a solid color, if it is one.
592 pub fn color(&self) -> Option<Hsla> {
593 match self {
594 Fill::Color(color) => Some(*color),
595 }
596 }
597}
598
599impl Default for Fill {
600 fn default() -> Self {
601 Self::Color(Hsla::default())
602 }
603}
604
605impl From<Hsla> for Fill {
606 fn from(color: Hsla) -> Self {
607 Self::Color(color)
608 }
609}
610
611impl From<Rgba> for Fill {
612 fn from(color: Rgba) -> Self {
613 Self::Color(color.into())
614 }
615}
616
617impl From<TextStyle> for HighlightStyle {
618 fn from(other: TextStyle) -> Self {
619 Self::from(&other)
620 }
621}
622
623impl From<&TextStyle> for HighlightStyle {
624 fn from(other: &TextStyle) -> Self {
625 Self {
626 color: Some(other.color),
627 font_weight: Some(other.font_weight),
628 font_style: Some(other.font_style),
629 background_color: other.background_color,
630 underline: other.underline,
631 strikethrough: other.strikethrough,
632 fade_out: None,
633 }
634 }
635}
636
637impl HighlightStyle {
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}