mirror of
https://gittea.dev/nova/th.git
synced 2025-12-11 02:00:10 -05:00
varrious small changes
This commit is contained in:
40
main.c
40
main.c
@@ -7,6 +7,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "config.h"
|
||||
#include "threading.h"
|
||||
#include "window.c"
|
||||
#include "colors.h"
|
||||
@@ -58,7 +59,6 @@ int main(){
|
||||
pthread_t thread_m;
|
||||
pthread_t thread_r;
|
||||
|
||||
char threading = 0;
|
||||
terminal_width_empty_line = malloc(terminal_width);
|
||||
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
||||
time_t t;
|
||||
@@ -71,7 +71,17 @@ int main(){
|
||||
pthread_create(&thread_m, NULL, thread_mid, &status); /*current_content slash win_m*/
|
||||
pthread_create(&thread_r, NULL, thread_rgt, &status); /*child_content slash win_r*/
|
||||
pthread_create(&thread_b, NULL, thread_btm, &status); /*bottom bar*/
|
||||
|
||||
|
||||
|
||||
/* running through all once manually in order to get an as fast as possible first render on the screen */
|
||||
pthread_cond_signal(&cond_top);
|
||||
pthread_cond_signal(&cond_mid);
|
||||
pthread_cond_signal(&cond_lft);
|
||||
user_interactions();
|
||||
render_pass();
|
||||
timeout(SETTINGS_CURSES_TIMEOUT);
|
||||
|
||||
|
||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||
getmaxyx(stdscr, terminal_height, terminal_width);
|
||||
|
||||
@@ -80,21 +90,17 @@ int main(){
|
||||
temp_width = terminal_width;
|
||||
temp_heigth = terminal_height;
|
||||
}
|
||||
if (threading) {
|
||||
status &= ~(STATUS_RELOAD_DIRECTORY | STATUS_DELTA_TIME);
|
||||
threading = 0;
|
||||
}
|
||||
if (status & STATUS_RUN_BACKEND) {
|
||||
pthread_cond_signal(&cond_top);
|
||||
pthread_cond_signal(&cond_mid);
|
||||
pthread_cond_signal(&cond_lft);
|
||||
status &= ~(STATUS_RUN_BACKEND);
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
threading = 1;
|
||||
} else {
|
||||
status &= ~(STATUS_RELOAD_DIRECTORY | STATUS_DELTA_TIME);
|
||||
}
|
||||
user_interactions();
|
||||
|
||||
|
||||
render_pass();
|
||||
|
||||
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
||||
@@ -112,16 +118,6 @@ int main(){
|
||||
threading_free();
|
||||
free(start_path);
|
||||
|
||||
/*
|
||||
if (threading) {
|
||||
pthread_join(thread_l, NULL);
|
||||
pthread_join(thread_r, NULL);
|
||||
pthread_join(thread_m, NULL);
|
||||
pthread_join(thread_t, NULL);
|
||||
pthread_join(thread_b, NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
delwin(win_l);
|
||||
delwin(win_m);
|
||||
delwin(win_r);
|
||||
@@ -143,9 +139,6 @@ void render_pass(){
|
||||
status &= ~STATUS_UPDATE_SCREEN_RELOAD_FULL;
|
||||
}
|
||||
|
||||
/*TODO: check if deallocation of window and reallocation is faster than this or not */
|
||||
|
||||
|
||||
wresize(win_t, 1, terminal_width);
|
||||
wresize(win_l, terminal_height-2, terminal_width/8);
|
||||
wresize(win_m, terminal_height-2, (terminal_width/2)-(terminal_width/8));
|
||||
@@ -183,7 +176,10 @@ void init() {
|
||||
setlocale(LC_ALL, "");
|
||||
initscr(); /* start ncurses */
|
||||
noecho(); /* hide keyboard input */
|
||||
timeout(0); /* blocking timeout of getch() */
|
||||
timeout(10); /* blocking timeout of getch(), using 10 rather than SETTINGS_CURSES_TIMEOUT to cause a faster first render
|
||||
regardless on SETTINGS_CURSES_TIMEOUT, 10 was taken arbitrary.
|
||||
if the blocking is too low, the first render happens delayed, however even this delay causes a quicker than
|
||||
(compute time of threads) + timeout */
|
||||
curs_set(0);
|
||||
|
||||
/*file_modifiers = (FILE_MODIFIERS_HIDDEN_FILES | FILE_MODIFIERS_SORT_BITMASK);*/
|
||||
|
||||
Reference in New Issue
Block a user