From 48ca0d55b562230644e5f71597979c8d813b80e2 Mon Sep 17 00:00:00 2001 From: verdant Date: Mon, 27 Jul 2026 09:26:02 +0800 Subject: Refactor fm --- fm.h | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'fm.h') diff --git a/fm.h b/fm.h index b50dabe..f175445 100644 --- a/fm.h +++ b/fm.h @@ -4,9 +4,15 @@ #include #include #include +#include #include "wm.h" +#define PANE_LEFT 0 +#define PANE_RIGHT 1 + +#define MARGIN 3 + typedef struct { char name[256]; int is_dir; @@ -14,26 +20,33 @@ typedef struct { typedef struct { file_item *items; - int count; - int cap; + size_t count; + size_t cap; } file_list; typedef struct { file_list *cur; file_list *next; - int selected_idx; - window *fm_l, *fm_r; - int got_next_dir; + int cursor; + window *windows[2]; + /* int got_next_dir; */ char got_dir[PATH_MAX]; char cwd[PATH_MAX]; - int top, bottom, margin_bottom; - int needs_redraw; + int top, bottom; + bool need_redraw; } fm_info; -void fm_getdir(fm_info *i, file_list *l, const char *path); +file_list *fm_getdir(file_list *list, const char *path); fm_info *fm_init(terminal *t); -void fm_getcwd(fm_info *f); -void fm_draw_entries(fm_info *i, int n, int m); -void fm_entries_scrool(terminal *t, fm_info *i, int n); -void fm_draw_right_window(fm_info *i); +void fm_getcwd(fm_info *info); +void fm_draw_entries(window *window, file_list *list, size_t cursor, int top, + int bottom); +void fm_entries_scroll(fm_info *info, int n); +/* void fm_draw_right_window(fm_info *i); */ + +void fm_cd_up(fm_info *i); +void fm_cd_down(fm_info *i); +bool fm_preview_file(window *w, const char *path); +void magic_init(void); +void magic_cleanup(void); #endif /* SF_FM_H */ -- cgit v1.2.3