summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2017-05-01 12:12:19 +0200
committerJonathan Slenders <jonathan@slenders.be>2017-05-01 12:12:23 +0200
commit5e296c52fa04e23ca68766b563213c06e62a06fd (patch)
tree0408cef4f8e4a1da5f203bf5801e1d42f8b0012f /tests
parente7036d50aa964910e9bc14ce4c7588b82fe8aac8 (diff)
Support for \001 and \002 in ANSI string.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_formatted_text.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_formatted_text.py b/tests/test_formatted_text.py
index f67ceee8..17fe42dd 100644
--- a/tests/test_formatted_text.py
+++ b/tests/test_formatted_text.py
@@ -1,5 +1,5 @@
from __future__ import unicode_literals
-from prompt_toolkit.layout.formatted_text import HTML, to_formatted_text
+from prompt_toolkit.layout.formatted_text import HTML, ANSI, to_formatted_text
def test_basic_html():
@@ -33,3 +33,26 @@ def test_html_with_fg_bg():
('fg:#ff0000 bg:ansired', 'hello '),
('class:world fg:ansiblue bg:ansired', 'world'),
]
+
+
+def test_ansi_formatting():
+ value = ANSI('\x1b[32mHe\x1b[45mllo')
+
+ assert to_formatted_text(value) == [
+ ('#ansidarkgreen', 'H'),
+ ('#ansidarkgreen', 'e'),
+ ('#ansidarkgreen bg:#ansipurple', 'l'),
+ ('#ansidarkgreen bg:#ansipurple', 'l'),
+ ('#ansidarkgreen bg:#ansipurple', 'o'),
+ ]
+
+ # Zero width escapes.
+ value = ANSI('ab\001cd\002ef')
+
+ assert to_formatted_text(value) == [
+ ('', 'a'),
+ ('', 'b'),
+ ('[ZeroWidthEscape]', 'cd'),
+ ('', 'e'),
+ ('', 'f'),
+ ]