annotate_snippets/renderer/
stylesheet.rs

1use anstyle::Style;
2
3#[derive(Clone, Copy, Debug)]
4pub(crate) struct Stylesheet {
5    pub(crate) error: Style,
6    pub(crate) warning: Style,
7    pub(crate) info: Style,
8    pub(crate) note: Style,
9    pub(crate) help: Style,
10    pub(crate) line_no: Style,
11    pub(crate) emphasis: Style,
12    pub(crate) none: Style,
13}
14
15impl Default for Stylesheet {
16    fn default() -> Self {
17        Self::plain()
18    }
19}
20
21impl Stylesheet {
22    pub(crate) const fn plain() -> Self {
23        Self {
24            error: Style::new(),
25            warning: Style::new(),
26            info: Style::new(),
27            note: Style::new(),
28            help: Style::new(),
29            line_no: Style::new(),
30            emphasis: Style::new(),
31            none: Style::new(),
32        }
33    }
34}
35
36impl Stylesheet {
37    pub(crate) fn error(&self) -> &Style {
38        &self.error
39    }
40
41    pub(crate) fn warning(&self) -> &Style {
42        &self.warning
43    }
44
45    pub(crate) fn info(&self) -> &Style {
46        &self.info
47    }
48
49    pub(crate) fn note(&self) -> &Style {
50        &self.note
51    }
52
53    pub(crate) fn help(&self) -> &Style {
54        &self.help
55    }
56
57    pub(crate) fn line_no(&self) -> &Style {
58        &self.line_no
59    }
60
61    pub(crate) fn emphasis(&self) -> &Style {
62        &self.emphasis
63    }
64
65    pub(crate) fn none(&self) -> &Style {
66        &self.none
67    }
68}