avoid some crashes. Also fixes the line separator on new messages

parent 534b39ae
......@@ -1172,6 +1172,8 @@ class Gui(object):
sys.exit()
def do_command(self, key):
if not key:
return
from common import debug
debug('do_command, %s, %s\n' % (key, self.current_tab()))
res = self.current_tab().on_input(key)
......
......@@ -271,9 +271,9 @@ class MucTab(Tab):
def on_lose_focus(self):
self._room.set_color_state(theme.COLOR_TAB_NORMAL)
self._room.remove_line_separator()
self._room.add_line_separator()
def on_gain_focus(self):
self._room.add_line_separator()
self._room.set_color_state(theme.COLOR_TAB_CURRENT)
def on_scroll_up(self):
......@@ -336,9 +336,9 @@ class PrivateTab(Tab):
def on_lose_focus(self):
self._room.set_color_state(theme.COLOR_TAB_NORMAL)
self._room.remove_line_separator()
self._room.add_line_separator()
def on_gain_focus(self):
self._room.add_line_separator()
self._room.set_color_state(theme.COLOR_TAB_CURRENT)
def on_scroll_up(self):
......@@ -353,9 +353,5 @@ class PrivateTab(Tab):
self.info_header.resize(1, self.width, self.height-3-self.info_win_size, 0, stdscr, self.visible)
self.info_win.resize(self.info_win_size, (self.width//10)*9, self.height-2-self.info_win_size, 0, stdscr, self.visible)
# self.text_win.resize(self.height-4-self.info_win_size, text_width, 1, 0, stdscr, self.visible)
# self.info_header.resize(1, (self.width//10)*9, self.height-3-self.info_win_size, 0, stdscr, self.visible)
# self.info_win.resize(self.info_win_size, (self.width//10)*9, self.height-2-self.info_win_size, 0, stdscr, self.visible)
def get_room(self):
return self._room
......@@ -41,6 +41,9 @@ class Win(object):
try:
self.win = parent_win.subwin(height, width, y, x)
except:
from common import debug
debug('%s %s %s %s %s\n' % (height, width, y, x, parent_win))
raise
# When resizing in a too little height (less than 3 lines)
# We don't need to resize the window, since this size
# just makes no sense
......@@ -94,8 +97,14 @@ class UserList(Win):
self.win.erase()
y = 0
for user in sorted(users):
role_col = self.color_role[user.role]
show_col = self.color_show[user.show]
if not user.role in self.color_role:
role_col = theme.COLOR_USER_NONE
else:
role_col = self.color_role[user.role]
if not user.show in self.color_show:
show_col = theme.COLOR_STATUS_NONE
else:
show_col = self.color_show[user.show]
self.addstr(y, 0, theme.CHAR_STATUS, curses.color_pair(show_col))
self.addnstr(y, 1, user.nick, self.width-2, curses.color_pair(role_col))
y += 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment