diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-09-11 04:17:17 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-09-11 04:17:17 +0200 |
commit | 362ff75e3239110b596429fd142487add12e08a4 (patch) | |
tree | 0b405cd9ebe8b9a6edb5fdfcbb64e73a42fb59d8 /src | |
parent | 1a485318bfc1a3db4cd970785029eeb8b03bf0b3 (diff) | |
download | poezio-362ff75e3239110b596429fd142487add12e08a4.tar.gz poezio-362ff75e3239110b596429fd142487add12e08a4.tar.bz2 poezio-362ff75e3239110b596429fd142487add12e08a4.tar.xz poezio-362ff75e3239110b596429fd142487add12e08a4.zip |
fixes crashes on too small size (except on the /configure tab, but that’s an other issue)
fixes #2186
Diffstat (limited to 'src')
-rw-r--r-- | src/tabs.py | 18 | ||||
-rw-r--r-- | src/windows.py | 8 |
2 files changed, 22 insertions, 4 deletions
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): |