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 437584f1b8bb89e8bb5da2ee3bbee9049486784c..628f6350d3116c45c29cd70a453f19ee1cffc8f1 100644 (file)
@@ -63,11 +63,13 @@ on_light_cyan = basic_color('106')
 on_white = basic_color('107')
 
 def init_cycle():
 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):
     """
 
 def order_rainbow(s):
     """
index 148fc5884456378dfa81f376f6e8bec921510f39..2586289d8e85c100d7330f86738616805c19e93b 100644 (file)
@@ -27,8 +27,7 @@ def check_theme():
         if c['theme'] == 'custom':
             config = os.environ.get(
                 'HOME',
         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'
                 '')) + 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]
         if data:
             for d in data:
                 c[d] = data[d]
+        # Re-init color cycle
+        cyc = init_cycle()
 
 
 def color_func(func_name):
 
 
 def color_func(func_name):
index 61eb30b4c8de82c60907c6a0c0725655754e8f23..d31533b029f6dbfe579a71cd0f024e8a24e55e5d 100644 (file)
@@ -801,7 +801,7 @@ def theme():
                     c[nc] = new_config[nc]
             # Update db and reset colors
             db.theme_update(g['stuff'])
                     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'] + ']: ')
             g['decorated_name'] = color_func(
                 c['DECORATED_NAME'])(
                 '[@' + g['original_name'] + ']: ')