Print a line separator to indicate the new messages. fixed #1487
This commit is contained in:
parent
835527e2d1
commit
6b4b32ffc5
3 changed files with 33 additions and 4 deletions
|
@ -181,8 +181,6 @@ class Gui(object):
|
||||||
returns the room that has this name
|
returns the room that has this name
|
||||||
"""
|
"""
|
||||||
for room in self.rooms:
|
for room in self.rooms:
|
||||||
from common import debug
|
|
||||||
debug('-- %s ? %s\n' % (room.name, name,))
|
|
||||||
if room.name.decode('utf-8') == name:
|
if room.name.decode('utf-8') == name:
|
||||||
return room
|
return room
|
||||||
return None
|
return None
|
||||||
|
@ -318,6 +316,7 @@ class Gui(object):
|
||||||
rotate the rooms list to the right
|
rotate the rooms list to the right
|
||||||
"""
|
"""
|
||||||
self.current_room().set_color_state(common.ROOM_STATE_NONE)
|
self.current_room().set_color_state(common.ROOM_STATE_NONE)
|
||||||
|
self.current_room().remove_line_separator()
|
||||||
self.rooms.append(self.rooms.pop(0))
|
self.rooms.append(self.rooms.pop(0))
|
||||||
self.current_room().set_color_state(common.ROOM_STATE_CURRENT)
|
self.current_room().set_color_state(common.ROOM_STATE_CURRENT)
|
||||||
self.refresh_window()
|
self.refresh_window()
|
||||||
|
@ -327,6 +326,7 @@ class Gui(object):
|
||||||
rotate the rooms list to the right
|
rotate the rooms list to the right
|
||||||
"""
|
"""
|
||||||
self.current_room().set_color_state(common.ROOM_STATE_NONE)
|
self.current_room().set_color_state(common.ROOM_STATE_NONE)
|
||||||
|
self.current_room().remove_line_separator()
|
||||||
self.rooms.insert(0, self.rooms.pop())
|
self.rooms.insert(0, self.rooms.pop())
|
||||||
self.current_room().set_color_state(common.ROOM_STATE_CURRENT)
|
self.current_room().set_color_state(common.ROOM_STATE_CURRENT)
|
||||||
self.refresh_window()
|
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]):
|
if (self.ignores.has_key(room_from)) and (nick_from in self.ignores[room_from]):
|
||||||
return
|
return
|
||||||
room = self.get_room_by_name(room_from)
|
room = self.get_room_by_name(room_from)
|
||||||
from common import debug
|
|
||||||
debug('%s\n' % room_from)
|
|
||||||
if not room:
|
if not room:
|
||||||
self.information(_("message received for a non-existing room: %s") % (room_from))
|
self.information(_("message received for a non-existing room: %s") % (room_from))
|
||||||
return
|
return
|
||||||
|
@ -594,6 +592,8 @@ class Gui(object):
|
||||||
Add the message to the room and refresh the associated component
|
Add the message to the room and refresh the associated component
|
||||||
of the interface
|
of the interface
|
||||||
"""
|
"""
|
||||||
|
if room != self.current_room():
|
||||||
|
room.add_line_separator()
|
||||||
room.add_message(txt, time, nickname)
|
room.add_message(txt, time, nickname)
|
||||||
if room == self.current_room():
|
if room == self.current_room():
|
||||||
self.window.text_win.refresh(room)
|
self.window.text_win.refresh(room)
|
||||||
|
@ -678,6 +678,7 @@ class Gui(object):
|
||||||
if self.current_room().nb == nb:
|
if self.current_room().nb == nb:
|
||||||
return
|
return
|
||||||
self.current_room().set_color_state(common.ROOM_STATE_NONE)
|
self.current_room().set_color_state(common.ROOM_STATE_NONE)
|
||||||
|
self.current_room().remove_line_separator()
|
||||||
start = self.current_room()
|
start = self.current_room()
|
||||||
self.rooms.append(self.rooms.pop(0))
|
self.rooms.append(self.rooms.pop(0))
|
||||||
while self.current_room().nb != nb:
|
while self.current_room().nb != nb:
|
||||||
|
|
14
src/room.py
14
src/room.py
|
@ -117,6 +117,20 @@ class Room(object):
|
||||||
time = time if time is not None else datetime.now()
|
time = time if time is not None else datetime.now()
|
||||||
self.messages.append(Message(txt, time, nickname, user, color))
|
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):
|
def get_user_by_name(self, nick):
|
||||||
for user in self.users:
|
for user in self.users:
|
||||||
if user.nick == nick.encode('utf-8'):
|
if user.nick == nick.encode('utf-8'):
|
||||||
|
|
|
@ -218,6 +218,9 @@ class TextWin(Win):
|
||||||
"""
|
"""
|
||||||
lines = []
|
lines = []
|
||||||
for message in messages:
|
for message in messages:
|
||||||
|
if message == None: # line separator
|
||||||
|
lines.append(None)
|
||||||
|
continue
|
||||||
txt = message.txt
|
txt = message.txt
|
||||||
if not txt:
|
if not txt:
|
||||||
continue
|
continue
|
||||||
|
@ -285,6 +288,10 @@ class TextWin(Win):
|
||||||
y = 0
|
y = 0
|
||||||
for line in lines:
|
for line in lines:
|
||||||
self.win.move(y, 0)
|
self.win.move(y, 0)
|
||||||
|
if line == None:
|
||||||
|
self.write_line_separator()
|
||||||
|
y += 1
|
||||||
|
continue
|
||||||
if line.time is not None:
|
if line.time is not None:
|
||||||
self.write_time(line.time)
|
self.write_time(line.time)
|
||||||
if line.nickname is not None:
|
if line.nickname is not None:
|
||||||
|
@ -293,6 +300,13 @@ class TextWin(Win):
|
||||||
y += 1
|
y += 1
|
||||||
self.win.refresh()
|
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):
|
def write_text(self, y, x, txt, color):
|
||||||
"""
|
"""
|
||||||
write the text of a line.
|
write the text of a line.
|
||||||
|
|
Loading…
Reference in a new issue