The room info bar and highlights work again.
This commit is contained in:
parent
fa4fbeb23c
commit
e3974e8524
3 changed files with 24 additions and 18 deletions
|
@ -16,6 +16,8 @@ http://codingteam.net/project/poezio/roadmap
|
||||||
- Various new commands (topic, kick, set, win)
|
- Various new commands (topic, kick, set, win)
|
||||||
- Password-protected MUCs are handled
|
- Password-protected MUCs are handled
|
||||||
- The dates of room history are handled
|
- The dates of room history are handled
|
||||||
|
- The way the text is displayed on the screen has been rewritten, this fixes
|
||||||
|
the blink and the slowness-over-ssh problems.
|
||||||
- Various Bugfixes
|
- Various Bugfixes
|
||||||
|
|
||||||
* Poezio 0.5.1 - 2 Feb 2010
|
* Poezio 0.5.1 - 2 Feb 2010
|
||||||
|
|
32
src/room.py
32
src/room.py
|
@ -61,26 +61,26 @@ class Room(object):
|
||||||
time = time if time is not None else datetime.now()
|
time = time if time is not None else datetime.now()
|
||||||
from common import debug
|
from common import debug
|
||||||
# debug("add_message: %s, %s, %s, %s" % (str(txt), str(time), str(nickname), str(user)))
|
# debug("add_message: %s, %s, %s, %s" % (str(txt), str(time), str(nickname), str(user)))
|
||||||
self.messages.append(Message(txt, time, nickname, user))
|
|
||||||
|
color = None
|
||||||
|
if nickname is not None:
|
||||||
|
self.set_color_state(12)
|
||||||
|
if nickname != self.own_nick and self.joined and nickname is not None: # do the highlight thing
|
||||||
|
if self.own_nick in txt:
|
||||||
|
self.set_color_state(13)
|
||||||
|
color = 3
|
||||||
|
else:
|
||||||
|
highlight_words = config.get('highlight_on', '').split(':')
|
||||||
|
for word in highlight_words:
|
||||||
|
if word.lower() in txt.lower() and word != '':
|
||||||
|
self.set_color_state(13)
|
||||||
|
color = 3
|
||||||
|
break
|
||||||
|
self.messages.append(Message(txt, time, nickname, user, color))
|
||||||
|
|
||||||
# def add_message(nick, msg, date=None)
|
# def add_message(nick, msg, date=None)
|
||||||
# TODO: limit the message kept in memory (configurable)
|
# TODO: limit the message kept in memory (configurable)
|
||||||
|
|
||||||
# if not date:
|
|
||||||
# date = datetime.now()
|
|
||||||
# color = None
|
|
||||||
# self.set_color_state(12)
|
|
||||||
# if nick != self.own_nick and self.joined: # do the highlight thing
|
|
||||||
# if self.own_nick in msg:
|
|
||||||
# self.set_color_state(13)
|
|
||||||
# color = 3
|
|
||||||
# else:
|
|
||||||
# highlight_words = config.get('highlight_on', '').split(':')
|
|
||||||
# for word in highlight_words:
|
|
||||||
# if word.lower() in msg.lower() and word != '':
|
|
||||||
# self.set_color_state(13)
|
|
||||||
# color = 3
|
|
||||||
# break
|
|
||||||
# if not msg:
|
# if not msg:
|
||||||
# logger.info('msg is None..., %s' % (nick))
|
# logger.info('msg is None..., %s' % (nick))
|
||||||
# return
|
# return
|
||||||
|
|
|
@ -196,7 +196,7 @@ class TextWin(Win):
|
||||||
else:
|
else:
|
||||||
x = 11
|
x = 11
|
||||||
self.win.attron(curses.color_pair(8))
|
self.win.attron(curses.color_pair(8))
|
||||||
y += self.write_text(y, x, message.txt)
|
y += self.write_text(y, x, message.txt, message.color)
|
||||||
if message.nickname is None:
|
if message.nickname is None:
|
||||||
self.win.attroff(curses.color_pair(8))
|
self.win.attroff(curses.color_pair(8))
|
||||||
# self.win.addnstr(y, x, message.txt, 40)
|
# self.win.addnstr(y, x, message.txt, 40)
|
||||||
|
@ -204,12 +204,14 @@ class TextWin(Win):
|
||||||
y += 1
|
y += 1
|
||||||
self.win.refresh()
|
self.win.refresh()
|
||||||
|
|
||||||
def write_text(self, y, x, txt):
|
def write_text(self, y, x, txt, color):
|
||||||
"""
|
"""
|
||||||
return the number of line written, -1
|
return the number of line written, -1
|
||||||
"""
|
"""
|
||||||
txt = txt.encode('utf-8')
|
txt = txt.encode('utf-8')
|
||||||
l = 0
|
l = 0
|
||||||
|
if color:
|
||||||
|
self.win.attron(curses.color_pair(color))
|
||||||
while txt != '':
|
while txt != '':
|
||||||
debug(txt)
|
debug(txt)
|
||||||
if txt[:self.width-x].find('\n') != -1:
|
if txt[:self.width-x].find('\n') != -1:
|
||||||
|
@ -220,6 +222,8 @@ class TextWin(Win):
|
||||||
self.win.addnstr(y+l, x, txt, limit)
|
self.win.addnstr(y+l, x, txt, limit)
|
||||||
txt = txt[limit+1:]
|
txt = txt[limit+1:]
|
||||||
l += 1
|
l += 1
|
||||||
|
if color:
|
||||||
|
self.win.attroff(curses.color_pair(color))
|
||||||
return l-1
|
return l-1
|
||||||
|
|
||||||
def write_nickname(self, y, nickname, user):
|
def write_nickname(self, y, nickname, user):
|
||||||
|
|
Loading…
Reference in a new issue