From 0b5a519c89b5fb48ec7a3cfbd9c02283ae0f23ac Mon Sep 17 00:00:00 2001 From: Daniel Schaal Date: Fri, 2 Aug 2013 07:59:02 +0200 Subject: systemd-delta: Only print colors when on a tty This make systemd-delta follow the behaviour of systemctl and journalctl. https://bugs.freedesktop.org/show_bug.cgi?id=67656 [zj: unify color query methods between those three programs.] --- src/delta/delta.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/delta') diff --git a/src/delta/delta.c b/src/delta/delta.c index 49c2fc323a..b3272d916e 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -66,7 +66,8 @@ static int notify_override_masked(const char *top, const char *bottom) { if (!(arg_flags & SHOW_MASKED)) return 0; - printf(ANSI_HIGHLIGHT_RED_ON "[MASKED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + printf("%s%s%s %s → %s\n", + ansi_highlight_red(), "[MASKED]", ansi_highlight_off(), top, bottom); return 1; } @@ -74,7 +75,8 @@ static int notify_override_equivalent(const char *top, const char *bottom) { if (!(arg_flags & SHOW_EQUIVALENT)) return 0; - printf(ANSI_HIGHLIGHT_GREEN_ON "[EQUIVALENT]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + printf("%s%s%s %s → %s\n", + ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight(), top, bottom); return 1; } @@ -82,7 +84,8 @@ static int notify_override_redirected(const char *top, const char *bottom) { if (!(arg_flags & SHOW_REDIRECTED)) return 0; - printf(ANSI_HIGHLIGHT_ON "[REDIRECTED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + printf("%s%s%s %s → %s\n", + ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(), top, bottom); return 1; } @@ -90,7 +93,8 @@ static int notify_override_overridden(const char *top, const char *bottom) { if (!(arg_flags & SHOW_OVERRIDDEN)) return 0; - printf(ANSI_HIGHLIGHT_ON "[OVERRIDDEN]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + printf("%s%s%s %s → %s\n", + ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(), top, bottom); return 1; } @@ -98,7 +102,8 @@ static int notify_override_extended(const char *top, const char *bottom) { if (!(arg_flags & SHOW_EXTENDED)) return 0; - printf(ANSI_HIGHLIGHT_ON "[EXTENDED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + printf("%s%s%s %s → %s\n", + ansi_highlight(), "[EXTENDED]", ansi_highlight_off(), top, bottom); return 1; } -- cgit v1.2.3