From 362ff75e3239110b596429fd142487add12e08a4 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 11 Sep 2011 04:17:17 +0200 Subject: =?UTF-8?q?fixes=20crashes=20on=20too=20small=20size=20(except=20o?= =?UTF-8?q?n=20the=20/configure=20tab,=20but=20that=E2=80=99s=20an=20other?= =?UTF-8?q?=20issue)=20fixes=20#2186?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tabs.py | 18 +++++++++++++++--- src/windows.py | 8 +++++++- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/tabs.py b/src/tabs.py index af4de010..d2145d54 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -14,7 +14,7 @@ Windows are displayed, resized, etc """ MIN_WIDTH = 50 -MIN_HEIGHT = 16 +MIN_HEIGHT = 22 import logging log = logging.getLogger(__name__) @@ -83,6 +83,10 @@ class Tab(object): @staticmethod def resize(scr): Tab.size = (Tab.height, Tab.width) = scr.getmaxyx() + if Tab.height < MIN_HEIGHT or Tab.width < MIN_WIDTH: + Tab.visible = False + else: + Tab.visible = True def complete_commands(self, the_input): """ @@ -666,6 +670,8 @@ class MucTab(ChatTab): """ Resize the whole window. i.e. all its sub-windows """ + if not self.visible: + return text_width = (self.width//10)*9 self.topic_win.resize(1, self.width, 0, 0) self.v_separator.resize(self.height-3, 1, 1, 9*(self.width//10)) @@ -1015,7 +1021,7 @@ class PrivateTab(ChatTab): self.core.close_tab() def resize(self): - if self.core.information_win_size >= self.height-3: + if self.core.information_win_size >= self.height-3 or not self.visible: return self.text_win.resize(self.height-3-self.core.information_win_size, self.width, 0, 0) self.text_win.rebuild_everything(self._room) @@ -1164,6 +1170,8 @@ class RosterInfoTab(Tab): self.resize() def resize(self): + if not self.visible: + return roster_width = self.width//2 info_width = self.width-roster_width-1 self.v_separator.resize(self.height-2, 1, 0, roster_width) @@ -1519,7 +1527,7 @@ class ConversationTab(ChatTab): self.core.close_tab() def resize(self): - if self.core.information_win_size >= self.height-3: + if self.core.information_win_size >= self.height-3 or not self.visible: return self.text_win.resize(self.height-4-self.core.information_win_size, self.width, 1, 0) self.text_win.rebuild_everything(self._room) @@ -1638,6 +1646,8 @@ class MucListTab(Tab): self.input.refresh() def resize(self): + if not self.visible: + return self.upper_message.resize(1, self.width, 0, 0) column_size = {'node-part': (self.width-5)//4, 'name': (self.width-5)//4*3, @@ -1766,6 +1776,8 @@ class SimpleTextTab(Tab): self.core.close_tab() def resize(self): + if not self.visible: + return self.text_win.resize(self.height-2, self.width, 0, 0) self.tab_win.resize(1, self.width, self.height-2, 0) self.input.resize(1, self.width, self.height-1, 0) diff --git a/src/windows.py b/src/windows.py index 7d138ad2..5b673c21 100644 --- a/src/windows.py +++ b/src/windows.py @@ -93,6 +93,12 @@ class Win(object): except: pass + def move(self, y, x): + try: + self._win.move(y, x) + except: + self._win.move(0, 0) + def addstr_colored(self, text, y=None, x=None): """ Write a string on the window, setting the @@ -105,7 +111,7 @@ class Win(object): one of 'u', 'b', 'c[0-9]' """ if y is not None and x is not None: - self._win.move(y, x) + self.move(y, x) next_attr_char = text.find('\x19') while next_attr_char != -1: if next_attr_char + 1 < len(text): -- cgit v1.2.3