Add sdlterm to setup.py. Simplify color description, allow missing bg.
--- a/sdlterm/cython/sdlterm.pyx Wed Jan 23 21:59:16 2013 +0100
+++ b/sdlterm/cython/sdlterm.pyx Sun Jan 27 12:54:52 2013 +0100
@@ -1,6 +1,6 @@
# distutils: language = c++
-# distutils: sources = src/sdlterm.cc
-# distutils: include_dirs = /usr/include/SDL src
+# distutils: sources = sdlterm/src/sdlterm.cc
+# distutils: include_dirs = /usr/include/SDL sdlterm/src
# distutils: libraries = SDL SDL_ttf
# distutils: define_macros = _GNU_SOURCE=1 _REENTRANT
# distutils: extra_compile_args = --std=c++11
@@ -86,7 +86,7 @@
def hide_cursor(self):
self.thisptr.hide_cursor()
- def wait_event(self, timeout):
+ def wait_event(self, timeout=None):
if not self.thisptr.wait_event(self.event, timeout or 0):
# timeout
return None
--- a/sdlterm/demo.py Wed Jan 23 21:59:16 2013 +0100
+++ b/sdlterm/demo.py Sun Jan 27 12:54:52 2013 +0100
@@ -1,21 +1,18 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-import sys
-sys.path.insert(0, 'build/lib.linux-x86_64-3.2')
-
from sdlterm import SDLTerminal
if __name__ == '__main__':
term = SDLTerminal()
term.resize(800, 600)
- term.select_font("font/DejaVuSansMono.ttf", "font/DejaVuSansMono-Bold.ttf", 12)
+ term.select_font(b"font/DejaVuSansMono.ttf", b"font/DejaVuSansMono-Bold.ttf", 12)
term.erase()
term.putch(5, 5, 'W')
term.commit()
while True:
- event = term.get_next_event()
+ event = term.wait_event()
print(event)
if event[0] == 'keypress' and event[1] == 'escape':
break
--- a/sdlterm/setup.py Wed Jan 23 21:59:16 2013 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-from distutils.core import setup
-from Cython.Build import cythonize
-
-setup(
- ext_modules = cythonize("cython/sdlterm.pyx")
-)
-
--- a/setup.py Wed Jan 23 21:59:16 2013 +0100
+++ b/setup.py Sun Jan 27 12:54:52 2013 +0100
@@ -1,6 +1,7 @@
#!/usr/bin/env python
from distutils.core import setup
+from Cython.Build import cythonize
setup(
name='tuikit',
@@ -11,5 +12,6 @@
url='http://hg.devl.cz/tuikit/',
keywords=['curses', 'tui', 'toolkit'],
packages=['tuikit'],
+ ext_modules = cythonize("sdlterm/cython/sdlterm.pyx"),
)
--- a/tuikit/application.py Wed Jan 23 21:59:16 2013 +0100
+++ b/tuikit/application.py Sun Jan 27 12:54:52 2013 +0100
@@ -131,10 +131,10 @@
# e.g. "blue (#2020FF) on black (#101010), underline"
# color in brackets is used when driver supports custom colors
driver = self.driver
- driver.setcolor('normal', 'white on black')
+ driver.setcolor('normal', 'lightgray on black')
driver.setcolor('strong', 'white on black, bold')
driver.setcolor('active', 'black on cyan')
- driver.setcolor('window:normal', 'white on blue')
+ driver.setcolor('window:normal', 'lightgray on blue')
driver.setcolor('window:controls', 'white on blue, bold')
driver.setcolor('window:controls-active', 'cyan on blue, bold')
driver.setcolor('button', 'black on white')
--- a/tuikit/driver_curses.py Wed Jan 23 21:59:16 2013 +0100
+++ b/tuikit/driver_curses.py Sun Jan 27 12:54:52 2013 +0100
@@ -53,22 +53,29 @@
)
color_map = {
- 'black' : curses.COLOR_BLACK,
- 'blue' : curses.COLOR_BLUE,
- 'cyan' : curses.COLOR_CYAN,
- 'green' : curses.COLOR_GREEN,
- 'magenta' : curses.COLOR_MAGENTA,
- 'red' : curses.COLOR_RED,
- 'white' : curses.COLOR_WHITE,
- 'yellow' : curses.COLOR_YELLOW,
+ 'black' : (curses.COLOR_BLACK, 0),
+ 'blue' : (curses.COLOR_BLUE, 0),
+ 'green' : (curses.COLOR_GREEN, 0),
+ 'cyan' : (curses.COLOR_CYAN, 0),
+ 'red' : (curses.COLOR_RED, 0),
+ 'magenta' : (curses.COLOR_MAGENTA,0),
+ 'brown' : (curses.COLOR_YELLOW, 0),
+ 'lightgray' : (curses.COLOR_WHITE, 0),
+ 'gray' : (curses.COLOR_BLACK, curses.A_BOLD),
+ 'lightblue' : (curses.COLOR_BLUE, curses.A_BOLD),
+ 'lightgreen' : (curses.COLOR_GREEN, curses.A_BOLD),
+ 'lightcyan' : (curses.COLOR_CYAN, curses.A_BOLD),
+ 'lightred' : (curses.COLOR_RED, curses.A_BOLD),
+ 'lightmagenta' : (curses.COLOR_MAGENTA,curses.A_BOLD),
+ 'yellow' : (curses.COLOR_YELLOW, curses.A_BOLD),
+ 'white' : (curses.COLOR_WHITE, curses.A_BOLD),
}
attr_map = {
+ 'bold' : curses.A_BOLD,
+ 'underline' : curses.A_UNDERLINE,
+ 'standout' : curses.A_STANDOUT, # inverse bg/fg
'blink' : curses.A_BLINK,
- 'bold' : curses.A_BOLD,
- 'dim' : curses.A_DIM,
- 'standout' : curses.A_STANDOUT, # inverse bg/fg
- 'underline' : curses.A_UNDERLINE,
}
def __init__(self):
@@ -126,13 +133,15 @@
def setcolor(self, name, desc):
parts = desc.split(',')
- fg, bg = parts[0].split(' on ')
+ fgbg = parts[0].split(' on ', 1)
+ fg = fgbg[0]
+ bg = fgbg[1:] and fgbg[1] or 'black'
attrs = parts[1:]
- fg = self._parsecolor(fg)
- bg = self._parsecolor(bg)
+ fg, fgattr = self._parsecolor(fg)
+ bg, _bgattr = self._parsecolor(bg)
col = self._getcolorpair(fg, bg)
attr = self._parseattrs(attrs)
- self.colors[name] = curses.color_pair(col) | attr
+ self.colors[name] = curses.color_pair(col) | fgattr | attr
def pushcolor(self, name):
# add prefix if such color is available
--- a/tuikit/driver_dummy.py Wed Jan 23 21:59:16 2013 +0100
+++ b/tuikit/driver_dummy.py Sun Jan 27 12:54:52 2013 +0100
@@ -62,8 +62,11 @@
def setcolor(self, name, desc):
'''Define color name.
- name - name of color (e.g. 'normal', 'active')
- desc - color description - foreground, background, attributes (e.g. 'black on white, bold')
+ Args:
+ name: name of color (e.g. 'normal', 'active')
+ desc: color description - foreground, background, attributes
+ Format: '<fg> [on <bg>][, <attr>[, <attr> ...]]
+ eg. 'white on black, bold'
'''
self.log.info('DummyDriver.setcolor(name=%r, desc=%r)', name, desc)
--- a/tuikit/driver_sdl.py Wed Jan 23 21:59:16 2013 +0100
+++ b/tuikit/driver_sdl.py Sun Jan 27 12:54:52 2013 +0100
@@ -44,7 +44,6 @@
'underline' : 1 << 25, # underline text
'standout' : 1 << 26, # inverse bg/fg
'blink' : 1 << 27, # blinking text
- 'dim' : 0,
}
def __init__(self):
@@ -108,7 +107,9 @@
'''
parts = desc.split(',')
- fg, bg = parts[0].split(' on ')
+ fgbg = parts[0].split(' on ', 1)
+ fg = fgbg[0]
+ bg = fgbg[1:] and fgbg[1] or 'black'
style = parts[1:]
fg = self._color_by_name(fg)
bg = self._color_by_name(bg)