From 61b93538fe6e03f175b907c19c2d196ecd860782 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 17 Aug 2026 15:21:59 +0200 Subject: Add kitty graphics fallback for Windows support --- idatui/kittygfx.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'idatui') diff --git a/idatui/kittygfx.py b/idatui/kittygfx.py index e53fba3..6f419ef 100644 --- a/idatui/kittygfx.py +++ b/idatui/kittygfx.py @@ -71,8 +71,16 @@ def log(msg: str) -> None: # Detection # --------------------------------------------------------------------------- # def _query_tty(timeout: float = 2.0) -> bool: - import termios - import tty as ttymod + # ``termios`` and ``/dev/tty`` are POSIX-only. Native Windows terminals + # generally don't expose the synchronous reply channel this probe needs; + # use the ANSI-art splash there instead of making graphics fatal to the + # whole application. IDATUI_KITTY=1 still permits an explicit override. + try: + import termios + import tty as ttymod + except ImportError: + log("supported: tty queries are unavailable on this platform") + return False try: fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY) @@ -136,7 +144,11 @@ def supported() -> bool: _supported = False # pilot tests, pipes, redirected output log("supported: stdout is not a tty") else: - _supported = _query_tty() + try: + _supported = _query_tty() + except Exception as exc: # graphics are optional on every platform + log(f"supported: terminal query failed ({type(exc).__name__}: {exc})") + _supported = False log(f"supported() -> {_supported}") return _supported -- cgit v1.3.1-sl0p