diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 67 |
1 files changed, 31 insertions, 36 deletions
@@ -19,6 +19,7 @@ #include "keys.h" #include "log.h" #include "mem.h" +#include "utils.h" #include "version.h" #include "wm.h" @@ -68,43 +69,37 @@ main(int argc, char **argv) char next_path[PATH_MAX]; refresh(); while (1) { - if (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) { - 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"); - } - - fm_preview_dir(info, next_path); - } - - draw_status_bar( - term->windows[stat_bar_win_index], info->cwd, - info->cur->items[info->cursor].permission); - - wrefresh(info->windows[FM_PANE_RIGHT]->win); - wrefresh(info->windows[FM_PANE_LEFT]->win); - wrefresh(term->windows[stat_bar_win_index]->win); + if (!need_redraw) { + ch = getch(); + handling_keys(ch, info); } - ch = getch(); - handling_keys(ch, info); + + fm_draw_entries(info->windows[FM_PANE_LEFT], info->cur, + info->cursor, info->top, info->bottom); + + if (info->cur->items[info->cursor].is_dir) { + xsnprintf(next_path, sizeof(next_path), "%s/%s", + info->cwd, + info->cur->items[info->cursor].name); + + fm_preview_dir(info, next_path); + + } else { + xsnprintf(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); + } + + draw_status_bar(term->windows[stat_bar_win_index], info->cwd, + info->cur->items[info->cursor].permission); + + wrefresh(info->windows[FM_PANE_RIGHT]->win); + wrefresh(info->windows[FM_PANE_LEFT]->win); + wrefresh(term->windows[stat_bar_win_index]->win); + + need_redraw = false; } magic_cleanup(); |
