annotate_snippets/renderer/
stylesheet.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use anstyle::Style;

#[derive(Clone, Copy, Debug)]
pub(crate) struct Stylesheet {
    pub(crate) error: Style,
    pub(crate) warning: Style,
    pub(crate) info: Style,
    pub(crate) note: Style,
    pub(crate) help: Style,
    pub(crate) line_no: Style,
    pub(crate) emphasis: Style,
    pub(crate) none: Style,
}

impl Default for Stylesheet {
    fn default() -> Self {
        Self::plain()
    }
}

impl Stylesheet {
    pub(crate) const fn plain() -> Self {
        Self {
            error: Style::new(),
            warning: Style::new(),
            info: Style::new(),
            note: Style::new(),
            help: Style::new(),
            line_no: Style::new(),
            emphasis: Style::new(),
            none: Style::new(),
        }
    }
}

impl Stylesheet {
    pub(crate) fn error(&self) -> &Style {
        &self.error
    }

    pub(crate) fn warning(&self) -> &Style {
        &self.warning
    }

    pub(crate) fn info(&self) -> &Style {
        &self.info
    }

    pub(crate) fn note(&self) -> &Style {
        &self.note
    }

    pub(crate) fn help(&self) -> &Style {
        &self.help
    }

    pub(crate) fn line_no(&self) -> &Style {
        &self.line_no
    }

    pub(crate) fn emphasis(&self) -> &Style {
        &self.emphasis
    }

    pub(crate) fn none(&self) -> &Style {
        &self.none
    }
}