|
Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
|
Implementation of terminal color support detection. More...
#include <stdio.h>#include <stdbool.h>#include <stdlib.h>#include <string.h>#include "color.h"#include <unistd.h>
Functions | |
| bool | terminal_supports_color (void) |
| Checks if the current terminal supports ANSI color escape sequences. | |
Implementation of terminal color support detection.
This module provides the function terminal_supports_color() which detects if the current terminal supports ANSI color escape sequences. It caches the result to avoid redundant system calls.
On Windows, it attempts to enable ANSI support on modern terminals (Windows Terminal, VS Code terminal, ConEmu, Cmder) by enabling virtual terminal processing. On Unix-like systems, it checks environment variables and terminal capabilities to determine color support.
| bool terminal_supports_color | ( | void | ) |
Checks if the current terminal supports ANSI color escape sequences.
Checks if the terminal supports ANSI color escape sequences.
This function determines whether the terminal connected to standard output supports colored output using ANSI escape sequences.
The result is cached after the first call for efficiency.
On Windows:
On Unix/Linux:
tput colors command to verify the number of colors supported.