1
0
mirror of https://gittea.dev/nova/th.git synced 2025-10-21 18:30:15 -04:00

handling of empty dirs

This commit is contained in:
nova
2025-08-24 19:45:08 +02:00
parent ba1e95bca3
commit 4a9c38d034
5 changed files with 65 additions and 40 deletions

11
dir.c
View File

@@ -314,6 +314,9 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
}
void update_selected_file(){
if (mid_content->file_name[0] == '\0') { /* only happens if the current path is either empty or inaccessible */
return;
}
if (selected_file_current >= mid_file_count) {
selected_file_current = mid_file_count-1;
}
@@ -324,11 +327,17 @@ void update_selected_file(){
selected_file_last = selected_file_current;
}
void dir_set_selected_file_current(unsigned long selected_file_current){
current_dir->selected_file_current = selected_file_current;
if (mid_content->file_name[0] != '\0') {
current_dir->selected_file_current = selected_file_current;
}
}
unsigned long dir_get_selected_file_current(){
current_dir = visited_dirs;
if (mid_content->file_name[0] == '\0') {
return 0;
}
char hit = 0;
char *path = getcwd(NULL, 0);
while(current_dir->next != NULL) {