from rich._win32_console import (
ENABLE_VIRTUAL_TERMINAL_PROCESSING,
GetConsoleMode,
GetStdHandle,
LegacyWindowsError,
)
except (AttributeError, ImportError, ValueError): # Fallback if we can't load the Windows DLL def get_windows_console_features() -> WindowsConsoleFeatures:
features = WindowsConsoleFeatures() return features
else:
def get_windows_console_features() -> WindowsConsoleFeatures: """Get windows console features.
Returns:
WindowsConsoleFeatures: An instance of WindowsConsoleFeatures. """
handle = GetStdHandle() try:
console_mode = GetConsoleMode(handle)
success = True except LegacyWindowsError:
console_mode = 0
success = False
vt = bool(success and console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
truecolor = False if vt:
win_version = sys.getwindowsversion()
truecolor = win_version.major > 10 or (
win_version.major == 10 and win_version.build >= 15063
)
features = WindowsConsoleFeatures(vt=vt, truecolor=truecolor) return features
if __name__ == "__main__": import platform
features = get_windows_console_features() from rich import print
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.