diff options
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 63 |
1 files changed, 35 insertions, 28 deletions
@@ -63,37 +63,44 @@ int main(int argc, char **argv) timeout(100); while (1) { - if (info->need_redraw) { - fm_draw_entries(info->windows[FM_PANE_LEFT], info->cur, - info->cursor, info->top, info->bottom); - - if (!info->cur->items[info->cursor].is_dir) { - snprintf(next_path, sizeof(next_path), "%s/%s", - info->cwd, - info->cur->items[info->cursor].name); - fm_preview_file(info->windows[FM_PANE_RIGHT], - next_path); - } else { - snprintf(next_path, sizeof(next_path), "%s/%s", - info->cwd, - info->cur->items[info->cursor].name); - file_list *new_list = info->next; - new_list = fm_getdir(new_list, next_path); - if (new_list) { - info->next = new_list; - int right_height = - info->windows[FM_PANE_RIGHT] - ->height; - fm_draw_entries( - info->windows[FM_PANE_RIGHT], - info->next, -1, 0, right_height); - } + if (!info->need_redraw) + continue; + + fm_draw_entries(info->windows[FM_PANE_LEFT], info->cur, + info->cursor, info->top, info->bottom); + + if (!info->cur->items[info->cursor].is_dir) { + size_t len = snprintf( + next_path, sizeof(next_path), "%s/%s", info->cwd, + info->cur->items[info->cursor].name); + if (len >= sizeof(next_path)) { + die("Length of items error"); + } + fm_preview_file(info->windows[FM_PANE_RIGHT], + next_path); + } else { + size_t len = snprintf( + next_path, sizeof(next_path), "%s/%s", info->cwd, + info->cur->items[info->cursor].name); + + if (len >= sizeof(next_path)) { + die("Length of items error"); + } + file_list *new_list = info->next; + new_list = fm_getdir(new_list, next_path); + if (new_list) { + info->next = new_list; + int right_height = + info->windows[FM_PANE_RIGHT]->height; + fm_draw_entries(info->windows[FM_PANE_RIGHT], + info->next, -1, 0, + right_height); } - - wrefresh(info->windows[FM_PANE_RIGHT]->win); - wrefresh(info->windows[FM_PANE_LEFT]->win); } + wrefresh(info->windows[FM_PANE_RIGHT]->win); + wrefresh(info->windows[FM_PANE_LEFT]->win); + ch = getch(); handling_keys(ch, info); } |
