Skip to content

Commit

Permalink
do not use ansi escape codes and readline if on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gospodin55 committed Oct 15, 2023
1 parent 109303f commit a82cfde
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions syncplay/ui/consoleUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import threading
import time
import os
import readline
try:
import readline
except ImportError:
pass

import syncplay
from syncplay import constants
Expand All @@ -15,6 +18,7 @@

class ConsoleUI(threading.Thread):
def __init__(self):
self.isWindows = sys.platform.startswith(constants.OS_WINDOWS)
self.promptMode = threading.Event()
self.PromptResult = ""
self.promptMode.set()
Expand Down Expand Up @@ -106,15 +110,17 @@ def showMessage(self, message, noTimestamp=False):
message = message.decode('utf-8')
except UnicodeEncodeError:
pass
sys.stdout.write('\33[2K\r')
if not self.isWindows:
sys.stdout.write('\33[2K\r')
if noTimestamp:
print(message)
else:
print(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message)
line = readline.get_line_buffer()
if line != '':
print(line, end='')
sys.stdout.flush()
if not self.isWindows:
line = readline.get_line_buffer()
if line != '':
print(line, end='')
sys.stdout.flush()

def showDebugMessage(self, message):
print(message)
Expand Down

0 comments on commit a82cfde

Please sign in to comment.