101 lines
2.4 KiB
C
101 lines
2.4 KiB
C
#include <curses.h>
|
|
#include <pthread.h>
|
|
#include "defines.h"
|
|
|
|
extern unsigned int status;
|
|
|
|
extern unsigned int color_count;
|
|
extern color *colors;
|
|
|
|
extern file *mid_content;
|
|
extern file *lft_content;
|
|
extern file *rgt_content;
|
|
extern char *top_content;
|
|
|
|
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){
|
|
unsigned long i = 0;
|
|
werase(win);
|
|
|
|
if (pthread_mutex_trylock(&mutex_top)) {
|
|
wprintw(win,"loading");
|
|
status |= STATUS_UPDATE_SCREEN_0;
|
|
|
|
} else {
|
|
wattron(win, COLOR_PAIR(COLOR_PATH));
|
|
mvwprintw(win, i, 0, "%s", top_content);
|
|
wattroff(win, COLOR_PAIR(COLOR_PATH));
|
|
pthread_mutex_unlock(&mutex_top);
|
|
}
|
|
}
|
|
void window_btm(WINDOW *win){
|
|
werase(win);
|
|
if (pthread_mutex_trylock(&mutex_btm)) {
|
|
} else {
|
|
pthread_mutex_unlock(&mutex_btm);
|
|
}
|
|
}
|
|
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)) {
|
|
mvwprintw(win, local_height/2, local_width/2, "LOADING");
|
|
status |= STATUS_UPDATE_SCREEN_0;
|
|
|
|
} else {
|
|
print_dir(win, &lft_file_count, lft_content);
|
|
pthread_mutex_unlock(&mutex_lft);
|
|
}
|
|
}
|
|
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)) {
|
|
mvwprintw(win, local_height/2, local_width/2, "LOADING");
|
|
status |= STATUS_UPDATE_SCREEN_0;
|
|
|
|
} else {
|
|
print_dir(win, &mid_file_count, mid_content);
|
|
pthread_mutex_unlock(&mutex_mid);
|
|
}
|
|
}
|
|
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)) {
|
|
mvwprintw(win, local_height/2, local_width/2, "LOADING");
|
|
status |= STATUS_UPDATE_SCREEN_0;
|
|
} else {
|
|
int i = 0;
|
|
for (i = 0; i < color_count; i++) {
|
|
wattron(win, COLOR_PAIR(colors[i].color_pair));
|
|
mvwprintw(win, i, 0, "%d", colors[i].color_pair);
|
|
mvwaddstr(win, i, 3,colors[i].file_extension);
|
|
wattroff(win, COLOR_PAIR(colors[i].color_pair));
|
|
}
|
|
pthread_mutex_unlock(&mutex_rgt);
|
|
}
|
|
}
|