diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-12-31 10:52:15 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-12-31 10:52:15 +0000 |
commit | 3b2d28e6ee0ae8522d25f0d582d36f7693abbcb0 (patch) | |
tree | 9bf57a5546ab39a62db8e71958cee42ea1859020 /src | |
parent | 9f4474be20ec73e9722da1d7f66c1c3dd3f52c22 (diff) | |
download | poezio-3b2d28e6ee0ae8522d25f0d582d36f7693abbcb0.tar.gz poezio-3b2d28e6ee0ae8522d25f0d582d36f7693abbcb0.tar.bz2 poezio-3b2d28e6ee0ae8522d25f0d582d36f7693abbcb0.tar.xz poezio-3b2d28e6ee0ae8522d25f0d582d36f7693abbcb0.zip |
remote nickname is colored in ConversationTab
Diffstat (limited to 'src')
-rw-r--r-- | src/core.py | 10 | ||||
-rw-r--r-- | src/message.py | 11 | ||||
-rw-r--r-- | src/room.py | 4 | ||||
-rw-r--r-- | src/tabs.py | 8 | ||||
-rw-r--r-- | src/text_buffer.py | 12 | ||||
-rw-r--r-- | src/theme.py | 3 | ||||
-rw-r--r-- | src/windows.py | 2 |
7 files changed, 23 insertions, 27 deletions
diff --git a/src/core.py b/src/core.py index d2931933..449fdef0 100644 --- a/src/core.py +++ b/src/core.py @@ -49,7 +49,6 @@ from user import User from room import Room from roster import Roster, RosterGroup, roster from contact import Contact, Resource -from message import Message from text_buffer import TextBuffer from keyboard import read_char @@ -491,8 +490,7 @@ class Core(object): if not conversation: # We create the conversation with the bare Jid if nothing was found conversation = self.open_conversation_window(jid.bare, False) - # room = self.open_conversation_window(jid, False) - self.add_message_to_text_buffer(conversation.get_room(), body, None, jid.full) + conversation.get_room().add_message(body, None, jid.full, False, curses.color_pair(theme.COLOR_REMOTE_USER)) if self.current_tab() is not conversation: conversation.set_color_state(theme.COLOR_TAB_PRIVATE) self.refresh_window() @@ -765,8 +763,7 @@ class Core(object): """ open a new conversation tab and focus it if needed """ - text_buffer = TextBuffer() - new_tab = tabs.ConversationTab(self, text_buffer, jid) + new_tab = tabs.ConversationTab(self, jid) # insert it in the rooms self.add_tab(new_tab, focus) self.refresh_window() @@ -841,9 +838,8 @@ class Core(object): body = message['body'] if body: date = date if delayed == True else None - # if not delayed: - # logger.groupchat(room_from, nick_from, body) 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() diff --git a/src/message.py b/src/message.py index 6cf7a3d3..4c3d8ccf 100644 --- a/src/message.py +++ b/src/message.py @@ -26,28 +26,27 @@ class Message(object): The color can be a single number OR a list of numbers, for specials cases like join or quit messages. """ - def __init__(self, txt, time=None, nickname=None, user=None, color=None, colorized=False): + def __init__(self, txt, time=None, nickname=None, nick_color=None, color=None, colorized=False): """ time is a datetime object, None means 'now'. If no nickname is specified, it's an information. - user is an User object (used for the color, etc) - """ self.txt = txt self.nickname = nickname self.time = time - self.user = user + self.nick_color = nick_color self.color = color self.colorized = colorized def __repr__(self): - return "<Message txt=%s, nickname=%s, time=%s, user=%s, colorized=%s>" % (self.txt, self.nickname, str(self.time), str(self.user), self.colorized) + return "<Message txt=%s, nickname=%s, time=%s, user=%s, colorized=%s>" % (self.txt, self.nickname, str(self.time), str(self.nick_color), self.colorized) + def __str__(self): return self.__repr__() class Line(object): """ - A line, corresponding to ONE row of the text area. + A line, corresponding to ONE row of a TextWin. A message is composed of ONE line or MORE. The same particularity for colors in Message class applies here too. diff --git a/src/room.py b/src/room.py index 2fe7a188..94825b3e 100644 --- a/src/room.py +++ b/src/room.py @@ -88,7 +88,7 @@ class Room(TextBuffer): """ self.color_state = color - def add_message(self, txt, time=None, nickname=None, colorized=False, forced_user=None): + def add_message(self, txt, time=None, nickname=None, colorized=False, forced_user=None, nick_color=None): """ Note that user can be None even if nickname is not None. It happens when we receive an history message said by someone who is not @@ -116,7 +116,7 @@ class Room(TextBuffer): if time: # History messages are colored to be distinguished color = theme.COLOR_INFORMATION_TEXT time = time if time is not None else datetime.now() - message = Message(txt, time, nickname, user, color, colorized) + message = Message(txt, time, nickname, nick_color or user.color, color, colorized) while len(self.messages) > MESSAGE_NB_LIMIT: self.messages.pop(0) self.messages.append(message) diff --git a/src/tabs.py b/src/tabs.py index 8016f86e..6170cb67 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -860,9 +860,10 @@ class RosterInfoTab(Tab): class ConversationTab(ChatTab): """ - The tab containg a normal conversation (someone from our roster) + The tab containg a normal conversation (not from a MUC) """ - def __init__(self, core, text_buffer, jid): + def __init__(self, core, jid): + text_buffer = windows.TextBuffer() ChatTab.__init__(self, core, text_buffer) self.color_state = theme.COLOR_TAB_NORMAL self._name = jid # a conversation tab is linked to one specific full jid OR bare jid @@ -890,9 +891,6 @@ class ConversationTab(ChatTab): self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick) def command_unquery(self, arg): - """ - /unquery - """ self.core.close_tab() def resize(self): diff --git a/src/text_buffer.py b/src/text_buffer.py index 1b11c67b..2f4d9533 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -25,13 +25,14 @@ from message import Message from datetime import datetime import theme -MESSAGE_NB_LIMIT = 16384 +MESSAGE_NB_LIMIT = 8192 class TextBuffer(object): """ This class just keep trace of messages, in a list with various informations and attributes. """ + def __init__(self): self.messages = [] # Message objects self.windows = [] # we keep track of one or more windows @@ -41,13 +42,11 @@ class TextBuffer(object): def add_window(self, win): self.windows.append(win) - def add_message(self, txt, time=None, nickname=None, colorized=False): + def add_message(self, txt, time=None, nickname=None, colorized=False, nick_color=None): color = theme.COLOR_NORMAL_TEXT - user = None + nick_color = nick_color time = time or datetime.now() - # if self.pos: # avoid scrolling of one line when one line is received - # self.pos += 1 - msg = Message(txt, time, nickname, user, color, colorized) + msg = Message(txt, time, nickname, nick_color, color, colorized) self.messages.append(msg) while len(self.messages) > MESSAGE_NB_LIMIT: self.messages.pop(0) @@ -56,3 +55,4 @@ class TextBuffer(object): nb = window.build_new_message(msg) if window.pos != 0: window.scroll_up(nb) + diff --git a/src/theme.py b/src/theme.py index dcc08a08..d483453b 100644 --- a/src/theme.py +++ b/src/theme.py @@ -40,6 +40,9 @@ COLOR_USER_PARTICIPANT = 4 COLOR_USER_NONE = 0 COLOR_USER_MODERATOR = 1 +# nickname colors +COLOR_REMOTE_USER = 23 + # The character printed in color (COLOR_STATUS_*) before the nickname # in the user list CHAR_STATUS = ' ' diff --git a/src/windows.py b/src/windows.py index 0ad7834c..0f5371b3 100644 --- a/src/windows.py +++ b/src/windows.py @@ -467,7 +467,7 @@ class TextWin(Win): else: limit = self.width-offset-1 this_line_was_broken_by_space = False - color = message.user.color if message.user else None + color = message.nick_color if not first: nick = None time = None |