History

msg: don't use bold colors and instead use bright ones

Also avoid regular white/black, because it is often the terminal background and invisible as foreground color. Change debug messages to blue while at it to differentiate them from trace ones.

Kacper Michajłow committed 2 years ago

Commit 4de63901 parent 7362f721 file · +17 −3Browse files

Unified · Split

common/msg.c+17−3
@@ -321,13 +321,27 @@ static void set_term_color(void *talloc_ctx, bstr *text, int c) · 320 unmodified lines
321 bstr_xappend(talloc_ctx, text, bstr0("\033[0m"));321 bstr_xappend(talloc_ctx, text, bstr0("\033[0m"));
322 return;322 return;
323 }323 }
324 324 // Pure black to gray
325 bstr_xappend_asprintf(talloc_ctx, text, "\033[%d;3%dm", c >> 3, c & 7);325 if (c == 0)
326 c += 8;
327 // Pure white to light one
328 if (c == 15)
329 c -= 8;
330 bstr_xappend_asprintf(talloc_ctx, text, "\033[%d%dm", c >= 8 ? 9 : 3, c & 7);
326}331}
327 332
328static void set_msg_color(void *talloc_ctx, bstr *text, int lev)333static void set_msg_color(void *talloc_ctx, bstr *text, int lev)
329{334{
330 static const int v_colors[] = {9, 1, 3, -1, -1, 2, 8, 8, 8, -1};335 static const int v_colors[] = {
336 [MSGL_FATAL] = 9, // bright red
337 [MSGL_ERR] = 1, // red
338 [MSGL_WARN] = 3, // yellow
339 [MSGL_INFO] = -1, // default
340 [MSGL_STATUS] = -1, // default
341 [MSGL_V] = 2, // green
342 [MSGL_DEBUG] = 4, // blue
343 [MSGL_TRACE] = 8, // bright black aka. gray
344 };
331 set_term_color(talloc_ctx, text, v_colors[lev]);345 set_term_color(talloc_ctx, text, v_colors[lev]);
332}346}
333 347

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t