nausea

curses audio visualizer
git clone git://git.2f30.org/nausea
Log | Files | Refs | README | LICENSE

commit 7d13978f48f229e52baff150427cb02c2c9b007b
parent 0795e7fb740af7a66c9b502640f2d43350067c0b
Author: lostd <lostd@2f30.org>
Date:   Mon, 25 Aug 2014 19:50:34 +0100

Fix color toggle logic

Diffstat:
Mnausea.c | 20++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/nausea.c b/nausea.c @@ -312,20 +312,17 @@ draw_wave(struct frame *fr) refresh(); } -static int +static void initcolors(void) { unsigned i; struct color_range *cr; - if (has_colors() == FALSE) - return -1; start_color(); for (i = 0; i < LEN(color_ranges); i++) { cr = &color_ranges[i]; init_pair(cr->pair, cr->fg, cr->bg); } - return 0; } static void @@ -376,7 +373,7 @@ main(int argc, char *argv[]) curs_set(FALSE); /* hide cursor */ timeout(msec); - if (colors && initcolors() < 0) { + if (colors && has_colors() == FALSE) { endwin(); done(&fr); errx(1, "your terminal does not support colors"); @@ -388,11 +385,8 @@ main(int argc, char *argv[]) die = 1; break; case 'c': - colors = ~colors; - if (colors) - (void)initcolors(); - else - (void)use_default_colors(); + if (has_colors() == TRUE) + colors = ~colors; break; case 'p': peaks = ~peaks; @@ -405,6 +399,12 @@ main(int argc, char *argv[]) break; } + /* only spectrum supports colors */ + if (colors && (draw == draw_spectrum)) + initcolors(); + else + (void)use_default_colors(); + update(&fr); draw(&fr); }