Skip to content

Commit

Permalink
use ansi escape and readline so output doesnt mix with input in cli ui
Browse files Browse the repository at this point in the history
  • Loading branch information
gospodin55 committed Oct 14, 2023
1 parent 20846ca commit f1c6757
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions syncplay/ui/consoleUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import threading
import time
import os
import readline

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

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

0 comments on commit f1c6757

Please sign in to comment.