From eb322687409127e0519f1305ce1763fab10508ce Mon Sep 17 00:00:00 2001 From: Steven Schubiger Date: Sat, 3 Aug 2024 23:00:20 +0200 Subject: Don't increment rainbow color with partial line --- colorize.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'colorize.c') diff --git a/colorize.c b/colorize.c index 3da2b6c..eb8f7c0 100644 --- a/colorize.c +++ b/colorize.c @@ -74,6 +74,7 @@ #define LF 0x01 #define CR 0x02 +#define PARTIAL 0x04 #define COUNT_OF(obj, type) (sizeof (obj) / sizeof (type)) @@ -1376,13 +1377,15 @@ read_print_stream (const char *attr, const struct color **colors, const char *fi if (feof (stream)) { if (*line != '\0') - print_line (attr, colors, line, 0, true); + print_line (attr, colors, line, PARTIAL, true); } else if (*line != '\0') { char *p; if ((clean || clean_all) && (p = strrchr (line, '\033'))) merge_print_line (line, p, stream); + else if (rainbow_fg || rainbow_bg) + print_line (attr, colors, line, PARTIAL, true); else print_line (attr, colors, line, 0, true); } @@ -1625,7 +1628,8 @@ print_line (const char *attr, const struct color **colors, const char *const lin colors[color_iter] = (struct color *)&tables[color_iter].entries[index]; - rainbow_index = index + 1; + if (!(flags & PARTIAL)) + rainbow_index = index + 1; } /* Foreground color code is guaranteed to be set when background color code is present. */ -- cgit v1.2.3