diff --git a/threading.c b/threading.c index 176a81d..0d22f9e 100644 --- a/threading.c +++ b/threading.c @@ -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);