authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-12-04 09:15:17-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2017-12-04 09:15:17-05:00
log67e6d9bc30dabc295262b1aee8fe5eb044ba5cdc
treea109b552cc30b78fc058b8f4a8fd80c8c344a8ba
parent76f3bdfff8224144e7b57748eb8eda2001d0308d
parentfea016afc0c1102a4847f4e5676260b14d81096e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #644 from Dubhead/Dubhead-fix-message-color

Fix the color of compiler messages for light-themed terminal.

3 files changed, 10 insertions(+), 4 deletions(-)

src/errmsg.cpp+4-4
...@@ -24,20 +24,20 @@ static void print_err_msg_type(ErrorMsg *err, ErrColor color, ErrType err_type)...@@ -24,20 +24,20 @@ static void print_err_msg_type(ErrorMsg *err, ErrColor color, ErrType err_type)
24 bool is_tty = os_stderr_tty();24 bool is_tty = os_stderr_tty();
25 if (color == ErrColorOn || (color == ErrColorAuto && is_tty)) {25 if (color == ErrColorOn || (color == ErrColorAuto && is_tty)) {
26 if (err_type == ErrTypeError) {26 if (err_type == ErrTypeError) {
27 os_stderr_set_color(TermColorWhite);27 os_stderr_set_color(TermColorBold);
28 fprintf(stderr, "%s:%" ZIG_PRI_usize ":%" ZIG_PRI_usize ": ", path, line, col);28 fprintf(stderr, "%s:%" ZIG_PRI_usize ":%" ZIG_PRI_usize ": ", path, line, col);
29 os_stderr_set_color(TermColorRed);29 os_stderr_set_color(TermColorRed);
30 fprintf(stderr, "error:");30 fprintf(stderr, "error:");
31 os_stderr_set_color(TermColorWhite);31 os_stderr_set_color(TermColorBold);
32 fprintf(stderr, " %s", text);32 fprintf(stderr, " %s", text);
33 os_stderr_set_color(TermColorReset);33 os_stderr_set_color(TermColorReset);
34 fprintf(stderr, "\n");34 fprintf(stderr, "\n");
35 } else if (err_type == ErrTypeNote) {35 } else if (err_type == ErrTypeNote) {
36 os_stderr_set_color(TermColorWhite);36 os_stderr_set_color(TermColorBold);
37 fprintf(stderr, "%s:%" ZIG_PRI_usize ":%" ZIG_PRI_usize ": ", path, line, col);37 fprintf(stderr, "%s:%" ZIG_PRI_usize ":%" ZIG_PRI_usize ": ", path, line, col);
38 os_stderr_set_color(TermColorCyan);38 os_stderr_set_color(TermColorCyan);
39 fprintf(stderr, "note:");39 fprintf(stderr, "note:");
40 os_stderr_set_color(TermColorWhite);40 os_stderr_set_color(TermColorBold);
41 fprintf(stderr, " %s", text);41 fprintf(stderr, " %s", text);
42 os_stderr_set_color(TermColorReset);42 os_stderr_set_color(TermColorReset);
43 fprintf(stderr, "\n");43 fprintf(stderr, "\n");
src/os.cpp+5
...@@ -931,6 +931,7 @@ int os_self_exe_path(Buf *out_path) {...@@ -931,6 +931,7 @@ int os_self_exe_path(Buf *out_path) {
931#define VT_GREEN "\x1b[32;1m"931#define VT_GREEN "\x1b[32;1m"
932#define VT_CYAN "\x1b[36;1m"932#define VT_CYAN "\x1b[36;1m"
933#define VT_WHITE "\x1b[37;1m"933#define VT_WHITE "\x1b[37;1m"
934#define VT_BOLD "\x1b[0;1m"
934#define VT_RESET "\x1b[0m"935#define VT_RESET "\x1b[0m"
935936
936static void set_color_posix(TermColor color) {937static void set_color_posix(TermColor color) {
...@@ -947,6 +948,9 @@ static void set_color_posix(TermColor color) {...@@ -947,6 +948,9 @@ static void set_color_posix(TermColor color) {
947 case TermColorWhite:948 case TermColorWhite:
948 fprintf(stderr, VT_WHITE);949 fprintf(stderr, VT_WHITE);
949 break;950 break;
951 case TermColorBold:
952 fprintf(stderr, VT_BOLD);
953 break;
950 case TermColorReset:954 case TermColorReset:
951 fprintf(stderr, VT_RESET);955 fprintf(stderr, VT_RESET);
952 break;956 break;
...@@ -989,6 +993,7 @@ void os_stderr_set_color(TermColor color) {...@@ -989,6 +993,7 @@ void os_stderr_set_color(TermColor color) {
989 SetConsoleTextAttribute(stderr_handle, FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);993 SetConsoleTextAttribute(stderr_handle, FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
990 break;994 break;
991 case TermColorWhite:995 case TermColorWhite:
996 case TermColorBold:
992 SetConsoleTextAttribute(stderr_handle,997 SetConsoleTextAttribute(stderr_handle,
993 FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);998 FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
994 break;999 break;
src/os.hpp+1
...@@ -21,6 +21,7 @@ enum TermColor {...@@ -21,6 +21,7 @@ enum TermColor {
21 TermColorGreen,21 TermColorGreen,
22 TermColorCyan,22 TermColorCyan,
23 TermColorWhite,23 TermColorWhite,
24 TermColorBold,
24 TermColorReset,25 TermColorReset,
25};26};
2627