%C escape suspends colors as well as attributes
authorJack Miller <jack@codezen.org>
Tue, 24 Mar 2015 20:10:45 +0000 (15:10 -0500)
committerJack Miller <jack@codezen.org>
Tue, 24 Mar 2015 20:12:34 +0000 (15:12 -0500)
canto_curses/story.py
canto_curses/tag.py
canto_curses/theme.py

index 36e16f4..0aa80a7 100644 (file)
@@ -329,9 +329,9 @@ class Story(PluginHandler):
         taglist_conf = self.callbacks["get_opt"]("taglist")
 
         if taglist_conf["border"]:
-            self.left = "%C%B%1" + theme_border("ls") + "%0%b %c"
-            self.left_more = "%C%B%1" + theme_border("ls") + "%0%b     %c"
-            self.right = "%C %B%1" + theme_border("rs") + "%0%b%c"
+            self.left = "%C%B" + theme_border("ls") + "%b %c"
+            self.left_more = "%C%B" + theme_border("ls") + "%b     %c"
+            self.right = "%C %B" + theme_border("rs") + "%b%c"
         else:
             self.left = "%C %c"
             self.left_more = "%C     %c"
index 0e6c482..a636d08 100644 (file)
@@ -341,7 +341,7 @@ class Tag(PluginHandler, list):
 
             if not self.collapsed and self.border:
                 theme_print(pad, theme_border("ts") * (width - 2), width,\
-                        "%B%1"+ theme_border("tl"), theme_border("tr") + "%0%b")
+                        "%B"+ theme_border("tl"), theme_border("tr") + "%b")
                 lines += 1
         except Exception as e:
             tb = traceback.format_exc()
@@ -355,7 +355,7 @@ class Tag(PluginHandler, list):
     def render_footer(self, width, pad):
         if not self.collapsed and self.border:
             theme_print(pad, theme_border("bs") * (width - 2), width,\
-                    "%B%1" + theme_border("bl"), theme_border("br") + "%0%b")
+                    "%B" + theme_border("bl"), theme_border("br") + "%b")
             theme_reset()
             return 1
         return 0
index 34d3eb9..5356508 100644 (file)
@@ -32,6 +32,7 @@ attr_map = { "B" : curses.A_BOLD,
 #   %0      turns on the previously enabled color
 
 color_stack = []
+color_stack_suspended = []
 
 # Return length of next string of non-space characters
 # or 0 if next character *is* a space.
@@ -176,12 +177,23 @@ def theme_print_one(pad, uni, width):
             elif c == "C":
                 for attr in attr_map:
                     pad.attroff(attr_map[attr])
+                for color in reversed(color_stack):
+                    pad.attroff(curses.color_pair(color))
+                pad.attron(curses.color_pair(0))
+                color_stack_suspended = color_stack
+                color_stack = []
 
             # Restore attributes
             elif c == "c":
                 for attr in attr_map:
                     if attr_count[attr]:
                         pad.attron(attr_map[attr])
+                color_stack = color_stack_suspended
+                color_stack_suspended = []
+                if color_stack:
+                    pad.attron(curses.color_pair(color_stack[-1]))
+                else:
+                    pad.attron(curses.color_pair(0))
             elif c == "[":
                 long_code = True
             code = False