--- a/tuikit/driver_curses.py Tue Oct 11 10:09:58 2011 +0200
+++ b/tuikit/driver_curses.py Wed Oct 12 00:58:46 2011 +0200
@@ -47,7 +47,7 @@
(0x1b,0x5b,0x5b,0x45, 'f5' ), # linux
)
- color_names = {
+ color_map = {
'black' : curses.COLOR_BLACK,
'blue' : curses.COLOR_BLUE,
'cyan' : curses.COLOR_CYAN,
@@ -58,6 +58,14 @@
'yellow' : curses.COLOR_YELLOW,
}
+ attr_map = {
+ 'blink' : curses.A_BLINK,
+ 'bold' : curses.A_BOLD,
+ 'dim' : curses.A_DIM,
+ 'standout' : curses.A_STANDOUT,
+ 'underline' : curses.A_UNDERLINE,
+ }
+
def __init__(self):
'''Set driver attributes to default values.'''
Driver.__init__(self)
@@ -67,7 +75,6 @@
self.colors = {} # maps names to curses attributes
self.colorpairs = {} # maps tuple (fg,bg) to curses color_pair
self.colorstack = [] # pushcolor/popcolor puts or gets attributes from this
- self.colorprefix = [] # stack of color prefixes
self.inputqueue = []
self.mbtnstack = []
@@ -92,7 +99,7 @@
def _parsecolor(self, name):
name = name.lower().strip()
- return self.color_names[name]
+ return self.color_map[name]
def _getcolorpair(self, fg, bg):
pair = (fg, bg)
@@ -107,14 +114,7 @@
res = 0
for a in attrs:
a = a.lower().strip()
- trans = {
- 'blink' : curses.A_BLINK,
- 'bold' : curses.A_BOLD,
- 'dim' : curses.A_DIM,
- 'standout' : curses.A_STANDOUT,
- 'underline' : curses.A_UNDERLINE,
- }
- res = res | trans[a]
+ res = res | self.attr_map[a]
return res
def setcolor(self, name, desc):
@@ -128,7 +128,7 @@
self.colors[name] = curses.color_pair(col) | attr
def pushcolor(self, name):
- # add prefix if available
+ # add prefix if such color is available
if len(self.colorprefix):
prefixname = self.colorprefix[-1] + name
if prefixname in self.colors:
@@ -144,13 +144,7 @@
else:
attr = 0
self.screen.attrset(attr)
-
- def pushcolorprefix(self, name):
- self.colorprefix.append(name)
-
- def popcolorprefix(self):
- self.colorprefix.pop()
-
+
## drawing ##