summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
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__