From c631673cf315dcaadb0c2a76a9e0d62dc840766b Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 11 May 2011 14:33:22 +0200 Subject: should fix #2161, and enable xhtml-im while in debug --- src/core.py | 3 +-- src/windows.py | 21 ++++++++++++--------- src/xhtml.py | 7 +++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/core.py b/src/core.py index 6cb6efa5..f5980af1 100644 --- a/src/core.py +++ b/src/core.py @@ -733,8 +733,7 @@ class Core(object): curses.curs_set(1) curses.noecho() curses.nonl() - if not options.debug: - curses.raw() + curses.raw() theme.init_colors() stdscr.idlok(True) stdscr.keypad(True) diff --git a/src/windows.py b/src/windows.py index e34565e7..85584152 100644 --- a/src/windows.py +++ b/src/windows.py @@ -98,7 +98,7 @@ class Win(object): except: pass - def addstr_colored(self, string, y=None, x=None): + def addstr_colored(self, text, y=None, x=None): """ Write a string on the window, setting the attributes as they are in the string. @@ -111,22 +111,25 @@ class Win(object): """ if y is not None and x is not None: self._win.move(y, x) - next_attr_char = string.find('\x19') + next_attr_char = text.find('\x19') while next_attr_char != -1: - attr_char = string[next_attr_char+1].lower() + if next_attr_char + 1 < len(text): + attr_char = text[next_attr_char+1].lower() + else: + attr_char = str() if next_attr_char != 0: - self.addstr(string[:next_attr_char]) - string = string[next_attr_char+2:] + self.addstr(text[:next_attr_char]) + text = text[next_attr_char+2:] if attr_char == 'o': self._win.attrset(0) elif attr_char == 'u': self._win.attron(curses.A_UNDERLINE) elif attr_char == 'b': self._win.attron(curses.A_BOLD) - elif attr_char.isdigit(): + elif attr_char.isnumeric(): self._win.attron(common.curses_color_pair(int(attr_char))) - next_attr_char = string.find('\x19') - self.addstr(string) + next_attr_char = text.find('\x19') + self.addstr(text) def finish_line(self, color=None): """ @@ -1122,7 +1125,7 @@ class MessageInput(Input): Read one more char (c) and add \x19c to the string """ attr_char = self.core.read_keyboard() - if attr_char in self.text_attributes or (attr_char.isdigit() and int(attr_char) < 7): + if attr_char in self.text_attributes or (attr_char.isnumeric() and int(attr_char) < 7): self.do_command('\x19', False) self.do_command(attr_char) diff --git a/src/xhtml.py b/src/xhtml.py index 954db374..237ed444 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -133,9 +133,12 @@ def poezio_colors_to_html(string): if 'strong' not in opened_elements: opened_elements.append('strong') res += '' - elif attr_char.isdigit(): + elif attr_char.isnumeric(): number = int(attr_char) if number in number_to_color_names: + if 'strong' in opened_elements: + res += '' + opened_elements.remove('strong') if 'span' in opened_elements: res += '' else: @@ -212,7 +215,7 @@ def poezio_colors_to_xhtml(string): if 'strong' not in open_elements: res += '' open_elements.append('strong') - elif attr_char.isdigit(): + elif attr_char.isnumeric(): self._win.attron(common.curses_color_pair(int(attr_char))) next_attr_char = string.find('\x19') -- cgit v1.2.3