summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-03-08 04:20:46 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-03-08 04:20:46 +0100
commit1a2252b3e5f902eea19b5f295812c9f9a0686815 (patch)
treeffd3bde93a278d6be063376e92dc19bc6546df96 /src/core.py
parent8f48c5ede7e1da18f85daae9bda5a4b68272498b (diff)
downloadpoezio-1a2252b3e5f902eea19b5f295812c9f9a0686815.tar.gz
poezio-1a2252b3e5f902eea19b5f295812c9f9a0686815.tar.bz2
poezio-1a2252b3e5f902eea19b5f295812c9f9a0686815.tar.xz
poezio-1a2252b3e5f902eea19b5f295812c9f9a0686815.zip
Have a single TextWin in common for each tab, reducing the needed memory, and simplifying its resize (F7 and F8 stuff)
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/core.py b/src/core.py
index 99ae27d1..d42093ef 100644
--- a/src/core.py
+++ b/src/core.py
@@ -89,6 +89,8 @@ class Core(object):
# information window.
self.information_buffer = TextBuffer()
self.information_win_size = config.get('info_win_height', 2, 'var')
+ self.information_win = windows.TextWin(20)
+ self.information_buffer.add_window(self.information_win)
self.tabs = []
self.previous_tab_nb = 0
self.own_nick = config.get('own_nick', '') or self.xmpp.boundjid.user
@@ -168,6 +170,10 @@ class Core(object):
"""
self.stdscr = curses.initscr()
self.init_curses(self.stdscr)
+ # Init the tab's size.
+ tabs.Tab.resize(self.stdscr)
+ # resize the information_win to its initial size
+ self.resize_global_information_win()
default_tab = tabs.InfoTab() if self.xmpp.anon\
else tabs.RosterInfoTab()
default_tab.on_gain_focus()
@@ -175,6 +181,13 @@ class Core(object):
self.information(_('Welcome to poezio!'))
self.refresh_window()
+ def resize_global_information_win(self):
+ """
+ Resize the global_information_win only once at each resize.
+ """
+ self.information_win.resize(self.information_win_size, tabs.Tab.width,
+ tabs.Tab.height - 2 - self.information_win_size, 0)
+
def on_exception(self, typ, value, trace):
"""
When an exception is raised, just reset curses and call
@@ -194,6 +207,7 @@ class Core(object):
if self.information_win_size == 14:
return
self.information_win_size += 1
+ self.resize_global_information_win()
for tab in self.tabs:
tab.on_info_win_size_changed()
self.refresh_window()
@@ -202,6 +216,7 @@ class Core(object):
if self.information_win_size == 0:
return
self.information_win_size -= 1
+ self.resize_global_information_win()
for tab in self.tabs:
tab.on_info_win_size_changed()
self.refresh_window()
@@ -574,16 +589,18 @@ class Core(object):
"""
Called when we want to resize the screen
"""
+ tabs.Tab.resize(self.stdscr)
+ self.resize_global_information_win()
with resize_lock:
for tab in self.tabs:
- tab.need_resize = True
+ tab.resize()
self.refresh_window()
def main_loop(self):
"""
main loop waiting for the user to press a key
"""
- curses.ungetch(0) # FIXME
+ # curses.ungetch(0) # FIXME
while self.running:
char = read_char(self.stdscr)
# search for keyboard shortcut