diff options
author | pommicket <pommicket@gmail.com> | 2022-12-25 13:35:36 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-25 13:35:36 -0500 |
commit | f67094bce357a76334a717ed669b377d3b93d18e (patch) | |
tree | 6721170920a8d78d31a16a532e1e75c740d377d0 /util.c | |
parent | 1793fa40528295306d1d790074fdd8f382e8bef3 (diff) |
fix various problems from texlab test
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -21,6 +21,32 @@ static bool is_space(char32_t c) { return c < WCHAR_MAX && iswspace((wint_t)c); } +static bool is_a_tty(FILE *out) { + return + #if __unix__ + isatty(fileno(out)) + #else + false + #endif + ; +} + +static const char *term_italics(FILE *out) { + return is_a_tty(out) ? "\x1b[3m" : ""; +} + +static const char *term_bold(FILE *out) { + return is_a_tty(out) ? "\x1b[1m" : ""; +} + +static const char *term_yellow(FILE *out) { + return is_a_tty(out) ? "\x1b[93m" : ""; +} + +static const char *term_clear(FILE *out) { + return is_a_tty(out) ? "\x1b[0m" : ""; +} + static u8 util_popcount(u64 x) { #ifdef __GNUC__ |