# HG changeset patch # User Radek Brich # Date 1394817803 -3600 # Node ID 2bead23b1262149f72bfe5eca87360b953b86032 # Parent 5cd40c30c4f2dbfe56c70a12a4f5c5ed45f4079f Fix original modules and demos. diff -r 5cd40c30c4f2 -r 2bead23b1262 tuikit/driver.py --- a/tuikit/driver.py Fri Mar 14 10:30:43 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -'''Tuikit driver base.''' - -from tuikit.common import Size, ClipStack, UnicodeGraphics - - -class Driver: - - '''Abstract driver interface. Use as base for drivers.''' - - def __init__(self): - '''Initialize instance attributes.''' - #: Screen size. - self.size = Size() - #: Clipping region stack. - self.clipstack = ClipStack() - #: Unicode graphics characters. - self.unigraph = UnicodeGraphics() - #: Stack of color prefixes. - self.colorprefix = [] - - - ## drawing ## - - def puts(self, x, y, s): - '''Output string of characters.''' - for c in s: - self.putch(x, y, c) - x += 1 - - def hline(self, x, y, w, c=' '): - '''Draw horizontal line.''' - if isinstance(c, str): - s = c*w - else: - s = [c]*w - self.puts(x, y, s) - - def vline(self, x, y, h, c=' '): - '''Draw vertical line.''' - for i in range(h): - self.putch(x, y+i, c) - - def fill_clip(self, c=' '): - """Fill current clip region.""" - rect = self.clipstack.top() - self.fill(rect.x, rect.y, rect.w, rect.h, c) - - def fill(self, x, y, w, h, c=' '): - '''Fill rectangular area.''' - for i in range(h): - self.hline(x, y + i, w, c) - - def frame(self, x, y, w, h): - '''Draw rectangular frame using line-drawing characters.''' - self.putch(x, y, self.unigraph.ULCORNER) - self.putch(x+w-1, y, self.unigraph.URCORNER) - self.putch(x, y+h-1, self.unigraph.LLCORNER) - self.putch(x+w-1, y+h-1, self.unigraph.LRCORNER) - self.hline(x+1, y, w-2, self.unigraph.HLINE) - self.hline(x+1, y+h-1, w-2, self.unigraph.HLINE) - self.vline(x, y+1, h-2, self.unigraph.VLINE) - self.vline(x+w-1, y+1, h-2, self.unigraph.VLINE) - - - ## colors ## - - def pushcolorprefix(self, name): - self.colorprefix.append(name) - - def popcolorprefix(self): - self.colorprefix.pop() - diff -r 5cd40c30c4f2 -r 2bead23b1262 tuikit/driver_base.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tuikit/driver_base.py Fri Mar 14 18:23:23 2014 +0100 @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +'''Tuikit driver base.''' + +from tuikit.common import Size, ClipStack, UnicodeGraphics + + +class Driver: + + '''Abstract driver interface. Use as base for drivers.''' + + def __init__(self): + '''Initialize instance attributes.''' + #: Screen size. + self.size = Size() + #: Clipping region stack. + self.clipstack = ClipStack() + #: Unicode graphics characters. + self.unigraph = UnicodeGraphics() + #: Stack of color prefixes. + self.colorprefix = [] + + + ## drawing ## + + def puts(self, x, y, s): + '''Output string of characters.''' + for c in s: + self.putch(x, y, c) + x += 1 + + def hline(self, x, y, w, c=' '): + '''Draw horizontal line.''' + if isinstance(c, str): + s = c*w + else: + s = [c]*w + self.puts(x, y, s) + + def vline(self, x, y, h, c=' '): + '''Draw vertical line.''' + for i in range(h): + self.putch(x, y+i, c) + + def fill_clip(self, c=' '): + """Fill current clip region.""" + rect = self.clipstack.top() + self.fill(rect.x, rect.y, rect.w, rect.h, c) + + def fill(self, x, y, w, h, c=' '): + '''Fill rectangular area.''' + for i in range(h): + self.hline(x, y + i, w, c) + + def frame(self, x, y, w, h): + '''Draw rectangular frame using line-drawing characters.''' + self.putch(x, y, self.unigraph.ULCORNER) + self.putch(x+w-1, y, self.unigraph.URCORNER) + self.putch(x, y+h-1, self.unigraph.LLCORNER) + self.putch(x+w-1, y+h-1, self.unigraph.LRCORNER) + self.hline(x+1, y, w-2, self.unigraph.HLINE) + self.hline(x+1, y+h-1, w-2, self.unigraph.HLINE) + self.vline(x, y+1, h-2, self.unigraph.VLINE) + self.vline(x+w-1, y+1, h-2, self.unigraph.VLINE) + + + ## colors ## + + def pushcolorprefix(self, name): + self.colorprefix.append(name) + + def popcolorprefix(self): + self.colorprefix.pop() + diff -r 5cd40c30c4f2 -r 2bead23b1262 tuikit/driver_curses.py --- a/tuikit/driver_curses.py Fri Mar 14 10:30:43 2014 +0100 +++ b/tuikit/driver_curses.py Fri Mar 14 18:23:23 2014 +0100 @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -import curses.wrapper +import curses import curses.ascii import math import logging -from tuikit.driver import Driver +from tuikit.driver_base import Driver class DriverCurses(Driver): diff -r 5cd40c30c4f2 -r 2bead23b1262 tuikit/driver_dummy.py --- a/tuikit/driver_dummy.py Fri Mar 14 10:30:43 2014 +0100 +++ b/tuikit/driver_dummy.py Fri Mar 14 18:23:23 2014 +0100 @@ -8,7 +8,7 @@ import logging -from tuikit.driver import Driver +from tuikit.driver_base import Driver class DriverDummy(Driver): diff -r 5cd40c30c4f2 -r 2bead23b1262 tuikit/driver_sdl.py --- a/tuikit/driver_sdl.py Fri Mar 14 10:30:43 2014 +0100 +++ b/tuikit/driver_sdl.py Fri Mar 14 18:23:23 2014 +0100 @@ -6,7 +6,7 @@ ''' -from tuikit.driver import Driver +from tuikit.driver_base import Driver import logging import subprocess