From 9c7342ca2f74dcafad845ca0010013181e2ca16f Mon Sep 17 00:00:00 2001 From: Vu Nhat Minh Date: Thu, 3 Jul 2014 17:08:34 +0900 Subject: [PATCH] cycle-color --- rainbowstream/colors.py | 10 ++++++---- rainbowstream/draw.py | 5 +++-- rainbowstream/rainbow.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/rainbowstream/colors.py b/rainbowstream/colors.py index 437584f..628f635 100644 --- a/rainbowstream/colors.py +++ b/rainbowstream/colors.py @@ -63,11 +63,13 @@ on_light_cyan = basic_color('106') on_white = basic_color('107') def init_cycle(): - colors_shuffle = [locals()[i.encode('utf8')] if not i.startswith( - 'RGB_') else RGB(int(i[4:])) for i in c['CYCLE_COLOR']] - cyc = itertools.cycle(colors_shuffle) + colors_shuffle = [globals()[i.encode('utf8')] + if not i.startswith('RGB_') + else RGB(int(i[4:])) + for i in c['CYCLE_COLOR']] + return itertools.cycle(colors_shuffle) -init_cycle() +cyc = init_cycle() def order_rainbow(s): """ diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 148fc58..2586289 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -27,8 +27,7 @@ def check_theme(): if c['theme'] == 'custom': config = os.environ.get( 'HOME', - os.environ.get( - 'USERPROFILE', + os.environ.get('USERPROFILE', '')) + os.sep + '.rainbow_config.json' else: config = 'rainbowstream/colorset/'+c['theme']+'.json' @@ -37,6 +36,8 @@ def check_theme(): if data: for d in data: c[d] = data[d] + # Re-init color cycle + cyc = init_cycle() def color_func(func_name): diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 61eb30b..d31533b 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -801,7 +801,7 @@ def theme(): c[nc] = new_config[nc] # Update db and reset colors db.theme_update(g['stuff']) - init_cycle() + cyc = init_cycle() g['decorated_name'] = color_func( c['DECORATED_NAME'])( '[@' + g['original_name'] + ']: ') -- 2.25.1