aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autistdraw.c50
1 files 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