summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-25 13:35:36 -0500
committerpommicket <pommicket@gmail.com>2022-12-25 13:35:36 -0500
commitf67094bce357a76334a717ed669b377d3b93d18e (patch)
tree6721170920a8d78d31a16a532e1e75c740d377d0 /util.c
parent1793fa40528295306d1d790074fdd8f382e8bef3 (diff)
fix various problems from texlab test
Diffstat (limited to 'util.c')
-rw-r--r--util.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/util.c b/util.c
index a87d230..93a7f2c 100644
--- a/util.c
+++ b/util.c
@@ -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__