Skip to content

Commit 40d1373

Browse files
committed
update 1.8.3
1 parent c125d14 commit 40d1373

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
## ... `v1.8.3`
1818
* adjusted the look of the prompts and inputs of the `System.check_libs()` method
1919
* adjusted error messages throughout the whole library to all be structured about the same
20+
* fixed a small bug in `FormatCodes.__config_console()`, where it would cause an exception, because it tried to configure Windows specific console settings on non-Windows systems
2021

2122
## 11.09.2025 `v1.8.2`
2223
* the client command `xulbux-help` now tells you that there's a newer version of the library available, if you're not using the latest version

src/xulbux/format_codes.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
import ctypes as _ctypes
167167
import regex as _rx
168168
import sys as _sys
169+
import os as _os
169170
import re as _re
170171

171172

@@ -419,11 +420,16 @@ def __config_console() -> None:
419420
global _CONSOLE_ANSI_CONFIGURED
420421
if not _CONSOLE_ANSI_CONFIGURED:
421422
_sys.stdout.flush()
422-
kernel32 = _ctypes.windll.kernel32
423-
h = kernel32.GetStdHandle(-11)
424-
mode = _ctypes.c_ulong()
425-
kernel32.GetConsoleMode(h, _ctypes.byref(mode))
426-
kernel32.SetConsoleMode(h, mode.value | 0x0004)
423+
if _os.name == "nt":
424+
try:
425+
# ENABLE VT100 MODE ON WINDOWS TO BE ABLE TO USE ANSI CODES
426+
kernel32 = _ctypes.windll.kernel32
427+
h = kernel32.GetStdHandle(-11)
428+
mode = _ctypes.c_ulong()
429+
kernel32.GetConsoleMode(h, _ctypes.byref(mode))
430+
kernel32.SetConsoleMode(h, mode.value | 0x0004)
431+
except Exception:
432+
pass
427433
_CONSOLE_ANSI_CONFIGURED = True
428434

429435
@staticmethod

0 commit comments

Comments
 (0)