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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/// This library takes in a str and returns a coloured String.


/// this function returns the String with the colour.
fn colourise(text: &str, colour: i8) -> String {
    return "\x1b[".to_owned() + &colour.to_string() + "m" + text + "\x1b[0m";
}


/// This function takes the &str, then calls the "colourise" function to convert it into a coloured string.
///
/// ___ 
///
/// Examples
/// ```rust
/// colour("this is a black string", "black");
/// colour("this is a underlined string", "u");
/// ```
/// ___
/// Available Colours
/// ```rust 
///    // normal colours
///     "black" | "b"
///     "red" | "r"
///     "green" | "g"
///     "yellow" | "y"
///     "blue" | "bl"
///     "magenta" | "m"
///     "cyan" | "c"
///     "white"| "w"
///     
///     // bright colours
///     "brightblack" | "bb" 
///     "brightred" | "br"   
///     "brightgreen" | "bg"   
///     "brightyellow" | "by"  
///     "brightblue" | "bbl" 
///     "brightmagenta" | "bm"  
///     "brightcyan" | "bc"  
///     "brightwhite" | "bw"  
///     
///     //background colours
///     "backgroundred" | "b-r"   
///     "backgroundgreen" | "b-g"  
///     "backgroundyellow" | "b-y"  
///     "backgroundblue" | "b-b"  
///     "backgroundmagenta" | "b-m"  
///     "backgroundcyan" | "b-c"  
///     "bacgroundwhite" | "b-w" 
///        
///     //bright background colours
///     "backgroundbrightblack" | "b-bb" 
///     "backgroundbrightred" | "b-br" 
///     "backgroundbrightgreen" | "b-bg" 
///     "backgroundbrightyellow" | "b-by"  
///     "backgroundbrightblue" | "b-bbl"  
///     "backgroundbrightmagenta" | "b-bm"  
///     "backgroundbrightcyan" | "b-bc"  
///     "backgroundbrightwhite" | "b-bw"  
///
///    // other styles
///     "clear" | "cl"  
///     "dimmed" | "d"   
///     "italic" | "i"   
///     "underline" | "u"  
///     "blink" | "bli"   
///     "reversed" | "re"   
///     "hidden" | "h"  
///     "strikethrough" | "s"  
/// ```
/// 
pub fn colour(text: &str, colour: &str) -> String {
    match colour {
        //normal colours
        "black" | "b" => return colourise(text, 30),
        "red" | "r" => return colourise(text, 31),
        "green" | "g" => return colourise(text, 32),
        "yellow" | "y" => return colourise(text, 33),
        "blue" | "bl" => return colourise(text, 34),
        "magenta" | "m" => return colourise(text, 35),
        "cyan" | "c" => return colourise(text, 36),
        "white"| "w" => return colourise(text, 37),
        
        // bright colours
        "brightblack" | "bb" => return colourise(text, 90),
        "brightred" | "br" => return colourise(text, 91),
        "brightgreen" | "bg" => return colourise(text, 92),
        "brightyellow" | "by" => return colourise(text, 93),
        "brightblue" | "bbl"=> return colourise(text, 94),
        "brightmagenta" | "bm" => return colourise(text, 95),
        "brightcyan" | "bc" => return colourise(text, 96),
        "brightwhite" | "bw" => return colourise(text, 97),
        
        //background colours
        "backgroundred" | "b-r" => return colourise(text, 41),
        "backgroundgreen" | "b-g" => return colourise(text, 42),
        "backgroundyellow" | "b-y" => return colourise(text, 43),
        "backgroundblue" | "b-b" => return colourise(text, 44),
        "backgroundmagenta" | "b-m" => return colourise(text, 45),
        "backgroundcyan" | "b-c" => return colourise(text, 46),
        "bacgroundwhite" | "b-w" => return colourise(text, 47),

        //bright background colours
        "backgroundbrightblack" | "b-bb" => return colourise(text, 100),
        "backgroundbrightred" | "b-br" => return colourise(text, 101),
        "backgroundbrightgreen" | "b-bg" => return colourise(text, 102),
        "backgroundbrightyellow" | "b-by" => return colourise(text, 103),
        "backgroundbrightblue" | "b-bbl" => return colourise(text, 104),
        "backgroundbrightmagenta" | "b-bm" => return colourise(text, 105),
        "backgroundbrightcyan" | "b-bc" => return colourise(text, 106),
        "backgroundbrightwhite" | "b-bw" => return colourise(text, 107),

        // other styles
        "clear" | "cl" => return colourise(text, 1),
        "dimmed" | "d"  => return colourise(text, 2),
        "italic" | "i" => return colourise(text, 3),
        "underline" | "u" => return colourise(text, 4),
        "blink" | "bli" => return colourise(text, 5),
        "reversed" | "re"  => return colourise(text, 7),
        "hidden" | "h" => return colourise(text, 8),
        "strikethrough" | "s" => return colourise(text, 9),
        // edge case
        _ => return colourise("no colour selected!", 93)


    }
}