now accounting for root dir

This commit is contained in:
nova
2026-07-12 23:03:13 +02:00
parent a55c38abfa
commit 56d2f9d5d0
+17 -6
View File
@@ -304,9 +304,13 @@ void *thread_top(){
if (mid_dir.current_file != NULL) {
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);
if (strlen(global_path) != 1) {
memcpy(top_buffer + strlen(global_path) + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
top_buffer[strlen(global_path)] = '/';
} else { /* dir '/' */
memcpy(top_buffer + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
}
top_buffer[strlen(global_path)] = '/';
top_width = strlen(top_buffer);
} else {
top_buffer = malloc(strlen(global_path)+1);
@@ -318,10 +322,17 @@ void *thread_top(){
/* rendering */
pthread_mutex_lock(&mutex_render);
werase(win_t);
wattron(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1);
if (strlen(global_path) != 1) {
wattron(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1);
} else { /* dir '/' */
wattron(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddnstr(win_t, 0, 0, top_buffer, 1);
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
mvwaddstr(win_t, 0, 1, top_buffer+1);
}
/*wnoutrefresh(win_t);*/
wrefresh(win_t);
pthread_mutex_unlock(&mutex_render);