Compare commits
3 Commits
f5d0c8bc85
...
c692a1a992
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c692a1a992 | ||
|
|
8c80a6e3da | ||
|
|
1aa66c82fb |
12
main.c
12
main.c
@@ -21,7 +21,6 @@ unsigned int temp_width = 0;
|
|||||||
unsigned int settings;
|
unsigned int settings;
|
||||||
unsigned int file_modifiers = 0;
|
unsigned int file_modifiers = 0;
|
||||||
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY) & ~STATUS_UPDATE_SCREEN_RESIZE;
|
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY) & ~STATUS_UPDATE_SCREEN_RESIZE;
|
||||||
char *start_path;
|
|
||||||
char *global_path;
|
char *global_path;
|
||||||
time_t seed;
|
time_t seed;
|
||||||
|
|
||||||
@@ -38,7 +37,6 @@ extern pthread_mutex_t mutex_mid;
|
|||||||
extern pthread_mutex_t mutex_rgt;
|
extern pthread_mutex_t mutex_rgt;
|
||||||
|
|
||||||
char *input; /*used in user_interactions*/
|
char *input; /*used in user_interactions*/
|
||||||
char *terminal_width_empty_line; /* used in user_interactions */
|
|
||||||
|
|
||||||
void render_pass();
|
void render_pass();
|
||||||
void init();
|
void init();
|
||||||
@@ -65,7 +63,6 @@ int main(){
|
|||||||
pthread_t thread_m;
|
pthread_t thread_m;
|
||||||
pthread_t thread_r;
|
pthread_t thread_r;
|
||||||
|
|
||||||
terminal_width_empty_line = malloc(terminal_width);
|
|
||||||
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
||||||
time_t t;
|
time_t t;
|
||||||
time_t dt;
|
time_t dt;
|
||||||
@@ -78,18 +75,12 @@ int main(){
|
|||||||
pthread_create(&thread_r, NULL, thread_rgt, &status); /*child_content slash win_r*/
|
pthread_create(&thread_r, NULL, thread_rgt, &status); /*child_content slash win_r*/
|
||||||
pthread_create(&thread_b, NULL, thread_btm, &status); /*bottom bar*/
|
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_mid);
|
|
||||||
pthread_cond_signal(&cond_lft);
|
|
||||||
render_pass();
|
|
||||||
timeout(SETTINGS_CURSES_TIMEOUT);
|
timeout(SETTINGS_CURSES_TIMEOUT);
|
||||||
|
|
||||||
|
|
||||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||||
getmaxyx(stdscr, terminal_height, terminal_width);
|
getmaxyx(stdscr, terminal_height, terminal_width);
|
||||||
|
|
||||||
user_interactions();
|
|
||||||
if (status & STATUS_RUN_BACKEND) {
|
if (status & STATUS_RUN_BACKEND) {
|
||||||
free(global_path);
|
free(global_path);
|
||||||
global_path = getcwd(NULL, 0);
|
global_path = getcwd(NULL, 0);
|
||||||
@@ -106,6 +97,7 @@ int main(){
|
|||||||
temp_width = terminal_width;
|
temp_width = terminal_width;
|
||||||
temp_heigth = terminal_height;
|
temp_heigth = terminal_height;
|
||||||
}
|
}
|
||||||
|
user_interactions();
|
||||||
render_pass();
|
render_pass();
|
||||||
|
|
||||||
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
||||||
@@ -121,7 +113,6 @@ int main(){
|
|||||||
ueberzug_close();
|
ueberzug_close();
|
||||||
#endif
|
#endif
|
||||||
threading_free();
|
threading_free();
|
||||||
free(start_path);
|
|
||||||
|
|
||||||
delwin(win_l);
|
delwin(win_l);
|
||||||
delwin(win_m);
|
delwin(win_m);
|
||||||
@@ -179,7 +170,6 @@ void init() {
|
|||||||
/*file_modifiers = (FILE_MODIFIERS_HIDDEN_FILES | FILE_MODIFIERS_SORT_BITMASK);*/
|
/*file_modifiers = (FILE_MODIFIERS_HIDDEN_FILES | FILE_MODIFIERS_SORT_BITMASK);*/
|
||||||
input = malloc(INPUT_BUFFER_SIZE); /* size of input buffer, out of bounds access will not be accounted for */
|
input = malloc(INPUT_BUFFER_SIZE); /* size of input buffer, out of bounds access will not be accounted for */
|
||||||
memset(input, 0, INPUT_BUFFER_SIZE);
|
memset(input, 0, INPUT_BUFFER_SIZE);
|
||||||
status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
|
||||||
if (getuid() == 0) {
|
if (getuid() == 0) {
|
||||||
status |= STATUS_USER_ROOT;
|
status |= STATUS_USER_ROOT;
|
||||||
}
|
}
|
||||||
|
|||||||
30
threading.c
30
threading.c
@@ -65,6 +65,7 @@ void *thread_mid(){
|
|||||||
if (global_path == NULL) {
|
if (global_path == NULL) {
|
||||||
mid_dir.current_file = NULL;
|
mid_dir.current_file = NULL;
|
||||||
mid_dir.file_count = 0;
|
mid_dir.file_count = 0;
|
||||||
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
char *path = malloc(strlen(global_path)+1);
|
char *path = malloc(strlen(global_path)+1);
|
||||||
@@ -214,7 +215,6 @@ void *thread_rgt(){
|
|||||||
|
|
||||||
pthread_mutex_unlock(&mutex_mid);
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
|
||||||
werase(win_r);
|
|
||||||
if (rgt_dir.current_file->permissions & S_IRUSR) {
|
if (rgt_dir.current_file->permissions & S_IRUSR) {
|
||||||
if (rgt_dir.current_file->file_type &= FILE_TYPE_DIR) {
|
if (rgt_dir.current_file->file_type &= FILE_TYPE_DIR) {
|
||||||
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||||
@@ -231,6 +231,7 @@ void *thread_rgt(){
|
|||||||
rgt_dir.current_file = NULL;
|
rgt_dir.current_file = NULL;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&mutex_render);
|
pthread_mutex_lock(&mutex_render);
|
||||||
|
werase(win_r);
|
||||||
print_dir(win_r, 0, &rgt_dir);
|
print_dir(win_r, 0, &rgt_dir);
|
||||||
wnoutrefresh(win_r);
|
wnoutrefresh(win_r);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
@@ -241,6 +242,7 @@ void *thread_rgt(){
|
|||||||
rgt_buffer = preview_file(rgt_dir.current_file);
|
rgt_buffer = preview_file(rgt_dir.current_file);
|
||||||
rgt_dir.current_file->file_type |= FILE_TYPE_OPEN_FILE;
|
rgt_dir.current_file->file_type |= FILE_TYPE_OPEN_FILE;
|
||||||
pthread_mutex_lock(&mutex_render);
|
pthread_mutex_lock(&mutex_render);
|
||||||
|
werase(win_r);
|
||||||
if (rgt_dir.current_file->file_type == FILE_TYPE_OPEN_FILE) {
|
if (rgt_dir.current_file->file_type == FILE_TYPE_OPEN_FILE) {
|
||||||
mvwaddnstr(win_r, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
mvwaddnstr(win_r, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
||||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||||
@@ -281,27 +283,27 @@ void *thread_top(){
|
|||||||
pthread_mutex_unlock(&mutex_top);
|
pthread_mutex_unlock(&mutex_top);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
top_buffer = malloc(strlen(global_path)+1);
|
|
||||||
memcpy(top_buffer, global_path, strlen(global_path)+1);
|
pthread_mutex_lock(&mutex_mid);
|
||||||
|
|
||||||
|
top_buffer = malloc(strlen(global_path)+1 + strlen(mid_dir.current_file->file_name)+1);
|
||||||
|
memcpy(top_buffer, global_path, strlen(global_path));
|
||||||
|
memcpy(top_buffer + strlen(global_path) + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
top_buffer[strlen(global_path)] = '/';
|
||||||
top_width = strlen(top_buffer);
|
top_width = strlen(top_buffer);
|
||||||
|
|
||||||
|
|
||||||
/* rendering */
|
/* rendering */
|
||||||
pthread_mutex_lock(&mutex_mid);
|
|
||||||
pthread_mutex_lock(&mutex_render);
|
pthread_mutex_lock(&mutex_render);
|
||||||
werase(win_t);
|
werase(win_t);
|
||||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
||||||
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
|
||||||
mvwaddstr(win_t, 0, 0, top_buffer);
|
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||||
mvwaddch(win_t, 0, strlen(top_buffer), '/');
|
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1);
|
||||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
|
||||||
if (mid_dir.file_count != 0 && !(mid_dir.current_file == NULL)) {
|
|
||||||
mvwaddstr(win_t, 0, strlen(top_buffer)+1, mid_dir.current_file->file_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wnoutrefresh(win_t);
|
wnoutrefresh(win_t);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
pthread_mutex_unlock(&mutex_mid);
|
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex_top);
|
pthread_mutex_unlock(&mutex_top);
|
||||||
|
|||||||
Reference in New Issue
Block a user