|
@@ -86,9 +86,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
86
|
86
|
* @v basic Basic colour
|
87
|
87
|
* @ret ansicol ANSI colour definition
|
88
|
88
|
*
|
89
|
|
- * Colours default to being just a basic colour.
|
|
89
|
+ * Colours default to being just a basic colour. If the colour
|
|
90
|
+ * matches the normal UI text background colour, then its basic colour
|
|
91
|
+ * value is set to @c ANSICOL_MAGIC.
|
90
|
92
|
*/
|
91
|
|
-#define ANSICOL_DEFAULT( basic ) ANSICOL_DEFINE ( (basic), ANSICOL_NO_RGB )
|
|
93
|
+#define ANSICOL_DEFAULT( basic ) \
|
|
94
|
+ ANSICOL_DEFINE ( ( ( (basic) == COLOR_NORMAL_BG ) ? \
|
|
95
|
+ ANSICOL_MAGIC : (basic) ), \
|
|
96
|
+ ANSICOL_NO_RGB )
|
92
|
97
|
|
93
|
98
|
/** ANSI colour definitions */
|
94
|
99
|
static uint32_t ansicols[] = {
|
|
@@ -102,6 +107,9 @@ static uint32_t ansicols[] = {
|
102
|
107
|
[COLOR_WHITE] = ANSICOL_DEFAULT ( COLOR_WHITE ),
|
103
|
108
|
};
|
104
|
109
|
|
|
110
|
+/** Magic basic colour */
|
|
111
|
+static uint8_t ansicol_magic = COLOR_NORMAL_BG;
|
|
112
|
+
|
105
|
113
|
/**
|
106
|
114
|
* Define ANSI colour
|
107
|
115
|
*
|
|
@@ -145,10 +153,10 @@ void ansicol_set ( unsigned int colour, unsigned int which ) {
|
145
|
153
|
ansicol = ANSICOL_DEFINE ( COLOUR_DEFAULT, ANSICOL_NO_RGB );
|
146
|
154
|
}
|
147
|
155
|
|
148
|
|
- /* If basic colour is out of range, use the default colour */
|
|
156
|
+ /* If basic colour is out of range, use the magic colour */
|
149
|
157
|
basic = ANSICOL_BASIC ( ansicol );
|
150
|
158
|
if ( basic >= 10 )
|
151
|
|
- basic = COLOR_DEFAULT;
|
|
159
|
+ basic = ansicol_magic;
|
152
|
160
|
|
153
|
161
|
/* Set basic colour first */
|
154
|
162
|
printf ( CSI "%c%dm", which, basic );
|
|
@@ -159,3 +167,25 @@ void ansicol_set ( unsigned int colour, unsigned int which ) {
|
159
|
167
|
ANSICOL_GREEN ( ansicol ), ANSICOL_BLUE ( ansicol ) );
|
160
|
168
|
}
|
161
|
169
|
}
|
|
170
|
+
|
|
171
|
+/**
|
|
172
|
+ * Reset magic colour
|
|
173
|
+ *
|
|
174
|
+ */
|
|
175
|
+void ansicol_reset_magic ( void ) {
|
|
176
|
+
|
|
177
|
+ /* Set to the compile-time default background colour */
|
|
178
|
+ ansicol_magic = COLOR_NORMAL_BG;
|
|
179
|
+}
|
|
180
|
+
|
|
181
|
+/**
|
|
182
|
+ * Set magic colour to transparent
|
|
183
|
+ *
|
|
184
|
+ */
|
|
185
|
+void ansicol_set_magic_transparent ( void ) {
|
|
186
|
+
|
|
187
|
+ /* Set to the console default colour (which will give a
|
|
188
|
+ * transparent background on the framebuffer console).
|
|
189
|
+ */
|
|
190
|
+ ansicol_magic = COLOR_DEFAULT;
|
|
191
|
+}
|