58 static InputState g_inputState = INPUTSTATE_NORMAL; |
58 static InputState g_inputState = INPUTSTATE_NORMAL; |
59 static Function<void (void)> g_disconnectConfirmFunction = nullptr; |
59 static Function<void (void)> g_disconnectConfirmFunction = nullptr; |
60 static IPAddress g_address; |
60 static IPAddress g_address; |
61 static String g_statusBarText; |
61 static String g_statusBarText; |
62 |
62 |
|
63 static const struct { Color color; bool bold; } g_colorCodes['v' - 'a' + 1] = |
|
64 { |
|
65 { RED, true }, // a - brick |
|
66 { YELLOW, true }, // b - tan |
|
67 { WHITE, false }, // c - gray |
|
68 { GREEN, true }, // d - light green |
|
69 { YELLOW, false }, // e - brown |
|
70 { YELLOW, true }, // f - gold yellow |
|
71 { RED, true }, // g - bright red |
|
72 { BLUE, false }, // h - dark blue |
|
73 { YELLOW, false }, // i - orange |
|
74 { WHITE, true }, // j - white |
|
75 { YELLOW, true }, // k - fire yellow |
|
76 { DEFAULT, false }, // l - untranslated |
|
77 { BLACK, false }, // m - black |
|
78 { BLUE, true }, // n - light blue |
|
79 { YELLOW, true }, // o - cream |
|
80 { GREEN, true }, // p - olive green |
|
81 { GREEN, false }, // q - dark green |
|
82 { RED, false }, // r - dark red |
|
83 { YELLOW, false }, // s - dark brown |
|
84 { MAGENTA, false }, // t - purple |
|
85 { BLACK, true }, // u - dark gray |
|
86 { CYAN, true }, // v - cyan |
|
87 }; |
|
88 |
63 // ------------------------------------------------------------------------------------------------- |
89 // ------------------------------------------------------------------------------------------------- |
64 // |
90 // |
65 static FUNCTION |
91 static FUNCTION |
66 interface_color_pair (Color fg, Color bg) -> int |
92 interface_color_pair (Color fg, Color bg) -> int |
67 { |
93 { |
260 assert (end - start <= height); |
286 assert (end - start <= height); |
261 |
287 |
262 for (int i = start; i < end; ++i) |
288 for (int i = start; i < end; ++i) |
263 { |
289 { |
264 mvhline (y, 0, ' ', COLS); |
290 mvhline (y, 0, ' ', COLS); |
265 mvprintw (y++, 0, "%s", g_output[i].chars()); |
291 int activeColor = -1; |
|
292 bool boldActive = false; |
|
293 int x = 0; |
|
294 |
|
295 for (int j = 0; j < g_output[i].length(); ++j) |
|
296 { |
|
297 char ch = g_output[i][j]; |
|
298 |
|
299 if (ch == '\x1C' and j + 1 < g_output[i].length()) |
|
300 { |
|
301 if (activeColor != -1) |
|
302 attroff (activeColor); |
|
303 |
|
304 if (boldActive) |
|
305 attroff (A_BOLD); |
|
306 |
|
307 char colorChar = g_output[i][j + 1]; |
|
308 |
|
309 if (colorChar >= 'a' and colorChar <= 'v' and colorChar != 'l') |
|
310 { |
|
311 auto colorInfo = g_colorCodes[colorChar - 'a']; |
|
312 activeColor = interface_color_pair (colorInfo.color, DEFAULT); |
|
313 boldActive = colorInfo.bold; |
|
314 attron (activeColor); |
|
315 |
|
316 if (boldActive) |
|
317 attron (A_BOLD); |
|
318 } |
|
319 |
|
320 j++; |
|
321 continue; |
|
322 } |
|
323 |
|
324 mvaddch (y, x++, g_output[i][j]); |
|
325 } |
|
326 |
|
327 if (activeColor != -1) |
|
328 attroff (activeColor); |
|
329 |
|
330 if (boldActive) |
|
331 attroff (A_BOLD); |
|
332 |
|
333 ++y; |
266 } |
334 } |
267 |
335 |
268 g_needRefresh = true; |
336 g_needRefresh = true; |
269 } |
337 } |
270 |
338 |