code base good enough to actually progress
This commit is contained in:
134
window.c
134
window.c
@ -1,72 +1,88 @@
|
||||
#include <curses.h>
|
||||
#include <dirent.h>
|
||||
#include "backend.h"
|
||||
#include <pthread.h>
|
||||
#include "defines.h"
|
||||
|
||||
extern unsigned int terminal_height;
|
||||
extern unsigned int terminal_width;
|
||||
extern unsigned long file_count_l;
|
||||
extern unsigned long file_count_m;
|
||||
extern unsigned long file_count_r;
|
||||
extern unsigned int status;
|
||||
|
||||
extern char *mid_content;
|
||||
extern unsigned long *mid_width;
|
||||
extern unsigned long *mid_length_width;
|
||||
extern unsigned long *mid_file_name_width;
|
||||
extern char *top_content;
|
||||
extern unsigned long *top_length_width;
|
||||
extern char *lft_content;
|
||||
extern unsigned long *lft_width;
|
||||
extern unsigned long *lft_length_width;
|
||||
extern unsigned long *lft_file_name_width;
|
||||
|
||||
void window_main(WINDOW *win, unsigned int start_y, unsigned int start_x, file_data *dir_content){
|
||||
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;
|
||||
|
||||
//WINDOW *win = (window_data)window_data.win;
|
||||
unsigned int local_width;
|
||||
unsigned int local_height;
|
||||
void window_top(WINDOW *win){
|
||||
unsigned long i = 0;
|
||||
werase(win);
|
||||
|
||||
//{{{ size & positioning
|
||||
wresize(win, terminal_height, terminal_width/3);
|
||||
getmaxyx(win, local_height, local_width);
|
||||
mvwin(win, start_y, start_x);
|
||||
wclear(win);
|
||||
//}}}
|
||||
|
||||
wmove(win, 1, 1);
|
||||
if (pthread_mutex_trylock(&mutex_top)) {
|
||||
wprintw(win,"loading");
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
|
||||
print_dir(win, file_count_m, dir_content);
|
||||
|
||||
|
||||
|
||||
box(win,0,0);
|
||||
wrefresh(win);
|
||||
} else {
|
||||
for (i = 0; i<top_length_width[1]; i++) {
|
||||
mvwprintw(win, 0, i, "%c", top_content[i]);
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
}
|
||||
}
|
||||
void window_left(WINDOW *win, unsigned int start_y, unsigned int start_x, file_data *dir_content){
|
||||
|
||||
unsigned int local_width;
|
||||
unsigned int local_height;
|
||||
|
||||
//{{{ size & positioning
|
||||
wresize(win, terminal_height, terminal_width/3);
|
||||
getmaxyx(win, local_height, local_width);
|
||||
mvwin(win, start_y, start_x);
|
||||
wclear(win);
|
||||
//}}}
|
||||
|
||||
wmove(win, 1, 1);
|
||||
|
||||
print_dir(win, file_count_l, dir_content);
|
||||
|
||||
|
||||
box(win,0,0);
|
||||
wrefresh(win);
|
||||
void window_btm(WINDOW *win){
|
||||
werase(win);
|
||||
if (pthread_mutex_trylock(&mutex_btm)) {
|
||||
} else {
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
}
|
||||
}
|
||||
void window_right(WINDOW *win, unsigned int start_y, unsigned int start_x, file_data *dir_content){
|
||||
void window_lft(WINDOW *win){
|
||||
werase(win);
|
||||
box(win, 0, 0);
|
||||
|
||||
wmove(win, 0, 0);
|
||||
unsigned int local_width;
|
||||
unsigned int local_height;
|
||||
|
||||
//{{{ size & positioning
|
||||
wresize(win, terminal_height, terminal_width/3);
|
||||
unsigned long local_width;
|
||||
unsigned long local_height;
|
||||
getmaxyx(win, local_height, local_width);
|
||||
mvwin(win, start_y, start_x);
|
||||
wclear(win);
|
||||
//}}}
|
||||
if (pthread_mutex_trylock(&mutex_lft)) {
|
||||
mvwprintw(win, local_height/2, local_width/2, "LOADING");
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
|
||||
wmove(win, local_height/2, local_width/2);
|
||||
wprintw(win, "%d,%d", local_height, local_width);
|
||||
|
||||
box(win,0,0);
|
||||
wrefresh(win);
|
||||
} else {
|
||||
mvwprintw(win, local_height/2, local_width/2, "%ld %ld", lft_length_width[0], lft_length_width[1]);
|
||||
print_dir(win, lft_length_width, lft_file_name_width, 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 {
|
||||
mvwprintw(win, local_height/2, local_width/2, "%ld %ld", mid_length_width[0], mid_length_width[1]);
|
||||
print_dir(win, mid_length_width, mid_file_name_width, mid_content);
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
}
|
||||
}
|
||||
void window_rgt(WINDOW *win){
|
||||
werase(win);
|
||||
box(win, 0, 0);
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_rgt)) {
|
||||
} else {
|
||||
pthread_mutex_unlock(&mutex_rgt);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user