File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737
3838BASE_DELIMITERS = " \t \n " + "" .join (constants .QUOTES ) + "" .join (constants .REDIRECTION_CHARS )
3939
40+ # prompt_toolkit accepts these standard ANSI color names directly
41+ ANSI_NAMES = (
42+ "ansiblack" ,
43+ "ansired" ,
44+ "ansigreen" ,
45+ "ansiyellow" ,
46+ "ansiblue" ,
47+ "ansimagenta" ,
48+ "ansicyan" ,
49+ "ansiwhite" ,
50+ "ansibrightblack" ,
51+ "ansibrightred" ,
52+ "ansibrightgreen" ,
53+ "ansibrightyellow" ,
54+ "ansibrightblue" ,
55+ "ansibrightmagenta" ,
56+ "ansibrightcyan" ,
57+ "ansibrightwhite" ,
58+ )
59+
4060
4161def pt_filter_style (text : str | ANSI ) -> str | ANSI :
4262 """Strip styles if disallowed by ru.ALLOW_STYLE. Otherwise return an ANSI object.
@@ -61,26 +81,7 @@ def rich_to_pt_color(color: "Color | None") -> str:
6181 # Use prompt_toolkit's 16 standard ansi color names if applicable.
6282 # This prevents overriding terminal themes with absolute RGB values.
6383 if color .number is not None and 0 <= color .number <= 15 :
64- # prompt_toolkit accepts these standard names directly
65- ansi_names = [
66- "ansiblack" ,
67- "ansired" ,
68- "ansigreen" ,
69- "ansiyellow" ,
70- "ansiblue" ,
71- "ansimagenta" ,
72- "ansicyan" ,
73- "ansiwhite" ,
74- "ansibrightblack" ,
75- "ansibrightred" ,
76- "ansibrightgreen" ,
77- "ansibrightyellow" ,
78- "ansibrightblue" ,
79- "ansibrightmagenta" ,
80- "ansibrightcyan" ,
81- "ansibrightwhite" ,
82- ]
83- return ansi_names [color .number ]
84+ return ANSI_NAMES [color .number ]
8485
8586 # For 8-bit and truecolor, we fallback to hex RGB strings which prompt-toolkit supports natively
8687 c = color .get_truecolor ()
You can’t perform that action at this time.
0 commit comments