21#if __has_include(<unistd.h>)
25#if __has_include(<sys/ioctl.h>)
26 #include <sys/ioctl.h>
33 bool compute_is_a_tty() {
34#if __has_include(<unistd.h>)
35 return isatty(fileno(stdout));
46 static bool cached = compute_is_a_tty();
76#if __has_include(<sys/ioctl.h>) && __has_include(<unistd.h>)
78 ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
81 if (w.ws_col == 0 || w.ws_row == 0) {
84 return {w.ws_row, w.ws_col};
bool utf8_supported
Whether the current terminal/locale supports UTF-8 output, as set by set_support_utf8.
std::pair< int, int > get_tty_dim()
Get the number of columns and lines of the current terminal.
This file contains tty info getters.
int get_tty_columns()
Get the number of columns of the current terminal.
void set_tty_columns(int columns)
Set the forced width of the terminal.
void set_support_utf8(bool support)
Set whether the current terminal/locale supports UTF-8 output.
bool support_utf8()
Query whether the current terminal/locale supports UTF-8 output.
int get_tty_lines()
Get the number of lines of the current terminal.
bool is_a_tty()
Test if current terminal is a tty.