#include #include #include #include "defines.h" extern unsigned int status; extern char *input; extern unsigned int timeout_time; extern unsigned int color_count; extern color *colors; extern file *mid_content; extern file *lft_content; extern file *rgt_content; extern char *top_buffer; extern char *rgt_buffer; extern char *btm_buffer; extern unsigned long lft_file_count; extern unsigned long mid_file_count; extern unsigned long rgt_file_count; extern unsigned long top_width; extern pthread_mutex_t mutex_top; extern pthread_mutex_t mutex_btm; extern pthread_mutex_t mutex_lft; extern pthread_mutex_t mutex_mid; extern pthread_mutex_t mutex_rgt; void window_top(WINDOW *win){ werase(win); if (pthread_mutex_trylock(&mutex_top) == 0) { wattron(win, COLOR_PAIR(COLOR_PATH)); if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/ mvwprintw(win, 0, 0, "%s", top_buffer); } wattroff(win, COLOR_PAIR(COLOR_PATH)); pthread_mutex_unlock(&mutex_top); } else { wprintw(win,"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); } pthread_mutex_unlock(&mutex_btm); /*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"); status |= STATUS_UPDATE_SCREEN_0; } } void window_lft(WINDOW *win){ werase(win); box(win, 0, 0); unsigned long local_width; unsigned long local_height; getmaxyx(win, local_height, local_width); if (pthread_mutex_trylock(&mutex_lft) == 0) { print_dir(win, &local_width, &lft_file_count, lft_content); pthread_mutex_unlock(&mutex_lft); } else { mvwprintw(win, local_height/2, local_width/2, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } } void window_mid(WINDOW *win){ werase(win); box(win, 0, 0); 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"); } else { print_dir(win, &local_width, &mid_file_count, mid_content); } pthread_mutex_unlock(&mutex_mid); } else { mvwprintw(win, local_height/2, local_width/2, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } } void window_rgt(WINDOW *win){ werase(win); box(win, 0, 0); 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) { mvwprintw(win, 0, 0, "%s", rgt_buffer); } else { mvwprintw(win, 0, 0, "empty"); } } else { print_dir(win, &local_width, &rgt_file_count, rgt_content); } pthread_mutex_unlock(&mutex_rgt); } else { mvwprintw(win, local_height/2, local_width/2, "LOADING"); status |= STATUS_UPDATE_SCREEN_0; } }