cycle-color
authorVu Nhat Minh <vunhat_minh@dwango.co.jp>
Thu, 3 Jul 2014 08:08:34 +0000 (17:08 +0900)
committerVu Nhat Minh <vunhat_minh@dwango.co.jp>
Thu, 3 Jul 2014 08:08:34 +0000 (17:08 +0900)
rainbowstream/colors.py
rainbowstream/draw.py
rainbowstream/rainbow.py

index 437584f..628f635 100644 (file)
@@ -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):
     """
index 148fc58..2586289 100644 (file)
@@ -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):
index 61eb30b..d31533b 100644 (file)
@@ -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'] + ']: ')