Update theme.md
[rainbowstream.git] / rainbowstream / draw.py
index c2119ff779e03cf0ca77631991ddccf81398f0f2..2fbe51de6336ecbf36ce2375d47ee9dd0142549d 100644 (file)
@@ -15,19 +15,28 @@ from .colors import *
 from .config import *
 from .db import *
 
-
 db = RainbowDB()
+g = {}
+
 
 def init_cycle():
     """
     Init the cycle
     """
     colors_shuffle = [globals()[i.encode('utf8')]
-        if not i.startswith('RGB_')
-        else RGB(int(i[4:]))
+        if not i.startswith('term_')
+        else term_color(int(i[5:]))
         for i in c['CYCLE_COLOR']]
     return itertools.cycle(colors_shuffle)
-cyc = init_cycle()
+g['cyc'] = init_cycle()
+
+
+def notify_cycle():
+    """
+    Notify from rainbow
+    """
+    g['cyc'] = init_cycle()
+
 
 def order_rainbow(s):
     """
@@ -64,7 +73,7 @@ def cycle_color(s):
     """
     Cycle the colors_shuffle
     """
-    return next(cyc)(s)
+    return next(g['cyc'])(s)
 
 
 def ascii_art(text):
@@ -73,7 +82,7 @@ def ascii_art(text):
     """
     fi = figlet_format(text, font='doom')
     print('\n'.join(
-        [next(cyc)(i) for i in fi.split('\n')]
+        [next(g['cyc'])(i) for i in fi.split('\n')]
     ))
 
 
@@ -99,7 +108,7 @@ def check_theme():
             for d in data:
                 c[d] = data[d]
         # Re-init color cycle
-        cyc = init_cycle()
+        g['cyc'] = init_cycle()
 
 
 def color_func(func_name):
@@ -107,8 +116,8 @@ def color_func(func_name):
     Call color function base on name
     """
     pure = func_name.encode('utf8')
-    if pure.startswith('RGB_') and pure[4:].isdigit():
-        return RGB(int(pure[4:]))
+    if pure.startswith('term_') and pure[5:].isdigit():
+        return term_color(int(pure[5:]))
     return globals()[pure]