From 77c9b04ecee4b9c3b0074f3e4c09fe08cce2b799 Mon Sep 17 00:00:00 2001 From: Vu Nhat Minh Date: Thu, 3 Jul 2014 16:42:31 +0900 Subject: [PATCH] re-init cycle color --- rainbowstream/colors.py | 17 +++++------------ rainbowstream/colorset/monokai.json | 6 +++--- rainbowstream/rainbow.py | 17 ++++++++++------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/rainbowstream/colors.py b/rainbowstream/colors.py index 909a85a..437584f 100644 --- a/rainbowstream/colors.py +++ b/rainbowstream/colors.py @@ -62,19 +62,12 @@ on_light_magenta = basic_color('105') on_light_cyan = basic_color('106') on_white = basic_color('107') -colors_shuffle = [locals()[i.encode('utf8')] if not i.startswith( - 'RGB_') else RGB(int(i[4:])) for i in c['CYCLE_COLOR']] - -background_shuffle = [ - on_grey, - on_light_red, - on_light_green, - on_light_yellow, - on_light_blue, - on_light_magenta, - on_light_cyan] -cyc = itertools.cycle(colors_shuffle[1:]) +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) +init_cycle() def order_rainbow(s): """ diff --git a/rainbowstream/colorset/monokai.json b/rainbowstream/colorset/monokai.json index 09c6341..a1ba750 100644 --- a/rainbowstream/colorset/monokai.json +++ b/rainbowstream/colorset/monokai.json @@ -22,10 +22,10 @@ http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html */ - "DECORATED_NAME" : "RGB_166", + "DECORATED_NAME" : "RGB_198", "CYCLE_COLOR" :["RGB_198","RGB_57","RGB_166","RGB_50","RGB_179","RGB_74","RGB_112"], "TWEET" : { - "nick" : "RGB_198", + "nick" : "RGB_112", "clock" : "RGB_57", "id" : "RGB_166", "favourite" : "RGB_50", @@ -35,7 +35,7 @@ }, "MESSAGE" : { - "sender" : "RGB_198", + "sender" : "RGB_112", "recipient" : "RGB_112", "to" : "RGB_50", "clock" : "RGB_57", diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 51ab7dd..61eb30b 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -775,12 +775,14 @@ def theme(): # Detect custom config if theme == 'custom': line += light_magenta('custom') - exists = db.theme_query() - themes = [t.theme_name for t in exists] - if themes[0] == 'custom': - line += light_magenta(' (applied)') + custom_path = os.environ.get( + 'HOME', + os.environ.get('USERPROFILE', + '')) + os.sep + '.rainbow_config.json' + if not os.path.exists(custom_path): + line += light_magenta(' (create your own config at ~/.rainbow_config.json)') else: - line += light_magenta(' (not specified)') + line += light_magenta(' (loaded)') else: line += light_magenta(theme) if c['theme'] == theme : @@ -797,14 +799,15 @@ def theme(): if new_config: for nc in new_config: c[nc] = new_config[nc] - # Update db + # Update db and reset colors db.theme_update(g['stuff']) + init_cycle() g['decorated_name'] = color_func( c['DECORATED_NAME'])( '[@' + g['original_name'] + ']: ') printNicely(green('Theme changed.')) except: - printNicely(red('Sorry, config file is broken!')) + printNicely(red('Sorry, can not load config file!')) def help(): -- 2.25.1