summaryrefslogtreecommitdiff
path: root/src/tab.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-10-17 05:14:22 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-10-17 05:14:22 +0000
commit9c9236eb49caf55f86bd5b7a39ab364f028bc1bf (patch)
tree7cc3e2f6d76ac724ef7b5900dfa31d7b9d78c579 /src/tab.py
parenteabf05c8a75aab889780349045c0b4b5ff3f8b4e (diff)
downloadpoezio-9c9236eb49caf55f86bd5b7a39ab364f028bc1bf.tar.gz
poezio-9c9236eb49caf55f86bd5b7a39ab364f028bc1bf.tar.bz2
poezio-9c9236eb49caf55f86bd5b7a39ab364f028bc1bf.tar.xz
poezio-9c9236eb49caf55f86bd5b7a39ab364f028bc1bf.zip
refresh optimization by limiting the .refresh() calls at the STRICT minimum
Diffstat (limited to 'src/tab.py')
-rw-r--r--src/tab.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/tab.py b/src/tab.py
index 8cb3ed0c..4acfab08 100644
--- a/src/tab.py
+++ b/src/tab.py
@@ -27,6 +27,7 @@ MIN_HEIGHT = 16
import window
import theme
+import curses
from roster import RosterGroup
from common import debug
@@ -118,6 +119,14 @@ class Tab(object):
"""
raise NotImplementedError
+ def just_before_refresh(self):
+ """
+ Method called just before the screen refresh.
+ Particularly useful to move the cursor at the
+ correct position.
+ """
+ raise NotImplementedError
+
class InfoTab(Tab):
"""
The information tab, used to display global informations
@@ -159,6 +168,7 @@ class InfoTab(Tab):
def on_gain_focus(self):
self.color_state = theme.COLOR_TAB_CURRENT
+ curses.curs_set(0)
def on_scroll_up(self):
pass
@@ -169,6 +179,9 @@ class InfoTab(Tab):
def on_info_win_size_changed(self, size, stdscr):
return
+ def just_before_refresh(self):
+ return
+
class MucTab(Tab):
"""
The tab containing a multi-user-chat room.
@@ -276,6 +289,7 @@ class MucTab(Tab):
def on_gain_focus(self):
self._room.set_color_state(theme.COLOR_TAB_CURRENT)
+ curses.curs_set(1)
def on_scroll_up(self):
self._room.scroll_up(self.text_win.height-1)
@@ -290,6 +304,9 @@ class MucTab(Tab):
self.info_header.resize(1, (self.width//10)*9, self.height-3-self.info_win_size, 0, stdscr, self.visible)
self.info_win.resize(self.info_win_size, (self.width//10)*9, self.height-2-self.info_win_size, 0, stdscr, self.visible)
+ def just_before_refresh(self):
+ self.input.move_cursor_to_pos()
+
class PrivateTab(Tab):
"""
The tab containg a private conversation (someone from a MUC)
@@ -341,6 +358,7 @@ class PrivateTab(Tab):
def on_gain_focus(self):
self._room.set_color_state(theme.COLOR_TAB_CURRENT)
+ curses.curs_set(1)
def on_scroll_up(self):
self._room.scroll_up(self.text_win.height-1)
@@ -357,6 +375,9 @@ class PrivateTab(Tab):
def get_room(self):
return self._room
+ def just_before_refresh(self):
+ return
+
class RosterInfoTab(Tab):
"""
A tab, splitted in two, containing the roster and infos
@@ -386,9 +407,9 @@ class RosterInfoTab(Tab):
self.input.resize(1, self.width, self.height-1, 0, stdscr, self.visible)
def refresh(self, tabs, informations, roster):
+ self.v_separator.refresh()
self.roster_win.refresh(roster)
self.contact_info_win.refresh(self.roster_win.get_selected_row())
- self.v_separator.refresh()
self.info_win.refresh(informations)
self.tab_win.refresh(tabs, tabs[0])
self.input.refresh()
@@ -412,6 +433,7 @@ class RosterInfoTab(Tab):
def on_gain_focus(self):
self._color_state = theme.COLOR_TAB_CURRENT
+ curses.curs_set(0)
def add_message(self):
return False
@@ -429,6 +451,9 @@ class RosterInfoTab(Tab):
selected_row = self.roster_win.get_selected_row()
return selected_row
+ def just_before_refresh(self):
+ return
+
class ConversationTab(Tab):
"""
The tab containg a normal conversation (someone from our roster)
@@ -457,6 +482,7 @@ class ConversationTab(Tab):
self.info_win.refresh(informations)
self.tab_win.refresh(tabs, tabs[0])
self.input.refresh()
+ curses.curs_set(1)
def get_color_state(self):
if self._room.color_state == theme.COLOR_TAB_NORMAL or\
@@ -495,3 +521,6 @@ class ConversationTab(Tab):
def get_room(self):
return self._room
+
+ def just_before_refresh(self):
+ return