simple errors for lang-dev
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
69
70
71
72
73
74
75
76
77
78
79
80
81
//! allows configuration of how the error will appear.
/// characters used in printing the error.
#[derive(Debug, Clone, Copy)]
pub struct Charset {
    /// the line on the left
    pub column_line: char,
    /// the line on the left when theres a label there
    pub column_broken_line: char,
    /// the character shown below the error span for inline labels
    /// ```text
    /// 0 | problem
    ///     ^^^^^^^ issue
    ///     ^^^^^^^ these ones
    /// ```
    pub spanning: char,
    /// the character shown about the span, when the error is moved to a next line
    /// ```text
    /// 0 | problem
    ///     ───┬───
    ///     ^^^ ^^^ these ones
    /// ```
    pub spanning_out: char,
    /// the character shown in the middle of the span, when the error is moved to a next line, in the middle
    /// ```text
    /// 0 | problem
    ///     ───┬───
    ///        ^ this one
    /// ```
    pub spanning_mid: char,
    /// the character used to extend the label to yet another line
    /// ```text
    /// 0 | problem
    ///     ───┬───
    ///        │ < this one
    /// ```
    pub out_extension: char,
    /// the character used to end the label for a moved label
    /// ```text
    /// 0 | problem
    ///     ───┬───
    ///        ╰ issue
    ///        ^ this one
    /// ```
    pub out_end: char,
    /// the character used for a note
    /// ```text
    /// 0 | problem
    ///   > btw i must say you use the same text in the example alot
    ///   ^ this one
    /// ```
    pub note: char,
}

impl Charset {
    /// Produces a (pretty) unicode charset.
    pub const fn unicode() -> Self {
        Self {
            column_line: '|',
            column_broken_line: '¦',
            spanning: '^',
            spanning_out: '─',
            spanning_mid: '┬',
            out_extension: '│', // not a pipe btw
            out_end: '╰',
            note: '>',
        }
    }
    /// Produces a (ugly) ascii charset.
    pub const fn ascii() -> Self {
        Self {
            column_line: '|',
            column_broken_line: ':',
            spanning: '^',
            spanning_out: '-',
            spanning_mid: '.',
            out_extension: '|',
            out_end: '\\',
            note: '>',
        }
    }
}