start of a major rewrite
This commit is contained in:
56
window.c
56
window.c
@@ -14,17 +14,14 @@ 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 dir rgt_dir;
|
||||
extern dir mid_dir;
|
||||
extern dir lft_dir;
|
||||
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;
|
||||
@@ -42,17 +39,17 @@ void window_top(WINDOW *win){
|
||||
mvwaddstr(win, 0, 0, top_buffer);
|
||||
mvwaddch(win, 0, strlen(top_buffer), '/');
|
||||
wattroff(win, COLOR_PAIR(COLOR_PATH));
|
||||
if (mid_file_count != 0) {
|
||||
mvwaddstr(win, 0, strlen(top_buffer)+1, mid_content[selected_file_current].file_name);
|
||||
if (mid_dir.file_count != 0) {
|
||||
mvwaddstr(win, 0, strlen(top_buffer)+1, mid_dir.current_file->file_name);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
} else {
|
||||
mvwaddstr(win, 0, terminal_width/2, "LOADING");
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
status |= STATUS_UPDATE_SCREEN_PRINTED;
|
||||
}
|
||||
}
|
||||
void window_btm(WINDOW *win, char force_render){
|
||||
void window_btm(WINDOW *win){
|
||||
werase(win);
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_btm) == 0) {
|
||||
@@ -62,62 +59,55 @@ void window_btm(WINDOW *win, char force_render){
|
||||
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 if (force_render) {
|
||||
/*force_render is used in stuff like open_with, search, and other functions that take over win_b,
|
||||
* while needing to avoid possible conflicts like thread_btm itself*/
|
||||
mvwprintw(win, 0, 0, "%s", btm_buffer);
|
||||
} else {
|
||||
} else {
|
||||
mvwaddstr(win, 0, terminal_width/2, "LOADING");
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
status |= STATUS_UPDATE_SCREEN_PRINTED;
|
||||
}
|
||||
}
|
||||
void window_lft(WINDOW *win){
|
||||
werase(win);
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_lft) == 0) {
|
||||
print_dir(win, 0, &lft_file_count, lft_content);
|
||||
print_dir(win, 0, &lft_dir);
|
||||
pthread_mutex_unlock(&mutex_lft);
|
||||
|
||||
} else {
|
||||
mvwaddstr(win, terminal_height/2, terminal_width/8, "LOADING");
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
status |= STATUS_UPDATE_SCREEN_PRINTED;
|
||||
}
|
||||
}
|
||||
void window_mid(WINDOW *win){
|
||||
werase(win);
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_mid) == 0) {
|
||||
if (mid_file_count == 0) {
|
||||
if (mid_dir.file_count == 0) {
|
||||
mvwaddstr(win, 0, 0, "empty");
|
||||
} else {
|
||||
print_dir(win, 1, &mid_file_count, mid_content);
|
||||
print_dir(win, 1, &mid_dir);
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
} else {
|
||||
mvwaddstr(win, terminal_height/2, terminal_width/4, "LOADING");
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
status |= STATUS_UPDATE_SCREEN_PRINTED;
|
||||
}
|
||||
}
|
||||
void window_rgt(WINDOW *win){
|
||||
werase(win);
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_rgt) == 0) {
|
||||
if (rgt_file_count == 0) {
|
||||
if (rgt_content[0].file_type == FILE_TYPE_OPEN_FILE) {
|
||||
mvwaddnstr(win, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
||||
} else if (rgt_content->permissions & S_IRUSR) {
|
||||
mvwaddstr(win, 0, 0, "not accessible");
|
||||
} else {
|
||||
mvwaddstr(win, 0, 0, "empty");
|
||||
}
|
||||
|
||||
|
||||
if (!rgt_dir.current_file) {
|
||||
mvwaddstr(win, 0, 0, "not accessible");
|
||||
}else if (rgt_dir.current_file->file_type == FILE_TYPE_OPEN_FILE) {
|
||||
mvwaddnstr(win, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||
mvwaddstr(win, 0, 0, "not accessible");
|
||||
} else {
|
||||
print_dir(win, 0, &rgt_file_count, rgt_content);
|
||||
print_dir(win, 0, &rgt_dir);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mutex_rgt);
|
||||
} else {
|
||||
mvwaddstr(win, terminal_height/2, terminal_width/4, "LOADING");
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
status |= STATUS_UPDATE_SCREEN_PRINTED;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user