diff options
author | Daniel Schaal <farbing@web.de> | 2013-08-02 07:59:02 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-08-04 08:33:02 -0400 |
commit | 0b5a519c89b5fb48ec7a3cfbd9c02283ae0f23ac (patch) | |
tree | f97494aceb6e7feb68c2ef554f4fa59485f6e7f1 /src/delta | |
parent | 92d700dea651e2a09ee75c7713b8387f11435cec (diff) |
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.]
Diffstat (limited to 'src/delta')
-rw-r--r-- | src/delta/delta.c | 15 |
1 files changed, 10 insertions, 5 deletions
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; } |