diff --git a/dir.c b/dir.c index a6286ee..bc7510e 100644 --- a/dir.c +++ b/dir.c @@ -327,7 +327,7 @@ char update_selected_file(){ if (selected_file_current >= mid_file_count) { selected_file_current = mid_file_count-1; } - if (selected_file_current != selected_file_last) { + if (selected_file_current != selected_file_last && selected_file_last <= mid_file_count) { mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER; ret = 1; } else { diff --git a/interactions.c b/interactions.c index 53317cf..5c154b6 100644 --- a/interactions.c +++ b/interactions.c @@ -417,41 +417,21 @@ void delete(){ werase(win_b); mvwin(win_b, terminal_height-6, 0); - if (strlen(file_str) < (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION-1) * (terminal_width/3)) { - wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/ - btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)); - memset(btm_buffer, ' ', (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3))); + wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width); + btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width); + memset(btm_buffer, ' ', BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width); - memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text)); - if (hits) { - memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str, strlen(file_str)); - } else { - btm_buffer[strlen(ui_delete_text)+1] = '"'; - memcpy(btm_buffer + strlen(ui_delete_text) +1 + sizeof(char), mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name)); - btm_buffer[strlen(ui_delete_text)+1 + sizeof(char) + strlen(mid_content[selected_file_current].file_name)] = '"'; - } + memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text)); - memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3) - (terminal_width/3)) , "(y/N)", strlen("(y/N)")); - btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)] = '\0'; + /*this horrendous check tries to copy everything until the last line, while keeping said last line unwritten*/ + /*lets hope im never gonna need to format something like this ever again*/ + memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str, + (strlen(file_str) > ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) ? + ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) : + strlen(file_str))); - } else { - /*since more data is present than can be represented using div3, we do the uncool thing*/ - wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width); - btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width); - memset(btm_buffer, ' ', BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width); - - memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text)); - - /*this horrendous check tries to copy everything until the last line, while keeping said last line unwritten*/ - /*lets hope im never gonna need to format something like this ever again*/ - memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str, - (strlen(file_str) > ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) ? - ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) : - strlen(file_str))); - - memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width - terminal_width) , "(y/N)", strlen("(y/N)")); - btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width] = '\0'; - } + memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width - terminal_width) , "(y/N)", strlen("(y/N)")); + btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width-1] = '\0';