From ea07d8931c365545131d4829164ac2f1a89d7a66 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch
Date: Sun, 24 Jun 2018 02:45:41 +0200 Subject: Cleanup --- autistdraw.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/autistdraw.c b/autistdraw.c index a215fb6..1c0d832 100644 --- a/autistdraw.c +++ b/autistdraw.c @@ -604,34 +604,34 @@ end: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +static const char *g_ansi_table[2 * PALETTE_WIDTH] = +{ + "\033[0m", + "\033[0;40m", + "\033[0;41m", + "\033[0;42m", + "\033[0;43m", + "\033[0;44m", + "\033[0;45m", + "\033[0;46m", + "\033[0;47m", + "\033[0;1;7m", + "\033[0;1;7;30m", + "\033[0;1;7;31m", + "\033[0;1;7;32m", + "\033[0;1;7;33m", + "\033[0;1;7;34m", + "\033[0;1;7;35m", + "\033[0;1;7;36m", + "\033[0;1;7;37m", +}; + static const char * color_to_ansi (uint8_t color) { - static const char *table[2 * PALETTE_WIDTH] = - { - "\033[0m", - "\033[0;40m", - "\033[0;41m", - "\033[0;42m", - "\033[0;43m", - "\033[0;44m", - "\033[0;45m", - "\033[0;46m", - "\033[0;47m", - "\033[0;1;7m", - "\033[0;1;7;30m", - "\033[0;1;7;31m", - "\033[0;1;7;32m", - "\033[0;1;7;33m", - "\033[0;1;7;34m", - "\033[0;1;7;35m", - "\033[0;1;7;36m", - "\033[0;1;7;37m", - }; - - if (color >= sizeof table / sizeof table[0]) - return NULL; - return table[color]; + if (color < N_ELEMENTS (g_ansi_table)) + return g_ansi_table[color]; + return NULL; } static void -- cgit v1.2.3-70-g09d2