@@ -17,6 +17,7 @@ def get_all_code_styles() -> dict[str, BaseStyle]:
1717 for name in get_all_styles ()
1818 }
1919 result ["win32" ] = Style .from_dict (win32_code_style )
20+ result ["default-ansi" ] = Style .from_dict (default_ansi_code_style )
2021 return result
2122
2223
@@ -38,6 +39,55 @@ def generate_style(python_style: BaseStyle, ui_style: BaseStyle) -> BaseStyle:
3839 return merge_styles ([python_style , ui_style ])
3940
4041
42+ # Use ANSI colors for the default theme.
43+ # This is `DefaultStyle` from Pygments, but adopted to use ANSI colors instead
44+ # of RGB. This adopts bettor to light/dark mode, because the built-in themes
45+ # from a terminal are typically designed for whatever background is used.
46+ # All the other Pygments themes use RGB, which is fine, because the user
47+ # consciously chooses what works for them.
48+ default_ansi_code_style = {
49+ "pygments.whitespace" : "ansigray" , # "#bbbbbb",
50+ "pygments.comment" : "italic ansibrightblack" , # "italic #3d7b7b",
51+ "pygments.comment.preproc" : "noitalic ansired" , # "noitalic #9c6500",
52+ "pygments.keyword" : "bold ansigreen" , # "bold #008000",
53+ "pygments.keyword.pseudo" : "nobold" ,
54+ "pygments.keyword.type" : "nobold ansired" , # "nobold #b00040",
55+ "pygments.operator" : "ansibrightblack" , # "#666666",
56+ "pygments.operator.word" : "bold ansimagenta" , # "bold #aa22ff",
57+ "pygments.name.builtin" : "ansigreen" , # "#008000",
58+ "pygments.name.function" : "ansibrightblue" , # "#0000ff",
59+ "pygments.name.class" : "bold ansibrightblue" , # "bold #0000ff",
60+ "pygments.name.namespace" : "bold ansibrightblack" , # "bold #0000ff",
61+ "pygments.name.exception" : "bold ansired" , # "bold #cb3f38",
62+ "pygments.name.variable" : "ansiblue" , # "#19177c",
63+ "pygments.name.constant" : "ansired" , # "#880000",
64+ "pygments.name.label" : "ansiyellow" , # "#767600",
65+ "pygments.name.entity" : "bold ansibrightblack" , # "bold #717171",
66+ "pygments.name.attribute" : "ansibrightblack" , # "#687822",
67+ "pygments.name.tag" : "bold ansigreen" , # "bold #008000",
68+ "pygments.name.decorator" : "ansimagenta" , # "#aa22ff",
69+ "pygments.literal.string" : "ansired" , # "#ba2121",
70+ "pygments.literal.string.doc" : "italic" ,
71+ "pygments.literal.string.interpol" : "bold ansibrightblack" , # "bold #a45a77",
72+ "pygments.literal.string.escape" : "bold ansired" , # "bold #aa5d1f",
73+ "pygments.literal.string.regex" : "ansibrightblack" , # "#a45a77",
74+ "pygments.literal.string.symbol" : "ansiblue" , # "#19177c",
75+ "pygments.literal.string.other" : "ansigreen" , # "#008000",
76+ "pygments.literal.number" : "ansibrightblack" , # "#666666",
77+ "pygments.generic.heading" : "bold ansiblue" , # "bold #000080",
78+ "pygments.generic.subheading" : "bold ansimagenta" , # "bold #800080",
79+ "pygments.generic.deleted" : "ansired" , # "#a00000",
80+ "pygments.generic.inserted" : "ansigreen" , # "#008400",
81+ "pygments.generic.error" : "ansigreen" , # "#e40000",
82+ "pygments.generic.emph" : "italic" ,
83+ "pygments.generic.strong" : "bold" ,
84+ "pygments.generic.emphstrong" : "bold italic" ,
85+ "pygments.generic.prompt" : "bold ansiblue" , # "bold #000080",
86+ "pygments.generic.output" : "ansibrightblack" , # "#717171",
87+ "pygments.generic.traceback" : "ansiblue" , # "#04d",
88+ "pygments.error" : "" , # "border:#ff0000",
89+ }
90+
4191# Code style for Windows consoles. They support only 16 colors,
4292# so we choose a combination that displays nicely.
4393win32_code_style = {
0 commit comments