Make color print correctly after a line

This commit is contained in:
Night Kaly 2024-11-02 16:39:10 +00:00
parent d3ab344b23
commit 14ecd17a9a
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM

6
ccc.c
View file

@ -976,6 +976,12 @@ void show_file_content()
putchar('\n'); putchar('\n');
} }
/* Check if the line ends with the ANSI reset sequence `\033[0m` */
size_t len = strlen(buffer);
if (len >= 4 && strcmp(&buffer[len - 4], "\033[0m") == 0) {
/* Line ends with ANSI reset, print it */
printf("\033[0m");
}
} }
fclose(stream); fclose(stream);
} }