diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-10-20 23:42:13 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2013-10-20 23:42:13 +0200 |
commit | b12a6b3ba993f7ee515b39edee1816a2b3587e6c (patch) | |
tree | ccfc8f7ae8e2424f284c9c344566ba921b30b225 /src/xhtml.py | |
parent | dd4f8661a969233267c4ca30bf4f204dcb03e230 (diff) | |
download | poezio-b12a6b3ba993f7ee515b39edee1816a2b3587e6c.tar.gz poezio-b12a6b3ba993f7ee515b39edee1816a2b3587e6c.tar.bz2 poezio-b12a6b3ba993f7ee515b39edee1816a2b3587e6c.tar.xz poezio-b12a6b3ba993f7ee515b39edee1816a2b3587e6c.zip |
Improve the input a lot
Noticeable changes:
- The input "view" is smarter, it always move to a decent position so we can
see enough text around the cursor.
- The cursor goes at the end of the input when pasting some long text
- The formatting chars (^C and o, b, a, 1, 2, 3 etc) are now visible in the
input. This makes it a lot easier to know where these special characters
are, to change them and efficiently edit our text (we just lose a little,
on the cosmetic side, but who cares)
- The code is actually a lot simpler in the functions to move the cursor,
insert/delete chars: we do not have to deal with special cases where the
formatting characters are actually composed of two chars.
fixes #2183
Diffstat (limited to 'src/xhtml.py')
-rw-r--r-- | src/xhtml.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/xhtml.py b/src/xhtml.py index 7a3d4da5..9c0ed7eb 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -388,6 +388,13 @@ def convert_simple_to_full_colors(text): takes a \x19n formatted string and returns a \x19n} formatted one. """ + # TODO, have a single list of this. This is some sort of + # dusplicate from windows.format_chars + mapping = str.maketrans({'\x0E': '\x19b', '\x0F': '\x19o', '\x10': '\x19u', + '\x11': '\x191', '\x12': '\x192','\x13': '\x193', + '\x14': '\x194', '\x15': '\x195','\x16': '\x196', + '\x17': '\x197', '\x18': '\x198','\x19': '\x199'}) + text = text.translate(mapping) def add_curly_bracket(match): return match.group(0) + '}' return re.sub(xhtml_simple_attr_re, add_curly_bracket, text) |