~ruther/gtkwave-tcl-generator

ref: a2d2abb06f308b7590ba4af679a80ce5d19c0f51 gtkwave-tcl-generator/src/display_elements.rs -rw-r--r-- 1.5 KiB
a2d2abb0 — František Boháček feat: split logic of context and comment tokens 1 year, 7 months ago
                                                                                
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
use std::{fmt::Display, slice::Iter};

#[derive(Eq, PartialEq, Clone, Copy)]
pub enum DisplayOption {
    Color(DisplayColor),
    Format(DisplayFormat),
    Omit,
}

#[derive(Eq, PartialEq, Copy, Clone)]
pub enum DisplayColor {
    Normal,
    Red,
    Orange,
    Yellow,
    Green,
    Blue,
    Indigo,
    Violet,
    Cycle,
}

impl Display for DisplayColor {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                DisplayColor::Normal => "Normal",
                DisplayColor::Red => "Red",
                DisplayColor::Orange => "Orange",
                DisplayColor::Yellow => "Yellow",
                DisplayColor::Green => "Green",
                DisplayColor::Blue => "Blue",
                DisplayColor::Indigo => "Indigo",
                DisplayColor::Violet => "Violet",
                DisplayColor::Cycle => "Cycle",
            }
        )
    }
}

#[derive(Eq, PartialEq, Copy, Clone)]
pub enum DisplayFormat {
    Hex,
    Decimal,
    SignedDecimal,
    Binary,
}

impl Display for DisplayFormat {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                DisplayFormat::Hex => "Hex",
                DisplayFormat::Decimal => "Decimal",
                DisplayFormat::SignedDecimal => "SignedDecimal",
                DisplayFormat::Binary => "Binary",
            }
        )
    }
}
Do not follow this link