summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-12-26 20:51:14 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-12-26 20:51:14 +0000
commitcdb8128d321c16bf526afdbd7d790fc6189239b3 (patch)
tree731f205c25b6ae1dfe2069216ecd103a2dcee7cf /src/windows.py
parent133cda19128b80cf52bcf3c9b16c467d30a56c7c (diff)
downloadpoezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.tar.gz
poezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.tar.bz2
poezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.tar.xz
poezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.zip
fixed #1988 Traceback handler
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/windows.py b/src/windows.py
index a7cee054..7161b0dd 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -49,7 +49,7 @@ import theme
g_lock = Lock()
-LINES_NB_LIMIT = 16384
+LINES_NB_LIMIT = 4096
class Win(object):
def __init__(self):
@@ -1425,16 +1425,35 @@ class ColumnHeaderWin(Win):
x += size
self._refresh()
-# class SimpleTextWin(Win):
-# def __init__(self, text):
-# self._text = text
-# self.built_lines = []
+class SimpleTextWin(Win):
+ def __init__(self, text):
+ self._text = text
+ self.built_lines = []
-# def resize(self, height, width, y, x, stdscr):
-# self._resize(height, width, y, x, stdscr)
-# self.rebuild_text()
+ def resize(self, height, width, y, x, stdscr):
+ self._resize(height, width, y, x, stdscr)
+ self.rebuild_text()
-# def rebuild_text(self):
-
-# def refresh(self):
-# pass
+ def rebuild_text(self):
+ """
+ Transform the text in lines than can then be
+ displayed without any calculation or anything
+ at refresh() time
+ It is basically called on each resize
+ """
+ self.built_lines = []
+ for line in self._text.split('\n'):
+ while len(line) >= self.width:
+ limit = line[:self.width].rfind(' ')
+ if limit <= 0:
+ limit = self.width
+ self.built_lines.append(line[:limit])
+ line = line[limit:]
+ self.built_lines.append(line)
+
+ def refresh(self):
+ with g_lock:
+ self._win.erase()
+ for y, line in enumerate(self.built_lines):
+ self.addstr(y, 0, line)
+ self._refresh()