summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-08-09 00:23:59 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-08-09 00:23:59 +0000
commit6b4b32ffc565eb82e48eb5564f1f336eecaef4dc (patch)
tree409e067c1272662be390458eaae87c10b549d457 /src
parent835527e2d130cd427972cadfc82d10ee36391e52 (diff)
downloadpoezio-6b4b32ffc565eb82e48eb5564f1f336eecaef4dc.tar.gz
poezio-6b4b32ffc565eb82e48eb5564f1f336eecaef4dc.tar.bz2
poezio-6b4b32ffc565eb82e48eb5564f1f336eecaef4dc.tar.xz
poezio-6b4b32ffc565eb82e48eb5564f1f336eecaef4dc.zip
Print a line separator to indicate the new messages. fixed #1487
Diffstat (limited to 'src')
-rw-r--r--src/gui.py9
-rw-r--r--src/room.py14
-rw-r--r--src/window.py14
3 files changed, 33 insertions, 4 deletions
diff --git a/src/gui.py b/src/gui.py
index a2ff670d..5d6ed512 100644
--- a/src/gui.py
+++ b/src/gui.py
@@ -181,8 +181,6 @@ class Gui(object):
returns the room that has this name
"""
for room in self.rooms:
- from common import debug
- debug('-- %s ? %s\n' % (room.name, name,))
if room.name.decode('utf-8') == name:
return room
return None
@@ -318,6 +316,7 @@ class Gui(object):
rotate the rooms list to the right
"""
self.current_room().set_color_state(common.ROOM_STATE_NONE)
+ self.current_room().remove_line_separator()
self.rooms.append(self.rooms.pop(0))
self.current_room().set_color_state(common.ROOM_STATE_CURRENT)
self.refresh_window()
@@ -327,6 +326,7 @@ class Gui(object):
rotate the rooms list to the right
"""
self.current_room().set_color_state(common.ROOM_STATE_NONE)
+ self.current_room().remove_line_separator()
self.rooms.insert(0, self.rooms.pop())
self.current_room().set_color_state(common.ROOM_STATE_CURRENT)
self.refresh_window()
@@ -438,8 +438,6 @@ class Gui(object):
if (self.ignores.has_key(room_from)) and (nick_from in self.ignores[room_from]):
return
room = self.get_room_by_name(room_from)
- from common import debug
- debug('%s\n' % room_from)
if not room:
self.information(_("message received for a non-existing room: %s") % (room_from))
return
@@ -594,6 +592,8 @@ class Gui(object):
Add the message to the room and refresh the associated component
of the interface
"""
+ if room != self.current_room():
+ room.add_line_separator()
room.add_message(txt, time, nickname)
if room == self.current_room():
self.window.text_win.refresh(room)
@@ -678,6 +678,7 @@ class Gui(object):
if self.current_room().nb == nb:
return
self.current_room().set_color_state(common.ROOM_STATE_NONE)
+ self.current_room().remove_line_separator()
start = self.current_room()
self.rooms.append(self.rooms.pop(0))
while self.current_room().nb != nb:
diff --git a/src/room.py b/src/room.py
index 4e341cbe..28e29b76 100644
--- a/src/room.py
+++ b/src/room.py
@@ -117,6 +117,20 @@ class Room(object):
time = time if time is not None else datetime.now()
self.messages.append(Message(txt, time, nickname, user, color))
+ def remove_line_separator(self):
+ """
+ Remove the line separator
+ """
+ if None in self.messages:
+ self.messages.remove(None)
+
+ def add_line_separator(self):
+ """
+ add a line separator at the end of messages list
+ """
+ if None not in self.messages:
+ self.messages.append(None)
+
def get_user_by_name(self, nick):
for user in self.users:
if user.nick == nick.encode('utf-8'):
diff --git a/src/window.py b/src/window.py
index 2c030afe..fbdaa1de 100644
--- a/src/window.py
+++ b/src/window.py
@@ -218,6 +218,9 @@ class TextWin(Win):
"""
lines = []
for message in messages:
+ if message == None: # line separator
+ lines.append(None)
+ continue
txt = message.txt
if not txt:
continue
@@ -285,6 +288,10 @@ class TextWin(Win):
y = 0
for line in lines:
self.win.move(y, 0)
+ if line == None:
+ self.write_line_separator()
+ y += 1
+ continue
if line.time is not None:
self.write_time(line.time)
if line.nickname is not None:
@@ -293,6 +300,13 @@ class TextWin(Win):
y += 1
self.win.refresh()
+ def write_line_separator(self):
+ """
+ """
+ self.win.attron(curses.color_pair(7))
+ self.win.addstr(' -'*(self.width/2))
+ self.win.attroff(curses.color_pair(7))
+
def write_text(self, y, x, txt, color):
"""
write the text of a line.