From: Lukáš Jiřiště Date: Mon, 11 Mar 2024 13:17:06 +0000 (+0100) Subject: Add color to the output X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=c354708d806432ce1b1881c538c6246c9e3358fc;p=palboss.git Add color to the output --- diff --git a/src/main.c b/src/main.c index 07cbdd0..91d783b 100644 --- a/src/main.c +++ b/src/main.c @@ -60,16 +60,24 @@ time_t get_time_sec(void) void print_entry(t_entry *entry) { - int countdown; + int countdown; + char *color; + static const char *reset_color = "\033[0m"; countdown = 3600 - (get_time_sec() - entry->kill_time); countdown = ft_max(0, countdown); - ft_printf(" %-20s%5i %-20s%2i:%02i", + if (countdown == 0) + color = "\033[42m"; + else + color = "\033[0m"; + ft_printf("%s %-20s%5i %-20s%2i:%02i%s", + color, entry->name, entry->level, entry->biome, countdown / 60, - countdown % 60); + countdown % 60, + reset_color); return ; }