From a57869a7a1ffd37f3a179c08119634865caeaf6d Mon Sep 17 00:00:00 2001 From: nova Date: Sat, 23 Aug 2025 22:48:46 +0200 Subject: [PATCH] imrovenments to rendering --- window.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/window.c b/window.c index 33b54ed..f87e337 100644 --- a/window.c +++ b/window.c @@ -5,6 +5,8 @@ #include "defines.h" #include "dir.h" +extern unsigned int terminal_height; +extern unsigned int terminal_width; extern unsigned int status; extern char *input; @@ -42,15 +44,13 @@ void window_top(WINDOW *win){ wattroff(win, COLOR_PAIR(COLOR_PATH)); pthread_mutex_unlock(&mutex_top); } else { - wprintw(win,"loading"); + mvwaddstr(win, 0, terminal_width/2, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } } void window_btm(WINDOW *win){ werase(win); - unsigned long local_width; - unsigned long local_height; - getmaxyx(win, local_height, local_width); + if (pthread_mutex_trylock(&mutex_btm) == 0) { if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/ mvwprintw(win, 0, 0, "%s", btm_buffer); @@ -59,31 +59,25 @@ void window_btm(WINDOW *win){ /*the printing of the input char is done in user_interactions*/ /*the printing of all possible inputs are done in user_interactions */ } else { - mvwprintw(win, local_height/2, local_width/2, "LOADING"); + mvwaddstr(win, 0, terminal_width/2, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } } void window_lft(WINDOW *win){ werase(win); - unsigned long local_width; - unsigned long local_height; - getmaxyx(win, local_height, local_width); if (pthread_mutex_trylock(&mutex_lft) == 0) { print_dir(win, 0, &lft_file_count, lft_content); pthread_mutex_unlock(&mutex_lft); } else { - mvwprintw(win, local_height/2, local_width/2, "LOADING"); + mvwaddstr(win, terminal_height/2, terminal_width/8, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } } void window_mid(WINDOW *win){ werase(win); - unsigned long local_width; - unsigned long local_height; - getmaxyx(win, local_height, local_width); if (pthread_mutex_trylock(&mutex_mid) == 0) { if (mid_file_count == 0) { mvwprintw(win, 0, 0, "empty"); @@ -92,16 +86,13 @@ void window_mid(WINDOW *win){ } pthread_mutex_unlock(&mutex_mid); } else { - mvwprintw(win, local_height/2, local_width/2, "LOADING"); + mvwaddstr(win, terminal_height/2, terminal_width/4, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } } void window_rgt(WINDOW *win){ werase(win); - unsigned long local_width; - unsigned long local_height; - getmaxyx(win, local_height, local_width); if (pthread_mutex_trylock(&mutex_rgt) == 0) { if (rgt_file_count == 0) { if (rgt_content[0].file_type == FILE_TYPE_OPEN_FILE) { @@ -116,7 +107,7 @@ void window_rgt(WINDOW *win){ } pthread_mutex_unlock(&mutex_rgt); } else { - mvwprintw(win, local_height/2, local_width/2, "LOADING"); + mvwaddstr(win, terminal_height/2, terminal_width/4, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } }