summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-04-16 21:46:07 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-04-16 21:46:07 +0200
commit3711c258a815a6ca1dfd295c1bd1b626a9626b8a (patch)
tree634d57568e12ba8919f1e6e4a2bf17e1a12996a5 /src
parent9889baf0ce398131979f3531ac65a602dfd8e782 (diff)
downloadpoezio-3711c258a815a6ca1dfd295c1bd1b626a9626b8a.tar.gz
poezio-3711c258a815a6ca1dfd295c1bd1b626a9626b8a.tar.bz2
poezio-3711c258a815a6ca1dfd295c1bd1b626a9626b8a.tar.xz
poezio-3711c258a815a6ca1dfd295c1bd1b626a9626b8a.zip
Optimize refresh by doing only when strictly required and on the concerned part of the screen.
Also remove the \n at the end of /info when status message is empty
Diffstat (limited to 'src')
-rw-r--r--src/core.py37
-rw-r--r--src/tabs.py39
2 files changed, 43 insertions, 33 deletions
diff --git a/src/core.py b/src/core.py
index 9373dcb2..4f2edb9a 100644
--- a/src/core.py
+++ b/src/core.py
@@ -147,7 +147,6 @@ class Core(object):
'M-e': self.go_to_important_room,
'M-r': self.go_to_roster,
'M-z': self.go_to_previous_tab,
- 'M-v': self.move_separator,
'^L': self.full_screen_redraw,
'M-j': self.go_to_room_number,
}
@@ -345,7 +344,6 @@ class Core(object):
if not contact.get_highest_priority_resource(): # No resource left: that was the last one
self.add_information_message_to_conversation_tab(jid.bare, '\x195%s is \x191offline' % (jid.bare))
self.information('\x193%s \x195is \x191offline' % (resource.get_jid().bare), "Roster")
- self.refresh_window()
def on_got_online(self, presence):
jid = presence['from']
@@ -508,8 +506,9 @@ class Core(object):
else:
conversation.remote_wants_chatstates = False
logger.log_message(jid.full.replace('/', '\\'), nick_from, body)
- self.refresh_window()
- self.doupdate()
+ if conversation is self.current_tab():
+ self.refresh_window()
+ self.doupdate()
def focus_tab_named(self, tab_name):
for tab in self.tabs:
@@ -557,7 +556,8 @@ class Core(object):
logger.log_message(jid.bare, remote_nick, body)
if self.current_tab() is not conversation:
conversation.set_color_state(theme.COLOR_TAB_PRIVATE)
- self.refresh_window()
+ else:
+ self.refresh_window()
def on_presence(self, presence):
jid = presence['from']
@@ -573,7 +573,9 @@ class Core(object):
resource.set_presence(status)
resource.set_priority(priority)
resource.set_status(status_message)
- self.refresh_window()
+ if isinstance(self.current_tab(), tabs.RosterTab) or\
+ isinstance(self.current_tab(), tabs.RosterInfoTab):
+ self.refresh_window()
def on_roster_update(self, iq):
"""
@@ -902,7 +904,8 @@ class Core(object):
else:
self.add_message_to_text_buffer(room, _("The subject is: %(subject)s") % {'subject':subject}, time=None)
room.topic = subject.replace('\n', '|')
- self.refresh_window()
+ if self.get_tab_by_name(room_from, tabs.MucTab) is self.current_tab():
+ self.refresh_window()
def on_groupchat_message(self, message):
"""
@@ -942,9 +945,10 @@ class Core(object):
if body:
date = date if delayed == True else None
self.add_message_to_text_buffer(room, body, date, nick_from)
- # TODO, only if we are focused on this MUC
- self.refresh_window()
- self.doupdate()
+ if tab is self.current_tab():
+ tab.text_win.refresh(tab._room)
+ tab.input.refresh()
+ self.doupdate()
def add_message_to_text_buffer(self, room, txt, time=None, nickname=None):
"""
@@ -955,7 +959,6 @@ class Core(object):
self.information('Trying to add a message in no room: %s' % txt, 'Error')
else:
room.add_message(txt, time, nickname)
- self.refresh_window()
def command_help(self, arg):
"""
@@ -1323,18 +1326,6 @@ class Core(object):
return
self.command_win('%s%s' % (nb1, nb2))
- def move_separator(self):
- """
- Move the new-messages separator at the bottom on the current
- text.
- """
- window = self.current_tab().get_text_window()
- if not window:
- return
- window.remove_line_separator()
- window.add_line_separator()
- self.refresh_window()
-
def information(self, msg, typ=''):
"""
Displays an informational message in the "Info" room window
diff --git a/src/tabs.py b/src/tabs.py
index 760aaa08..d71ec75a 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -255,6 +255,7 @@ class ChatTab(Tab):
# if that’s None, then no paused chatstate was sent recently
# if that’s a weakref returning None, then a paused chatstate was sent
# since the last input
+ self.key_func['M-v'] = self.move_separator
self.key_func['M-/'] = self.last_words_completion
self.key_func['^M'] = self.on_enter
self.commands['say'] = (self.command_say,
@@ -339,6 +340,12 @@ class ChatTab(Tab):
del event
self.timed_event_paused = None
+ def move_separator(self):
+ self.text_win.remove_line_separator()
+ self.text_win.add_line_separator()
+ self.text_win.refresh(self._room)
+ self.input.refresh()
+
def command_say(self, line):
raise NotImplementedError
@@ -457,11 +464,13 @@ class MucTab(ChatTab):
def scroll_user_list_up(self):
self.user_win.scroll_up()
- self.core.refresh_window()
+ self.user_win.refresh(self._room.users)
+ self.input.refresh()
def scroll_user_list_down(self):
self.user_win.scroll_down()
- self.core.refresh_window()
+ self.user_win.refresh(self._room.users)
+ self.input.refresh()
def command_info(self, arg):
args = common.shell_split(arg)
@@ -470,8 +479,9 @@ class MucTab(ChatTab):
user = self.get_room().get_user_by_name(args[0])
if not user:
return self.core.information("Unknown user: %s" % args[0])
- self.get_room().add_message("%s%s: show: %s, affiliation: %s, role: %s\n%s"% (args[0], ' (%s)'%user.jid if user.jid else '', user.show or 'Available', user.role or 'None', user.affiliation or 'None', user.status))
- self.core.refresh_window()
+ self.get_room().add_message("%s%s: show: %s, affiliation: %s, role: %s%s"% (args[0], ' (%s)'%user.jid if user.jid else '', user.show or 'Available', user.role or 'None', user.affiliation or 'None', '\n%s' % user.status if user.status else ''))
+ self.text_win.refresh(self._room)
+ self.input.refresh()
def command_configure(self, arg):
form = self.core.xmpp.plugin['xep_0045'].getRoomForm(self.get_name())
@@ -516,7 +526,8 @@ class MucTab(ChatTab):
user.color = theme.LIST_COLOR_NICKNAMES[i % nb_color]
i += 1
self.text_win.rebuild_everything(self.get_room())
- self.core.refresh_window()
+ self.text_win.refresh(self._room)
+ self.input.refresh()
def command_nick(self, arg):
"""
@@ -804,8 +815,11 @@ class MucTab(ChatTab):
# status change
else:
self.on_user_change_status(room, user, from_nick, from_room, affiliation, role, show, status)
- self.core.refresh_window()
- self.core.doupdate()
+ if self.core.current_tab() is self:
+ self.text_win.refresh(self._room)
+ self.user_win.refresh(self._room.users)
+ self.info_header.refresh(self._room, self.text_win)
+ self.core.doupdate()
def on_user_join(self, room, from_nick, affiliation, show, status, role, jid):
"""
@@ -1265,7 +1279,8 @@ class RosterInfoTab(Tab):
def reset_help_message(self, _=None):
curses.curs_set(0)
self.input = self.default_help_message
- self.core.refresh_window()
+ self.input.refresh()
+ self.core.doupdate()
return True
def execute_slash_command(self, txt):
@@ -1299,14 +1314,18 @@ class RosterInfoTab(Tab):
while not isinstance(self.roster_win.get_selected_row(), RosterGroup):
if not self.roster_win.move_cursor_up():
break
- self.core.refresh_window()
+ self.roster_win.refresh(roster)
+ self.input.refresh()
+ self.core.doupdate()
def move_cursor_to_next_group(self):
self.roster_win.move_cursor_down()
while not isinstance(self.roster_win.get_selected_row(), RosterGroup):
if not self.roster_win.move_cursor_down():
break
- self.core.refresh_window()
+ self.roster_win.refresh(roster)
+ self.input.refresh()
+ self.core.doupdate()
def on_scroll_down(self):
for i in range(self.height-1):