Make italics work
This commit is contained in:
parent
bd7b52988c
commit
156d170d13
4 changed files with 11 additions and 4 deletions
|
@ -20,7 +20,7 @@ from poezio.theming import to_curses_attr, read_tuple
|
|||
FORMAT_CHAR = '\x19'
|
||||
# These are non-printable chars, so they should never appear in the input,
|
||||
# I guess. But maybe we can find better chars that are even less risky.
|
||||
format_chars = '\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18'
|
||||
format_chars = '\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x1A'
|
||||
|
||||
|
||||
class DummyWin(object):
|
||||
|
@ -132,7 +132,7 @@ class Win(object):
|
|||
self._win.attron(curses.A_UNDERLINE)
|
||||
elif char == 'b':
|
||||
self._win.attron(curses.A_BOLD)
|
||||
elif char == 'i' and has_italic:
|
||||
elif char == 'i':
|
||||
self._win.attron(attr_italic)
|
||||
else:
|
||||
# this will reset previous bold/uderline sequences if any was used
|
||||
|
|
|
@ -31,7 +31,7 @@ class Input(Win):
|
|||
passing the list of items that can be used to complete. The completion can be used
|
||||
in a very flexible way.
|
||||
"""
|
||||
text_attributes = 'bou1234567t'
|
||||
text_attributes = 'bou1234567ti'
|
||||
clipboard = '' # A common clipboard for all the inputs, this makes
|
||||
|
||||
# it easy cut and paste text between various input
|
||||
|
|
|
@ -491,7 +491,8 @@ def convert_simple_to_full_colors(text):
|
|||
'\x16': '\x196',
|
||||
'\x17': '\x197',
|
||||
'\x18': '\x198',
|
||||
'\x19': '\x199'
|
||||
'\x19': '\x199',
|
||||
'\x1A': '\x19i'
|
||||
})
|
||||
text = text.translate(mapping)
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ def test_poezio_colors_to_html():
|
|||
text = '\x19bcoucou\x19o toto \x194}titi'
|
||||
assert poezio_colors_to_html(text) == base + '<span style="font-weight: bold;">coucou</span> toto <span style="color: blue;">titi</span>' + end
|
||||
|
||||
text = '\x19icoucou'
|
||||
assert poezio_colors_to_html(text) == base + '<span style="font-style: italic;">coucou</span>' + end
|
||||
|
||||
def test_xhtml_to_poezio_colors():
|
||||
start = b'<body xmlns="http://www.w3.org/1999/xhtml"><p>'
|
||||
end = b'</p></body>'
|
||||
|
@ -45,6 +48,9 @@ def test_xhtml_to_poezio_colors():
|
|||
xhtml = start + b'<a href="http://perdu.com">http://perdu.com</a>' + end
|
||||
assert xhtml_to_poezio_colors(xhtml) == '\x19uhttp://perdu.com\x19o'
|
||||
|
||||
xhtml = start + b'<span style="font-style: italic">Test</span>' + end
|
||||
assert xhtml_to_poezio_colors(xhtml) == '\x19iTest\x19o'
|
||||
|
||||
xhtml = b'<div style="font-weight:bold">Allo <div style="color:red">test <div style="color: blue">test2</div></div></div>'
|
||||
assert xhtml_to_poezio_colors(xhtml, force=True) == '\x19bAllo \x19196}test \x1921}test2\x19o'
|
||||
|
||||
|
|
Loading…
Reference in a new issue