From 6aee75c803ef07cc1083b002ee4a2cd584d7323f Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Mon, 1 May 2023 20:34:54 -0400 Subject: [PATCH] use os.linesep just in case --- main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index cb5ca7a..2e5d3a3 100644 --- a/main.py +++ b/main.py @@ -36,7 +36,7 @@ config = { "print_status_after_insert" : True, "output_buffer_timeout" : 0.05, # 50 milliseconds "default_history" : 100, - "fixed_width" : 78, # Need room for the pre-message decoration + "fixed_width" : 76, # Need room for the pre-message decoration "tokenfile" : ".qcstoken" } @@ -112,7 +112,7 @@ def ws_onopen(ws): def main_loop(): - printr(Fore.GREEN + Style.BRIGHT + "\n-- Connected to live updates! --") + printr(Fore.GREEN + Style.BRIGHT + os.linesep + "-- Connected to live updates! --") if not ws.current_room: printr(Fore.YELLOW + "* You are not connected to any room! Press 'S' to search for a room! *") @@ -220,7 +220,7 @@ def ws_onmessage(ws, message): for key,value in statuses.items(): key = int(key) user = contentapi.get_user_or_default(result["data"]["objects"]["user"], key) - userlist_output += "\n" + Style.BRIGHT + " " + ("%s" % (user["username"] + Style.DIM + " #%d" % key)) + Style.RESET_ALL + " - " + value + userlist_output += os.linesep + Style.BRIGHT + " " + ("%s" % (user["username"] + Style.DIM + " #%d" % key)) + Style.RESET_ALL + " - " + value ws_print(ws, userlist_output) return # Live updates are messages, edits, user updates, etc. Check the event list to see @@ -244,10 +244,10 @@ def ws_onmessage(ws, message): # Produce the string output for a given message. Can be printed directly to console def get_message_string(ws, message, user): result = (MSGPREFIX + Fore.CYAN + Style.BRIGHT + user["username"] + " " + Style.DIM + "#%d" % user["id"] + - Fore.MAGENTA + " " + message["createDate"] + " [%d]" % message["id"] + "\n" + Style.RESET_ALL) + Fore.MAGENTA + " " + message["createDate"] + " [%d]" % message["id"] + os.linesep + Style.RESET_ALL) for t in textwrap.wrap(message["text"], width = ws.main_config["fixed_width"]): - result += (MSGPREFIX + t + "\n") - return result.rstrip("\n") + result += (MSGPREFIX + t + os.linesep) + return result.rstrip(os.linesep) # Produce a large string of output for all history in the current room. Can be printed directly to console @@ -258,8 +258,8 @@ def get_message_history_string(ws): message_block = "" for message in reversed(result["objects"]["message"]): user = contentapi.get_user_or_default(users, message["createUserId"]) - message_block += get_message_string(ws, message, user) + "\n" - return message_block.rstrip("\n") + message_block += get_message_string(ws, message, user) + os.linesep + return message_block.rstrip(os.linesep) return None @@ -371,7 +371,7 @@ def print_statusline(ws): room = "'" + (name[:(MAXTITLE - 3)] + '...' if len(name) > MAXTITLE else name) + "'" else: room = Fore.RED + Style.DIM + "NONE" + Style.NORMAL + Fore.BLACK - print(Back.GREEN + Fore.BLACK + "\n " + ws.user_info["username"] + " - " + room + " CTRL: h s g u i c t q " + Style.RESET_ALL) + print(Back.GREEN + Fore.BLACK + os.linesep + " " + ws.user_info["username"] + " - " + room + " CTRL: h s g u i c t q " + Style.RESET_ALL) # Print and then reset the style