diff --git a/dir.c b/dir.c index 62f1873..e6675f3 100644 --- a/dir.c +++ b/dir.c @@ -148,10 +148,6 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file /* i am not proud of this function */ unsigned long line_width = getmaxx(win); - char *bg = malloc(line_width+1); - memset(bg, ' ', line_width); - bg[line_width] = '\0'; - unsigned long i = 0; float file_size; float printed_size = 0; @@ -226,12 +222,17 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file } if (dir_content[i].status & FILE_STATUS_HOVER) { wattron(win, A_REVERSE); + unsigned long bg = 0; + for (bg = 0; bg < line_width; bg++) { + mvwaddch(win, i-offset_vertical, bg, ' '); + } + } else { wattroff(win, A_REVERSE); } + - mvwaddstr(win, i-offset_vertical, 0, bg); if(print_info) { #if SETTINGS_LINE_NUMBERS == 2 long i_ = (selected_file_current) - i; @@ -274,7 +275,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file } char *extension = strrchr(dir_content[i].file_name, '.'); - size_t printable_size = offset_back-offset_front-is_selected-2; + unsigned long printable_size = offset_back-offset_front-is_selected-2; mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, dir_content[i].file_name, printable_size); if (extension && printable_size <= strlen(dir_content[i].file_name)) { @@ -288,10 +289,8 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file } else { wattroff(win, COLOR_PAIR(dir_content[i].color_pair)); } - /*free(file_name);*/ } - free(bg); } char update_selected_file(){