diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2023-07-02 19:56:30 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2023-07-02 19:56:46 +0200 |
| commit | 23bf7973fa571088cb5080d78d04a798a2cc1e7c (patch) | |
| tree | 09d7e24d0891c76e6a9d8f8ff9822be7c11cc076 /src/main.cpp | |
| parent | cdcb64b0d08be85c3ea579270eeb4d193b4cb495 (diff) | |
detect unix color support
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2198b4536..d66ec5846 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2547,6 +2547,10 @@ gb_internal int strip_semicolons(Parser *parser) { return cast(int)failed; } +#if defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX) +#include <stdio.h> +#endif + gb_internal void init_terminal(void) { build_context.has_ansi_terminal_colours = false; #if defined(GB_SYSTEM_WINDOWS) @@ -2558,6 +2562,18 @@ gb_internal void init_terminal(void) { build_context.has_ansi_terminal_colours = true; } } +#elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX) + FILE* file = popen("tput colors", "r"); + if (file) { + char buffer[20]; + if (fgets(&buffer[0], 20, file)) { + u64 colors = gb_str_to_u64(buffer, nullptr, 10); + if (colors >= 8) { + build_context.has_ansi_terminal_colours = true; + } + } + pclose(file); + } #endif if (!build_context.has_ansi_terminal_colours) { |