From 258222160ea4a114a702889c72b3ff88fdc34b04 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 24 Feb 2023 16:31:20 +0100 Subject: [PATCH] sort of fixed received message formatting but actually not --- src/chat/main/client.c | 1 - src/chat/misc.c | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/chat/main/client.c b/src/chat/main/client.c index df70f57..d9ca115 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -50,7 +50,6 @@ int main(void) for (;;) { - printf(">>> "); //TODO: Fix formatting getline(&line, &line_length, stdin); why2_send_socket(line, listen_socket); diff --git a/src/chat/misc.c b/src/chat/misc.c index 6dc2b24..6aeff86 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -265,8 +265,18 @@ void why2_clean_threads(void) void *why2_listen_server(void *socket) { + char *read = NULL; + + printf(">>> "); //TODO: Make this smart + fflush(stdout); + for (;;) { - printf("%s\n", why2_read_socket(*((int*) socket))); + read = why2_read_socket(*((int*) socket)); //TODO: Fix other user message formatting + printf("\033[A\33[2K\r"); + printf("%s\n>>> ", read); + fflush(stdout); + + why2_deallocate(read); } } \ No newline at end of file