|
2 | 2 | """
|
3 | 3 | Support for ANSI escape sequences which are used for things like applying style to text,
|
4 | 4 | setting the window title, and asynchronous alerts.
|
5 |
| - """ |
| 5 | +""" |
| 6 | + |
6 | 7 | import functools
|
7 | 8 | import re
|
8 | 9 | from enum import (
|
@@ -62,25 +63,25 @@ def __repr__(self) -> str:
|
62 | 63 | """
|
63 | 64 |
|
64 | 65 | # Regular expression to match ANSI style sequence
|
65 |
| -ANSI_STYLE_RE = re.compile(fr'{ESC}\[[^m]*m') |
| 66 | +ANSI_STYLE_RE = re.compile(rf'{ESC}\[[^m]*m') |
66 | 67 |
|
67 | 68 | # Matches standard foreground colors: CSI(30-37|90-97|39)m
|
68 |
| -STD_FG_RE = re.compile(fr'{ESC}\[(?:[39][0-7]|39)m') |
| 69 | +STD_FG_RE = re.compile(rf'{ESC}\[(?:[39][0-7]|39)m') |
69 | 70 |
|
70 | 71 | # Matches standard background colors: CSI(40-47|100-107|49)m
|
71 |
| -STD_BG_RE = re.compile(fr'{ESC}\[(?:(?:4|10)[0-7]|49)m') |
| 72 | +STD_BG_RE = re.compile(rf'{ESC}\[(?:(?:4|10)[0-7]|49)m') |
72 | 73 |
|
73 | 74 | # Matches eight-bit foreground colors: CSI38;5;(0-255)m
|
74 |
| -EIGHT_BIT_FG_RE = re.compile(fr'{ESC}\[38;5;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])m') |
| 75 | +EIGHT_BIT_FG_RE = re.compile(rf'{ESC}\[38;5;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])m') |
75 | 76 |
|
76 | 77 | # Matches eight-bit background colors: CSI48;5;(0-255)m
|
77 |
| -EIGHT_BIT_BG_RE = re.compile(fr'{ESC}\[48;5;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])m') |
| 78 | +EIGHT_BIT_BG_RE = re.compile(rf'{ESC}\[48;5;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])m') |
78 | 79 |
|
79 | 80 | # Matches RGB foreground colors: CSI38;2;(0-255);(0-255);(0-255)m
|
80 |
| -RGB_FG_RE = re.compile(fr'{ESC}\[38;2(?:;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])){{3}}m') |
| 81 | +RGB_FG_RE = re.compile(rf'{ESC}\[38;2(?:;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])){{3}}m') |
81 | 82 |
|
82 | 83 | # Matches RGB background colors: CSI48;2;(0-255);(0-255);(0-255)m
|
83 |
| -RGB_BG_RE = re.compile(fr'{ESC}\[48;2(?:;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])){{3}}m') |
| 84 | +RGB_BG_RE = re.compile(rf'{ESC}\[48;2(?:;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])){{3}}m') |
84 | 85 |
|
85 | 86 |
|
86 | 87 | def strip_style(text: str) -> str:
|
|
0 commit comments