Skip to content

Commit 4c1df46

Browse files
committed
Update ANSI_ESCAPE_SEQUENCE comments
1 parent 81df8f9 commit 4c1df46

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎Lib/_pyrepl/utils.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@
2020

2121

2222
ANSI_ESCAPE_SEQUENCE = re.compile(
23-
r"\x1b(?:\[[ -@]*[A-~]|\][^\x1b\x07]*(?:\x07|\x1b\\))"
23+
r"""
24+
\x1b
25+
(?:
26+
# CSI: ESC [ followed by parameter/intermediate bytes and a final byte.
27+
# For example, ESC [ 31 m ("\x1b[31m") selects red foreground text.
28+
\[ [ -@]* [A-~]
29+
|
30+
# OSC: ESC ] followed by a payload terminated by BEL or ST (ESC \).
31+
# For example, ESC ] 0 ; title BEL ("\x1b]0;title\x07") sets the title.
32+
\] [^\x1b\x07]* (?: \x07 | \x1b\\ )
33+
)
34+
""",
35+
re.X,
2436
)
2537
ZERO_WIDTH_BRACKET = re.compile(r"\x01.*?\x02")
2638
ZERO_WIDTH_TRANS = str.maketrans({"\x01": "", "\x02": ""})

0 commit comments

Comments
 (0)