From 1a2252b3e5f902eea19b5f295812c9f9a0686815 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 8 Mar 2011 04:20:46 +0100 Subject: Have a single TextWin in common for each tab, reducing the needed memory, and simplifying its resize (F7 and F8 stuff) --- src/windows.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/windows.py') diff --git a/src/windows.py b/src/windows.py index e6ca9800..7ad382d3 100644 --- a/src/windows.py +++ b/src/windows.py @@ -56,13 +56,17 @@ LINES_NB_LIMIT = 4096 class Win(object): _win_core = None def __init__(self): - pass + self._win = None def _resize(self, height, width, y, x): self.height, self.width, self.x, self.y = height, width, x, y if height == 0 or width == 0: return - self._win = curses.newwin(height, width, y, x) + if not self._win: + self._win = curses.newwin(height, width, y, x) + else: + self._win.resize(height, width) + self._win.mvwin(y, x) def resize(self, height, width, y, x): """ @@ -1456,6 +1460,7 @@ class ListWin(Win): scrolled up and down, with one selected line at a time """ def __init__(self, columns, with_headers=True): + Win.__init__(self) self._columns = columns # a tuple with the name of the columns self._columns_sizes = {} # a dict {'column_name': size} self.sorted_by = (None, None) # for example: ('name', '↑') @@ -1546,6 +1551,7 @@ class ColumnHeaderWin(Win): A class displaying the column's names """ def __init__(self, columns): + Win.__init__(self) self._columns = columns self._columns_sizes = {} @@ -1566,6 +1572,7 @@ class ColumnHeaderWin(Win): class SimpleTextWin(Win): def __init__(self, text): + Win.__init__(self) self._text = text self.built_lines = [] -- cgit v1.2.3