summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-05-11 14:33:22 +0200
committermathieui <mathieui@mathieui.net>2011-05-11 14:33:22 +0200
commitc631673cf315dcaadb0c2a76a9e0d62dc840766b (patch)
treef0d2c031055ffc8ba56349725e257d7b5a79369a
parent4a007eb42b8a44ce0ae2195d88962a7b1eebffc5 (diff)
downloadpoezio-c631673cf315dcaadb0c2a76a9e0d62dc840766b.tar.gz
poezio-c631673cf315dcaadb0c2a76a9e0d62dc840766b.tar.bz2
poezio-c631673cf315dcaadb0c2a76a9e0d62dc840766b.tar.xz
poezio-c631673cf315dcaadb0c2a76a9e0d62dc840766b.zip
should fix #2161, and enable xhtml-im while in debug
-rw-r--r--src/core.py3
-rw-r--r--src/windows.py21
-rw-r--r--src/xhtml.py7
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 += '<strong>'
- 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 += '</strong>'
+ opened_elements.remove('strong')
if 'span' in opened_elements:
res += '</span>'
else:
@@ -212,7 +215,7 @@ def poezio_colors_to_xhtml(string):
if 'strong' not in open_elements:
res += '<strong>'
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')