th/main.c

57 lines
1.6 KiB
C

#include <curses.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include "window.h"
unsigned int terminal_height;
unsigned int terminal_width;
unsigned int settings;
unsigned long file_count;
unsigned long longest_name;
char **content_l; //content of parent dir, used in left window
char **content_m; //content of current dir, used in main window
char **content_r; //content of child dir, used in right window
char *path = ".";
int main() {
initscr(); //start ncurses
unsigned int ch;
getmaxyx(stdscr, terminal_height, terminal_width);
WINDOW *winl = newwin(terminal_height, terminal_width/3, terminal_height, (terminal_width/3));
WINDOW *winm = newwin(terminal_height, terminal_width/3, 0, 0);
WINDOW *winr = newwin(terminal_height, terminal_width/3, terminal_height, ((terminal_width/3)*2));
settings = 1; //bit 0 = show_hidden_files
while((ch = wgetch(winm)) != 'q'){
getmaxyx(stdscr, terminal_height, terminal_width);
pthread_t populate_l;
pthread_t populate_m;
pthread_t populate_r;
pthread_create(&populate_l, NULL, populate_dir, (void*)0); //parent_content slash win_l
pthread_create(&populate_m, NULL, populate_dir, (void*)1); //current_content slash win_m
pthread_create(&populate_r, NULL, populate_dir, (void*)2); //child_content slash win_r
pthread_join(populate_l, NULL);
pthread_join(populate_m, NULL);
pthread_join(populate_r, NULL);
window_left(winl, 0, 0, content_l);
window_main(winm, 0, terminal_width/3, content_m);
window_right(winr, 0, (terminal_width/3)*2, content_r);
wmove(stdscr,0,0);
free(content_l);
free(content_m);
free(content_r);
}
endwin();
return 0;
}