removal of top_buffer

This commit is contained in:
nova
2026-07-13 18:03:00 +02:00
parent 56d2f9d5d0
commit 24fe4a4aa4
+18 -34
View File
@@ -31,7 +31,6 @@ dir mid_dir;
dir lft_dir; dir lft_dir;
char *rgt_buffer; /* used for file previews, unlike rgt_content, which is used for directory previews */ char *rgt_buffer; /* used for file previews, unlike rgt_content, which is used for directory previews */
char *btm_buffer; char *btm_buffer;
char *top_buffer; /* current path */
extern WINDOW *win_t; extern WINDOW *win_t;
extern WINDOW *win_b; extern WINDOW *win_b;
@@ -289,34 +288,20 @@ void *thread_top(){
pthread_cond_wait(&cond_top, &mutex_top); pthread_cond_wait(&cond_top, &mutex_top);
free(top_buffer);
if(global_path == NULL) {
top_buffer = malloc(sizeof("cannot open directory"));
top_width = sizeof("cannot open directory");
top_buffer = "cannot open directory";
pthread_mutex_unlock(&mutex_top);
continue;
}
pthread_mutex_lock(&mutex_mid); pthread_mutex_lock(&mutex_mid);
if(global_path == NULL) {
if (mid_dir.current_file != NULL) { mvwaddstr(win_t, 0, 0, "cannot open directory");
top_buffer = malloc(strlen(global_path)+1 + strlen(mid_dir.current_file->file_name)+1); pthread_mutex_unlock(&mutex_top);
memcpy(top_buffer, global_path, strlen(global_path)); pthread_mutex_unlock(&mutex_mid);
if (strlen(global_path) != 1) { continue;
memcpy(top_buffer + strlen(global_path) + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1); } else if (mid_dir.current_file == NULL) {
top_buffer[strlen(global_path)] = '/'; mvwaddstr(win_t, 0, 0, "cannot open file");
} else { /* dir '/' */ pthread_mutex_unlock(&mutex_top);
memcpy(top_buffer + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1); pthread_mutex_unlock(&mutex_mid);
} continue;
top_width = strlen(top_buffer);
} else {
top_buffer = malloc(strlen(global_path)+1);
memcpy(top_buffer, global_path, strlen(global_path)+1);
} }
pthread_mutex_unlock(&mutex_mid);
/* rendering */ /* rendering */
@@ -324,20 +309,21 @@ void *thread_top(){
werase(win_t); werase(win_t);
if (strlen(global_path) != 1) { if (strlen(global_path) != 1) {
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); mvwaddnstr(win_t, 0, 0, global_path, strlen(global_path)+1);
mvwaddch(win_t, 0, strlen(global_path), '/');
wattroff(win_t, COLOR_PAIR(COLOR_PATH)); wattroff(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1); mvwaddstr(win_t, 0, strlen(global_path)+1, mid_dir.current_file->file_name);
} else { /* dir '/' */ } else { /* dir '/' */
wattron(win_t, COLOR_PAIR(COLOR_PATH)); wattron(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddnstr(win_t, 0, 0, top_buffer, 1); mvwaddnstr(win_t, 0, 0, global_path, 1);
wattroff(win_t, COLOR_PAIR(COLOR_PATH)); wattroff(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddstr(win_t, 0, 1, top_buffer+1); mvwaddstr(win_t, 0, 1, mid_dir.current_file->file_name);
} }
/*wnoutrefresh(win_t);*/ /*wnoutrefresh(win_t);*/
wrefresh(win_t); wrefresh(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);
} }
pthread_exit(0); pthread_exit(0);
@@ -476,7 +462,6 @@ void *thread_btm(){
void threading_init(){ void threading_init(){
top_buffer = NULL;
rgt_buffer = NULL; rgt_buffer = NULL;
btm_buffer = NULL; btm_buffer = NULL;
@@ -494,7 +479,6 @@ void threading_init(){
} }
void threading_free(){ void threading_free(){
free(top_buffer);
pthread_mutex_destroy(&mutex_top); pthread_mutex_destroy(&mutex_top);
pthread_mutex_destroy(&mutex_mid); pthread_mutex_destroy(&mutex_mid);