From f3a39b0df075da4cd4c2f4e2df319e1876267740 Mon Sep 17 00:00:00 2001 From: nova Date: Sat, 17 Jan 2026 17:53:52 +0100 Subject: [PATCH] small changes --- config.h | 2 +- dir.c | 3 ++- interactions.c | 16 +++++++++------- threading.c | 16 ++++------------ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/config.h b/config.h index ee1925b..f882d55 100644 --- a/config.h +++ b/config.h @@ -39,7 +39,7 @@ static const extension file_extension_default_cmd[] = { { ".csv", "$EDITOR"}, }; static const binding key_binding[] = { - /*key action blackmagic comment*/ + /*key action blackmagic comment*/ /*you cannot add bindings that include other bindings in its entirety * possible: mk, mf * not possible: gg, ggg diff --git a/dir.c b/dir.c index fa84512..a6286ee 100644 --- a/dir.c +++ b/dir.c @@ -254,7 +254,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file file_name[printable_size + strlen(extension)-1] = '\0'; file_name[printable_size - 2] = '~'; } else { - file_name = malloc(printable_size-1); + file_name = malloc(printable_size); memcpy(file_name, dir_content[i].file_name, printable_size); file_name[printable_size-2] = '~'; file_name[printable_size-1] = '\0'; @@ -323,6 +323,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file char update_selected_file(){ char ret = -1; /* -1 on empty or inaccessible file, 0 on unchanged file, 1 on changed file */ + if (selected_file_current >= mid_file_count) { selected_file_current = mid_file_count-1; } diff --git a/interactions.c b/interactions.c index be0b966..53317cf 100644 --- a/interactions.c +++ b/interactions.c @@ -201,7 +201,7 @@ void move_up(unsigned long passes){ current_dir->selected_file_current = selected_file_current; - status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK); + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0); pthread_mutex_unlock(&mutex_selection); } void move_left(unsigned long passes){ @@ -217,7 +217,9 @@ void move_left(unsigned long passes){ selected_file_current = dir_get_selected_file_current(); } } - status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY); + update_selected_file(); + current_dir->selected_file_current = selected_file_current; + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY); } void move_right(){ if (mid_content->file_name[0] == '\0') { @@ -248,7 +250,7 @@ void move_right(){ } curs_set(1); /*for some reason, 1 here turns it invisible once again */ match = 1; - status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY); break; } } @@ -262,7 +264,7 @@ void move_right(){ /*do nothing*/ } curs_set(1); /*for some reason, 1 here turns it invisible once again */ - status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY); break; } @@ -271,11 +273,11 @@ void move_right(){ free(mime); } update_selected_file(); - status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY); + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY); } void toggle_hidden_files(){ file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES; - status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY); + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY); } void toggle_selection(){ pthread_mutex_lock(&mutex_selection); @@ -291,7 +293,7 @@ void jump_bottom(){ selected_file_current = 0 - 1; update_selected_file(); current_dir->selected_file_current = selected_file_current; - status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK); + status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0); pthread_mutex_unlock(&mutex_selection); } void jump_top(){ diff --git a/threading.c b/threading.c index 89b0b9c..acd8ee7 100644 --- a/threading.c +++ b/threading.c @@ -93,9 +93,7 @@ void *thread_mid(){ mid_file_count = 0; } - pthread_mutex_lock(&mutex_selection); update_selected_file(); - pthread_mutex_unlock(&mutex_selection); } btm_status = local_status; @@ -157,18 +155,11 @@ void *thread_rgt(){ pthread_mutex_lock(&mutex_mid); - char *path; - if (mid_file_count != 0) { - path = malloc(strlen(mid_content[selected_file_current].file_name) + 1); - memcpy(path, mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name)+1); - } else { - path = malloc(sizeof(char)); - path[0] = '\0'; - } + char *path = mid_content[selected_file_current].file_name; memcpy(&file_current, &mid_content[selected_file_current], sizeof(file)); pthread_mutex_unlock(&mutex_mid); - if (mid_content[selected_file_current].permissions & S_IRUSR) { + if (file_current.permissions & S_IRUSR) { if (file_current.file_type &= FILE_TYPE_DIR) { #if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0 images_clear(); @@ -229,8 +220,9 @@ void *thread_rgt(){ rgt_buffer = malloc(sizeof(char)); rgt_buffer[0] = '\0'; } - + /* free(path); + */ pthread_mutex_unlock(&mutex_rgt); }