commit: 743b2f83cd2f304dca7df2d4223d8d59312fb584
parent: aaced5a847f17d43b56cc1b0605d51ae01af1d6e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 9 Apr 2020 11:49:57 +0200
src/xcd.c: reset color before printing characters
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/xcd.c b/src/xcd.c
@@ -7,7 +7,10 @@
#include <string.h> /* memset() */
#include <ctype.h> /* isprint() */
-void rainbow(double freq, int i) {
+#define LANODAN_XCD_RESET printf("[0m[48;2;0;0;0m");
+#define LANODAN_XCD_PRINT printf(" >%s<", line);
+
+void rainbow(double freq, char i) {
uint8_t red, green, blue;
double pi = 3.14159;
@@ -26,7 +29,7 @@ int main(void) {
memset(&line, 0, line_width);
- printf("[48;2;0;0;0m");
+ LANODAN_XCD_RESET
rainbow(freq, bytes);
printf("%06x ", bytes);
@@ -35,7 +38,8 @@ int main(void) {
if(cols >= line_width) {
cols = 0;
- printf(" >%s<", line);
+ LANODAN_XCD_RESET
+ LANODAN_XCD_PRINT
memset(&line, 0, line_width);
rainbow(freq, bytes);
@@ -54,10 +58,12 @@ int main(void) {
// Fill the rest of the hex space with spaces
for(cols; cols < line_width; cols++) printf(" ");
- printf(" >%s<", line);
+ LANODAN_XCD_RESET
+ LANODAN_XCD_PRINT
rainbow(freq, bytes);
printf("\n%06x\n", bytes);
+ LANODAN_XCD_RESET
return 0;
}