Soft-fail and block missing termios on Windows

This commit is contained in:
Mark Qvist committed 2026-09-27 14:52:39 +02:00
1 parent e5d7de4537
commit 725c5a1b42
1 file changed
+5 -2
+5 -2
View File
@@ -10,9 +10,11 @@ import os
import select
import shutil
import sys
import termios
import time
try: import termios
except: termios = None
from . import _ctlseqs
QUERY_TIMEOUT = 0.3
@@ -43,7 +45,7 @@ def _open_tty():
def query_tty(request, timeout=QUERY_TIMEOUT):
# Sends a query to the terminal and returns the raw response.
global _query_failed
if _query_failed: return b""
if _query_failed or not termios: return b""
fd = _open_tty()
if fd == -1:
@@ -121,6 +123,7 @@ def _cell_size_from_winsize(buf):
def _query_cell_size():
# Determines the current cell size in pixels, or None if unknown.
if not termios: return None
fd = _open_tty()
if fd != -1:
# First, try the TIOCGWINSZ pixel fields (fast, no query)