aboutsummaryrefslogtreecommitdiffstats
path: root/idatui/kittygfx.py
diff options
context:
space:
mode:
authorblasty <peter@haxx.in>2026-08-21 12:09:12 +0200
committerblasty <peter@haxx.in>2026-08-21 12:09:21 +0200
commit9541043c9dee7973c140159b3af561c6d0405e9e (patch)
tree1395ffadb7dd44b4b2acc3b1f2348fa367667dc8 /idatui/kittygfx.py
parentsplash: give the logo a placement id so re-anchoring replaces, not stacks (diff)
parentSwitch to ida-nexus (diff)
downloadida-tui-9541043c9dee7973c140159b3af561c6d0405e9e.tar.gz
ida-tui-9541043c9dee7973c140159b3af561c6d0405e9e.tar.xz
ida-tui-9541043c9dee7973c140159b3af561c6d0405e9e.zip
Merge PR #1 from mrexodia: Windows support and auto-refresh on events
https://github.com/blasty/ida-tui/pull/1 — from the ida-nexus (né ida-codemode) maintainer: kitty-graphics fallback for platforms without termios, Ctrl+R view refresh, typed remote operations through ida_nexus RemoteModule, live auto-refresh from other clients' IDB events (upstream item 7), discard-without-save (item 6), and the ida-nexus 0.7.0 rename. tests/test_kittygfx.py is the union of both sides' files: our escape- construction checks plus the PR's cross-platform fallback checks.
Diffstat (limited to 'idatui/kittygfx.py')
-rw-r--r--idatui/kittygfx.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/idatui/kittygfx.py b/idatui/kittygfx.py
index 2f6766d..62fd6a6 100644
--- a/idatui/kittygfx.py
+++ b/idatui/kittygfx.py
@@ -79,8 +79,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)
@@ -144,7 +152,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