diff --git a/RA3MP3Playback.py b/RA3MP3Playback.py index ef26c83..369ee2c 100644 --- a/RA3MP3Playback.py +++ b/RA3MP3Playback.py @@ -89,6 +89,16 @@ ANSI_ESCAPE_RE = re.compile( # ========================================================== # ===================== 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): """ 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: line, buffer = buffer.split(b"\n", 1) + if os.name != "nt": + line = apply_backspaces(line) line = strip_ansi(line.decode(errors="ignore")).strip() if line: if "--debug" in sys.argv: