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() -