mirror of
https://github.com/markqvist/NomadNet.git
synced 2026-10-26 02:48:48 -04:00
Soft-fail and block missing termios on Windows
This commit is contained in:
parent
e5d7de4537
commit
725c5a1b42
1 changed files with 5 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue