init function
This commit is contained in:
parent
6e06b56a23
commit
3269ced286
37
main.c
37
main.c
@ -2,6 +2,7 @@
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include "window.h"
|
||||
#include "interactions.h"
|
||||
#include "defines.h"
|
||||
@ -13,10 +14,15 @@ unsigned int temp_width = 0;
|
||||
unsigned int settings;
|
||||
unsigned int file_modifiers;
|
||||
unsigned int status; //bit 0 = enable
|
||||
unsigned short cpu_cores; //amount of cores/threads the host system reports to have
|
||||
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 = ".";
|
||||
char input = 0;
|
||||
|
||||
|
||||
void init();
|
||||
|
||||
|
||||
int main() {
|
||||
@ -24,17 +30,12 @@ int main() {
|
||||
timeout(50); //blocking timeout of getch()
|
||||
keypad(stdscr, TRUE);
|
||||
|
||||
init();
|
||||
|
||||
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));
|
||||
file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES;
|
||||
status ^= STATUS_RUN_BACKEND;
|
||||
char input = 0;
|
||||
|
||||
content_l = calloc(1, sizeof(*content_l)); //allocation in order to allow a more streamlined backend
|
||||
content_m = calloc(1, sizeof(*content_m));
|
||||
content_r = calloc(1, sizeof(*content_r));
|
||||
|
||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||
getmaxyx(stdscr, temp_heigth, temp_width);
|
||||
@ -51,19 +52,22 @@ int main() {
|
||||
pthread_join(populate_l, NULL);
|
||||
pthread_join(populate_m, NULL);
|
||||
pthread_join(populate_r, NULL);
|
||||
status ^= STATUS_UPDATE_SCREEN_0;
|
||||
}
|
||||
|
||||
|
||||
getmaxyx(stdscr, terminal_height, terminal_width);
|
||||
temp_heigth -= terminal_height;
|
||||
temp_width -= terminal_width;
|
||||
if (!temp_heigth || !temp_width || (status & STATUS_RUN_BACKEND)) { //updates screen
|
||||
if (!temp_heigth || !temp_width || (status & STATUS_UPDATE_SCREEN_MASK)) { //updates screen
|
||||
if (status & STATUS_UPDATE_SCREEN_0) {
|
||||
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);
|
||||
}
|
||||
|
||||
status ^= STATUS_RUN_BACKEND;
|
||||
wmove(stdscr,0,0);
|
||||
status &= ~STATUS_UPDATE_SCREEN_MASK;
|
||||
}
|
||||
|
||||
|
||||
@ -79,3 +83,16 @@ int main() {
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//this function exists for things done at startup (initialization, reading config, etc)
|
||||
void init() {
|
||||
|
||||
cpu_cores = get_nprocs();
|
||||
file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES;
|
||||
status ^= STATUS_RUN_BACKEND;
|
||||
|
||||
content_l = calloc(1, sizeof(*content_l)); //allocation in order to allow a more streamlined backend
|
||||
content_m = calloc(1, sizeof(*content_m));
|
||||
content_r = calloc(1, sizeof(*content_r));
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user