re-init cycle color
authorVu Nhat Minh <vunhat_minh@dwango.co.jp>
Thu, 3 Jul 2014 07:42:31 +0000 (16:42 +0900)
committerVu Nhat Minh <vunhat_minh@dwango.co.jp>
Thu, 3 Jul 2014 07:42:31 +0000 (16:42 +0900)
rainbowstream/colors.py
rainbowstream/colorset/monokai.json
rainbowstream/rainbow.py

index 909a85a..437584f 100644 (file)
@@ -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):
     """
index 09c6341..a1ba750 100644 (file)
     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",
index 51ab7dd..61eb30b 100644 (file)
@@ -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():