Update client.py
This commit is contained in:
@@ -67,7 +67,7 @@ def recv_json(sock):
|
|||||||
return json.loads(buffer.decode("utf-8"))
|
return json.loads(buffer.decode("utf-8"))
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
continue
|
continue
|
||||||
return {} # fallback, lege dict als niks lukt
|
return {}
|
||||||
|
|
||||||
def login():
|
def login():
|
||||||
base_dir = Path(__file__).parent
|
base_dir = Path(__file__).parent
|
||||||
@@ -140,6 +140,8 @@ chat_data = recv_json(s)
|
|||||||
chat_names = list(chat_data.keys())
|
chat_names = list(chat_data.keys())
|
||||||
|
|
||||||
def draw_chat_window(messages, chatname):
|
def draw_chat_window(messages, chatname):
|
||||||
|
current_input = readline.get_line_buffer() # bewaar wat je typt
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
w, h = term_size()
|
w, h = term_size()
|
||||||
print(blauw_bg + wit + chatname.center(w) + reset)
|
print(blauw_bg + wit + chatname.center(w) + reset)
|
||||||
@@ -153,6 +155,9 @@ def draw_chat_window(messages, chatname):
|
|||||||
else:
|
else:
|
||||||
print_white(f"[{user}] {text}")
|
print_white(f"[{user}] {text}")
|
||||||
print("-" * w)
|
print("-" * w)
|
||||||
|
|
||||||
|
readline.insert_text(current_input) # herstel input
|
||||||
|
readline.redisplay()
|
||||||
|
|
||||||
def chat_session(chatkeuze):
|
def chat_session(chatkeuze):
|
||||||
global chat_messages, chat_users
|
global chat_messages, chat_users
|
||||||
|
|||||||
Reference in New Issue
Block a user