term_ctrl/
predefined.rs

1// Copyright 2017 Lyndon Brown
2//
3// Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not
4// copy, modify, or distribute this file except in compliance with said license. You can find copies
5// of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at
6// <http://opensource.org/licenses/MIT> and <http://www.apache.org/licenses/LICENSE-2.0>
7// respectively.
8
9//! Predefined sequence strings
10
11use crate::seq;
12
13// Alias for the non-British-English speakers
14pub use self::colours as colors;
15
16/// Resets everything to defaults (removes all effects and colours specified)
17pub const RESET: &str = seq!(0);
18
19/// Effects
20pub mod effects {
21    use super::seq;
22
23    /// Alias for reset-all
24    pub const NORMAL:      &str = super::RESET;
25    /// Bold (increase intensity)
26    pub const BOLD:        &str = seq!(1);
27    /// Dim (aka faint; decrease intensity)
28    pub const DIM:         &str = seq!(2);
29    /// Italic
30    pub const ITALIC:      &str = seq!(3);
31    /// Underline
32    pub const UNDERLINE:   &str = seq!(4);
33    /// Blink
34    pub const BLINK:       &str = seq!(5);
35    /// Rapid-blink
36    pub const RAPID_BLINK: &str = seq!(6);
37    /// Inverse (swap foreground/background colours)
38    pub const INVERSE:     &str = seq!(7);
39    /// Invisible (hidden)
40    pub const INVISIBLE:   &str = seq!(8);
41    /// Strike-through
42    pub const STRIKE:      &str = seq!(9);
43
44    /* `10`-`19` are used for font selection, covered by the font mod */
45
46    /// Fraktur
47    pub const FRAKTUR:       &str = seq!(20);
48    /// Double-underline
49    pub const DBL_UNDERLINE: &str = seq!(21);
50
51    /// Alias for removing blink
52    pub const STEADY:    &str = remove::BLINK;
53    /// Alias for removing inverse
54    pub const POSITIVE:  &str = remove::INVISIBLE;
55    /// Alias for v invisible
56    pub const VISIBLE:   &str = remove::INVISIBLE;
57
58    /// Sequences that remove specific effects
59    pub mod remove {
60        use super::seq;
61
62        /// Removes bold and/or dim
63        pub const BOLD_DIM:  &str = seq!(22);
64        /// Removes italic
65        pub const ITALIC:    &str = seq!(23);
66        /// Removes underline
67        pub const UNDERLINE: &str = seq!(24);
68        /// Removes blink
69        pub const BLINK:     &str = seq!(25);
70        /* `26` is unused? */
71        /// Removes inverse
72        pub const INVERSE:   &str = seq!(27);
73        /// Removes invisible
74        pub const INVISIBLE: &str = seq!(28);
75        /// Removes strike-through
76        pub const STRIKE:    &str = seq!(29);
77
78        /// Alias for `BOLD_DIM` (reset intensity)
79        pub const INTENSITY:  &str = BOLD_DIM;
80    }
81}
82
83/// Font selection
84pub mod fonts {
85    use super::seq;
86
87    /// Select the primary (default) font
88    pub const DEFAULT: &str = seq!(10);
89    /// Select alternate font #1
90    pub const ALT1: &str = seq!(11);
91    /// Select alternate font #2
92    pub const ALT2: &str = seq!(12);
93    /// Select alternate font #3
94    pub const ALT3: &str = seq!(13);
95    /// Select alternate font #4
96    pub const ALT4: &str = seq!(14);
97    /// Select alternate font #5
98    pub const ALT5: &str = seq!(15);
99    /// Select alternate font #6
100    pub const ALT6: &str = seq!(16);
101    /// Select alternate font #7
102    pub const ALT7: &str = seq!(17);
103    /// Select alternate font #8
104    pub const ALT8: &str = seq!(18);
105    /// Select alternate font #9
106    pub const ALT9: &str = seq!(19);
107}
108
109/// Text foreground and background colours
110pub mod colours {
111    use super::seq;
112
113    /// Reset both foreground and background colours
114    pub const RESET:    &str = seq!(39, 49);
115    /// Alias for resetting foreground colour
116    pub const RESET_FG: &str = fg::RESET;
117    /// Alias for resetting background colour
118    pub const RESET_BG: &str = bg::RESET;
119
120    /// Text (foreground) colour
121    pub mod fg {
122        use super::seq;
123
124        pub const BLACK:   &str = seq!(30);
125        pub const RED:     &str = seq!(31);
126        pub const GREEN:   &str = seq!(32);
127        pub const YELLOW:  &str = seq!(33);
128        pub const BLUE:    &str = seq!(34);
129        pub const MAGENTA: &str = seq!(35);
130        pub const CYAN:    &str = seq!(36);
131        pub const WHITE:   &str = seq!(37);
132
133        /// Resets foreground colour to default
134        pub const RESET:   &str = seq!(39);
135
136        /// Bright variants
137        pub mod bright {
138            use super::seq;
139
140            pub const BLACK:   &str = seq!(90);
141            pub const RED:     &str = seq!(91);
142            pub const GREEN:   &str = seq!(92);
143            pub const YELLOW:  &str = seq!(93);
144            pub const BLUE:    &str = seq!(94);
145            pub const MAGENTA: &str = seq!(95);
146            pub const CYAN:    &str = seq!(96);
147            pub const WHITE:   &str = seq!(97);
148        }
149    }
150
151    /// Text (background) highlighting colour
152    pub mod bg {
153        use super::seq;
154
155        pub const BLACK:   &str = seq!(40);
156        pub const RED:     &str = seq!(41);
157        pub const GREEN:   &str = seq!(42);
158        pub const YELLOW:  &str = seq!(43);
159        pub const BLUE:    &str = seq!(44);
160        pub const MAGENTA: &str = seq!(45);
161        pub const CYAN:    &str = seq!(46);
162        pub const WHITE:   &str = seq!(47);
163
164        /// Resets background-highlight colour to default
165        pub const RESET:   &str = seq!(49);
166
167        /// Bright variants
168        pub mod bright {
169            use super::seq;
170
171            pub const BLACK:   &str = seq!(100);
172            pub const RED:     &str = seq!(101);
173            pub const GREEN:   &str = seq!(102);
174            pub const YELLOW:  &str = seq!(103);
175            pub const BLUE:    &str = seq!(104);
176            pub const MAGENTA: &str = seq!(105);
177            pub const CYAN:    &str = seq!(106);
178            pub const WHITE:   &str = seq!(107);
179        }
180    }
181}
182
183/// Miscellaneous
184pub mod misc {
185    use super::seq;
186
187    /// Framed
188    pub const FRAMED:    &str = seq!(51);
189    /// Encircled
190    pub const ENCIRCLED: &str = seq!(52);
191    /// Overlined
192    pub const OVERLINED: &str = seq!(53);
193
194    /// Remove misc effects
195    pub mod remove {
196        use super::seq;
197
198        /// Remove framed and encircled effects
199        pub const FRAMED_ENCIRCLED: &str = seq!(54);
200        /// Remove overlined effects
201        pub const OVERLINED:        &str = seq!(55);
202    }
203
204    /// Ideogram stuff
205    pub mod ideogram {
206        use super::seq;
207
208        /// Ideogram underline or right side line
209        pub const UNDERLINE:      &str = seq!(60);
210        /// Ideogram double underline or double line on the right side
211        pub const DBL_UNDERLINE:  &str = seq!(61);
212        /// Ideogram overline or left side line
213        pub const OVERLINE:       &str = seq!(62);
214        /// Ideogram double overline or double line on the left side
215        pub const DBL_OVERLINE:   &str = seq!(63);
216        /// Ideogram stress marking
217        pub const STRESS_MARKING: &str = seq!(64);
218        /// Ideogram attributes off
219        pub const RESET:          &str = seq!(65);
220    }
221}
222
223/// Combinations
224pub mod combinations {
225    use super::seq;
226
227    /// Combined bold + text (foreground) colour
228    pub mod fg_bold {
229        use super::seq;
230
231        pub const BLACK:   &str = seq!(30,1);
232        pub const RED:     &str = seq!(31,1);
233        pub const GREEN:   &str = seq!(32,1);
234        pub const YELLOW:  &str = seq!(33,1);
235        pub const BLUE:    &str = seq!(34,1);
236        pub const MAGENTA: &str = seq!(35,1);
237        pub const CYAN:    &str = seq!(36,1);
238        pub const WHITE:   &str = seq!(37,1);
239    }
240}