There was an error while loading. Please reload this page.
1 parent 81df8f9 commit 4c1df46Copy full SHA for 4c1df46
1 file changed
Lib/_pyrepl/utils.py
@@ -20,7 +20,19 @@
20
21
22
ANSI_ESCAPE_SEQUENCE = re.compile(
23
- r"\x1b(?:\[[ -@]*[A-~]|\][^\x1b\x07]*(?:\x07|\x1b\\))"
+ 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,
36
)
37
ZERO_WIDTH_BRACKET = re.compile(r"\x01.*?\x02")
38
ZERO_WIDTH_TRANS = str.maketrans({"\x01": "", "\x02": ""})
0 commit comments