@@ -33,6 +33,7 @@ class Windows10_Output:
33
33
def __init__ (
34
34
self , stdout : TextIO , default_color_depth : ColorDepth | None = None
35
35
) -> None :
36
+ self .default_color_depth = default_color_depth
36
37
self .win32_output = Win32Output (stdout , default_color_depth = default_color_depth )
37
38
self .vt100_output = Vt100_Output (
38
39
stdout , lambda : Size (0 , 0 ), default_color_depth = default_color_depth
@@ -74,12 +75,30 @@ def __getattr__(self, name: str) -> Any:
74
75
"get_win32_screen_buffer_info" ,
75
76
"enable_bracketed_paste" ,
76
77
"disable_bracketed_paste" ,
77
- "get_default_color_depth" ,
78
78
):
79
79
return getattr (self .win32_output , name )
80
80
else :
81
81
return getattr (self .vt100_output , name )
82
82
83
+ def get_default_color_depth (self ) -> ColorDepth :
84
+ """
85
+ Return the default color depth for a windows terminal.
86
+
87
+ Contrary to the Vt100 implementation, this doesn't depend on a $TERM
88
+ variable.
89
+ """
90
+ if self .default_color_depth is not None :
91
+ return self .default_color_depth
92
+
93
+ # Previously, we used `DEPTH_4_BIT`, even on Windows 10. This was
94
+ # because true color support was added after "Console Virtual Terminal
95
+ # Sequences" support was added, and there was no good way to detect
96
+ # what support was given.
97
+ # 24bit color support was added in 2016, so let's assume it's safe to
98
+ # take that as a default:
99
+ # https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/
100
+ return ColorDepth .TRUE_COLOR
101
+
83
102
84
103
Output .register (Windows10_Output )
85
104
0 commit comments