aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-06-24 02:45:41 +0200
committerPřemysl Janouch <p@janouch.name>2018-06-24 02:45:41 +0200
commitea07d8931c365545131d4829164ac2f1a89d7a66 (patch)
tree4ad1eff8754096c4f93cf4fa0e6f5f83b0d75297
parentb990e7b6a244958519bee62a5c830b8d93f9bc72 (diff)
downloadneetdraw-ea07d8931c365545131d4829164ac2f1a89d7a66.tar.gz
neetdraw-ea07d8931c365545131d4829164ac2f1a89d7a66.tar.xz
neetdraw-ea07d8931c365545131d4829164ac2f1a89d7a66.zip
Cleanup
-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