From f08f43d706db3dc7a9e6c8e5fbf0fbf5883b4a4e Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 16 Aug 2016 12:20:27 -0300 Subject: [PATCH] eeshow/fig.c: output all user-defined colors --- eeshow/fig.c | 12 +++++++----- eeshow/style.c | 3 +++ eeshow/style.h | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/eeshow/fig.c b/eeshow/fig.c index 859a5ce..4735c5c 100644 --- a/eeshow/fig.c +++ b/eeshow/fig.c @@ -201,10 +201,12 @@ static void fig_header(void) } -static void fig_color32(void) +static void fig_colors(void) { - /* User32, COLOR_DARK_YELLOW */ - printf("0 32 #848400\n"); + unsigned i; + + for (i = 32; i != n_color_rgb; i++) + printf("0 %d #%06x\n", i, color_rgb[i]); } @@ -266,7 +268,7 @@ static void *fig_init(int argc, char *const *argv) if (!template) { fig_header(); - fig_color32(); + fig_colors(); return NULL; } @@ -279,7 +281,7 @@ static void *fig_init(int argc, char *const *argv) if (*buf == '#') continue; if (!--lines_to_colors) - fig_color32(); + fig_colors(); /* * @@@ known bug: if the template is empty, we won't output * color 32. diff --git a/eeshow/style.c b/eeshow/style.c index 3e0f21c..85f4138 100644 --- a/eeshow/style.c +++ b/eeshow/style.c @@ -12,6 +12,7 @@ #include +#include "util.h" #include "style.h" @@ -37,3 +38,5 @@ uint32_t color_rgb[] = { [COLOR_DARK_YELLOW] = 0x848400, [COLOR_LIGHT_GREY] = 0xd0d0d0, }; + +unsigned n_color_rgb = ARRAY_ELEMENTS(color_rgb); diff --git a/eeshow/style.h b/eeshow/style.h index cfeba00..80e3597 100644 --- a/eeshow/style.h +++ b/eeshow/style.h @@ -97,5 +97,6 @@ #define MISSING_HEIGHT 300 extern uint32_t color_rgb[]; +extern unsigned n_color_rgb; #endif /* !STYLE_H */