diff --git a/dir.c b/dir.c index 56b2235..8c01940 100644 --- a/dir.c +++ b/dir.c @@ -313,18 +313,23 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file free(bg); } -void update_selected_file(){ +char update_selected_file(){ + char ret = -1; /* -1 on empty or inaccessible file, 0 on unchanged file, 1 on changed file */ if (mid_content->file_name[0] == '\0') { /* only happens if the current path is either empty or inaccessible */ - return; + return ret; } if (selected_file_current >= mid_file_count) { selected_file_current = mid_file_count-1; } if (selected_file_current != selected_file_last) { mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER; + ret = 1; + } else { + ret = 0; } mid_content[selected_file_current].status |= FILE_STATUS_HOVER; selected_file_last = selected_file_current; + return ret; } void dir_set_selected_file_current(unsigned long selected_file_current){ if (mid_content->file_name[0] != '\0') { diff --git a/dir.h b/dir.h index 023b329..17e35ce 100644 --- a/dir.h +++ b/dir.h @@ -6,7 +6,7 @@ unsigned long get_dir_size(char *path); void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_content); void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file *dir_content); -void update_selected_file(); +char update_selected_file(); void dir_set_selected_file_current(unsigned long selected_file_current); unsigned long dir_get_selected_file_current(); void dir_init(); diff --git a/interactions.c b/interactions.c index 18fc5ad..6842233 100644 --- a/interactions.c +++ b/interactions.c @@ -17,6 +17,7 @@ extern unsigned int file_modifiers; extern pthread_mutex_t mutex_selection; extern pthread_mutex_t mutex_rgt; extern pthread_mutex_t mutex_mid; +extern pthread_cond_t cond_rgt; extern file *mid_content; extern file *lft_content; extern file *rgt_content; @@ -807,11 +808,13 @@ void search(){ for (i = 0; i < mid_file_count; i++) { if (smartstrcasestr(mid_content[i].file_name, search_buffer)) { selected_file_current = i; - update_selected_file(); + if (update_selected_file()) { + pthread_cond_signal(&cond_rgt); + } status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0); - render_pass(); break; } + render_pass(); } } }