From 285c49a0d0e93a30ffad16a1b889edbb7cec9fb7 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 13 Oct 2012 15:58:02 +0200 Subject: Fixes #2374 (Crash on " " in the MUC list) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Also fixes arefresh issue (up&down keys didn’t refresh the win) - Rework the style of the Columns a bit (was 2-spaces indent & trailing spaces) --- src/tabs.py | 14 ++++++++++++-- src/windows.py | 53 ++++++++++++++++++++++++++--------------------------- 2 files changed, 38 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/tabs.py b/src/tabs.py index da6bceaf..68a93667 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -2965,8 +2965,8 @@ class MucListTab(Tab): self.listview = windows.ListWin(columns) self.default_help_message = windows.HelpText("“j”: join room.") self.input = self.default_help_message - self.key_func["KEY_DOWN"] = self.listview.move_cursor_down - self.key_func["KEY_UP"] = self.listview.move_cursor_up + self.key_func["KEY_DOWN"] = self.move_cursor_down + self.key_func["KEY_UP"] = self.move_cursor_up self.key_func['^I'] = self.completion self.key_func["/"] = self.on_slash self.key_func['j'] = self.join_selected @@ -3106,6 +3106,16 @@ class MucListTab(Tab): def on_scroll_down(self): return self.listview.scroll_down() + def move_cursor_up(self): + self.listview.move_cursor_up() + self.listview.refresh() + self.core.doupdate() + + def move_cursor_down(self): + self.listview.move_cursor_down() + self.listview.refresh() + self.core.doupdate() + class XMLTab(Tab): def __init__(self): diff --git a/src/windows.py b/src/windows.py index cf341e28..22326820 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1836,10 +1836,12 @@ class ListWin(Win): """ Sort the list by the given column, ascendant or descendant """ - if asc: - self.lines.sort(key=lambda x: x[col_name]) + if not col_name: + return + elif asc: + self.lines.sort(key=lambda x: x[col_name]) else: - self.lines.sort(key=lambda x: x[col_name],reverse=True) + self.lines.sort(key=lambda x: x[col_name],reverse=True) self.refresh() curses.doupdate() @@ -1956,22 +1958,22 @@ class ColumnHeaderWin(Win): for col in self._columns: txt = col if col in self._column_order: - if self._column_order_asc: - txt += get_theme().CHAR_COLUMN_ASC - else: - txt += get_theme().CHAR_COLUMN_DESC + if self._column_order_asc: + txt += get_theme().CHAR_COLUMN_ASC + else: + txt += get_theme().CHAR_COLUMN_DESC #⇓⇑↑↓⇧⇩▲▼ size = self._columns_sizes[col] txt += ' ' * (size-len(txt)) if col in self._column_sel: - self.addstr(0, x, txt, to_curses_attr(get_theme().COLOR_COLUMN_HEADER_SEL)) + self.addstr(0, x, txt, to_curses_attr(get_theme().COLOR_COLUMN_HEADER_SEL)) else: - self.addstr(0, x, txt, to_curses_attr(get_theme().COLOR_COLUMN_HEADER)) + self.addstr(0, x, txt, to_curses_attr(get_theme().COLOR_COLUMN_HEADER)) x += size self._refresh() def sel_column(self,dic): - self._column_sel = dic + self._column_sel = dic def get_sel_column(self): return self._column_sel @@ -1982,36 +1984,33 @@ class ColumnHeaderWin(Win): def get_order(self): if self._column_sel == self._column_order: - return self._column_order_asc + return self._column_order_asc else: - return False + return False def sel_column_left(self): if self._column_sel in self._columns: - index = self._columns.index(self._column_sel) - if index > 1: - index = index -1 - else: - index = 0 + index = self._columns.index(self._column_sel) + if index > 1: + index = index -1 + else: + index = 0 else: - index = 0 + index = 0 self._column_sel = self._columns[index] self.refresh() - return def sel_column_right(self): if self._column_sel in self._columns: - index = self._columns.index(self._column_sel) - if index < len(self._columns)-2: - index = index +1 - else: - index = len(self._columns) -1 + index = self._columns.index(self._column_sel) + if index < len(self._columns)-2: + index = index +1 + else: + index = len(self._columns) -1 else: - index = len(self._columns) - 1 + index = len(self._columns) - 1 self._column_sel = self._columns[index] self.refresh() - return - class SimpleTextWin(Win): -- cgit v1.2.3