summaryrefslogtreecommitdiff
path: root/urwid/graphics.py
diff options
context:
space:
mode:
authorian <none@none>2006-10-01 21:41:31 +0000
committerian <none@none>2006-10-01 21:41:31 +0000
commit7e0726fca169fba7aa0f043e45450c4bf0822568 (patch)
tree384b25f7ebaf159bb632f1382c72c4c3aec46551 /urwid/graphics.py
parent497631240af8acaa045555555d21aa7ce430b1f8 (diff)
downloadurwid-7e0726fca169fba7aa0f043e45450c4bf0822568.tar.gz
release 0.9.7release-0.9.7
--HG-- extra : convert_revision : ba9ea5bad833b377739bd193bb8124e8b90e7507
Diffstat (limited to 'urwid/graphics.py')
-rwxr-xr-xurwid/graphics.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/urwid/graphics.py b/urwid/graphics.py
index 07179ed..8063300 100755
--- a/urwid/graphics.py
+++ b/urwid/graphics.py
@@ -30,6 +30,61 @@ from escape import utf8decode
try: True # old python?
except: False, True = 0, 1
+class BigText(FixedWidget):
+ def __init__(self, markup, font):
+ """
+ markup -- same as Text widget markup
+ font -- instance of a Font class
+ """
+ self.set_font(font)
+ self.set_text(markup)
+
+ def set_text(self, markup):
+ self.text, self.attrib = decompose_tagmarkup(markup)
+
+ def get_text(self):
+ """
+ Returns (text, attributes).
+ """
+ return self.text, self.attrib
+
+ def set_font(self, font):
+ self.font = font
+
+ def pack(self, size=None, focus=False):
+ rows = self.font.height
+ cols = 0
+ for c in self.text:
+ cols += self.font.char_width(c)
+ return cols, rows
+
+ def render(self, size, focus=False):
+ fixed_size(size) # complain if parameter is wrong
+ a = None
+ ai = ak = 0
+ o = []
+ rows = self.font.height
+ cols = 0
+ attrib = self.attrib+[(None,len(self.text))]
+ for ch in self.text:
+ if not ak:
+ a, ak = attrib[ai]
+ ai += 1
+ ak -= 1
+ width = self.font.char_width(ch)
+ if not width:
+ # ignore invalid characters
+ continue
+ c = self.font.render(ch)
+ c.fill_attr(a)
+ o.append(c)
+ cols += width
+ o.append(width)
+
+ if o:
+ return CanvasJoin(o[:-1])
+ return Canvas([""]*rows, maxcol=0)
+
class LineBox(WidgetWrap):
def __init__(self, w):