base layout for multithreading
This commit is contained in:
42
main.c
42
main.c
@ -1,29 +1,51 @@
|
||||
#include <curses.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "window.h"
|
||||
|
||||
unsigned int terminal_height;
|
||||
unsigned int terminal_width;
|
||||
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 *win_m = newwin(terminal_height, terminal_width/3, 0, 0);
|
||||
WINDOW *win_l = newwin(terminal_height, terminal_width/3, terminal_height, (terminal_width/3));
|
||||
WINDOW *win_r = newwin(terminal_height, terminal_width/3, terminal_height, ((terminal_width/3)*2));
|
||||
while((ch = wgetch(win_m)) != 'q'){
|
||||
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));
|
||||
|
||||
|
||||
while((ch = wgetch(winm)) != 'q'){
|
||||
getmaxyx(stdscr, terminal_height, terminal_width);
|
||||
|
||||
pthread_t main_window_thread;
|
||||
pthread_t left_window_thread;
|
||||
pthread_t right_window_thread;
|
||||
window_left(win_l,0,0);
|
||||
window_main(win_m,0,(terminal_width/3));
|
||||
window_right(win_r,0,((terminal_width/3)*2));
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user