more posix nuance
This commit is contained in:
parent
89c51c05f1
commit
5224137713
1 changed files with 12 additions and 0 deletions
|
|
@ -89,6 +89,16 @@ ANSI_ESCAPE_RE = re.compile(
|
||||||
# ==========================================================
|
# ==========================================================
|
||||||
|
|
||||||
# ===================== UTILITY FUNCTIONS =================
|
# ===================== UTILITY FUNCTIONS =================
|
||||||
|
def apply_backspaces(s):
|
||||||
|
buf = []
|
||||||
|
for c in s:
|
||||||
|
if c == "\x08":
|
||||||
|
if buf:
|
||||||
|
buf.pop()
|
||||||
|
else:
|
||||||
|
buf.append(c)
|
||||||
|
return "".join(buf)
|
||||||
|
|
||||||
def acquire_single_instance(lockfile_base: str):
|
def acquire_single_instance(lockfile_base: str):
|
||||||
"""
|
"""
|
||||||
Ensures only one instance of the program is running per user.
|
Ensures only one instance of the program is running per user.
|
||||||
|
|
@ -366,6 +376,8 @@ def monitor_game_pty(master_fd):
|
||||||
|
|
||||||
while b"\n" in buffer:
|
while b"\n" in buffer:
|
||||||
line, buffer = buffer.split(b"\n", 1)
|
line, buffer = buffer.split(b"\n", 1)
|
||||||
|
if os.name != "nt":
|
||||||
|
line = apply_backspaces(line)
|
||||||
line = strip_ansi(line.decode(errors="ignore")).strip()
|
line = strip_ansi(line.decode(errors="ignore")).strip()
|
||||||
if line:
|
if line:
|
||||||
if "--debug" in sys.argv:
|
if "--debug" in sys.argv:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue