Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions syncplay/ui/consoleUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import threading
import time
import os
try:
import readline
except ImportError:
pass

import syncplay
from syncplay import constants
Expand All @@ -14,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 @@ -105,10 +110,17 @@ def showMessage(self, message, noTimestamp=False):
message = message.decode('utf-8')
except UnicodeEncodeError:
pass
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)
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