Move sort_field member out from panel_sort_info_t structure.
[midnight-commander.git] / src / filemanager / panel.h
blobb8952f8326633a0e8fa2629b787b336ddce1c994
1 /** \file panel.h
2 * \brief Header: defines WPanel structure
3 */
5 #ifndef MC__PANEL_H
6 #define MC__PANEL_H
8 #include <inttypes.h> /* uintmax_t */
10 #include "lib/global.h" /* gboolean */
11 #include "lib/fs.h" /* MC_MAXPATHLEN */
12 #include "lib/strutil.h"
13 #include "lib/widget.h" /* Widget */
14 #include "lib/filehighlight.h"
16 #include "dir.h" /* dir_list */
18 /*** typedefs(not structures) and defined constants **********************************************/
20 #define selection(p) (&(p->dir.list[p->selected]))
21 #define DEFAULT_USER_FORMAT "half type name | size | perm"
23 #define LIST_TYPES 4
25 #define UP_KEEPSEL ((char *) -1)
27 /*** enums ***************************************************************************************/
29 enum list_types
31 list_full, /* Name, size, perm/date */
32 list_brief, /* Name */
33 list_long, /* Like ls -l */
34 list_user /* User defined */
37 typedef enum
39 frame_full, /* full screen frame */
40 frame_half /* half screen frame */
41 } panel_display_t;
43 typedef enum
45 UP_OPTIMIZE = 0,
46 UP_RELOAD = 1,
47 UP_ONLY_CURRENT = 2
48 } panel_update_flags_t;
50 /* run mode and params */
52 enum cd_enum
54 cd_parse_command,
55 cd_exact
58 /*** structures declarations (and typedefs of structures)*****************************************/
60 struct format_e;
62 typedef struct panel_field_struct
64 const char *id;
65 int min_size;
66 int expands;
67 align_crt_t default_just;
68 const char *hotkey;
69 const char *title_hotkey;
70 gboolean is_user_choice;
71 gboolean use_in_user_format;
72 const char *(*string_fn) (file_entry *, int);
73 GCompareFunc sort_routine; /* used by mouse_sort_col() */
74 } panel_field_t;
76 typedef struct
78 dir_list list;
79 int count;
80 vfs_path_t *root_vpath;
81 } panelized_panel_t;
83 typedef struct panel_sort_info_struct
85 gboolean reverse; /* Show listing in reverse? */
86 gboolean case_sensitive; /* Listing is case sensitive? */
87 gboolean exec_first; /* Show executable top in list? */
88 } panel_sort_info_t;
90 typedef struct WPanel
92 Widget widget;
93 dir_list dir; /* Directory contents */
95 int list_type; /* listing type (was view_type) */
96 int active; /* If panel is currently selected */
97 vfs_path_t *cwd_vpath; /* Current Working Directory */
98 vfs_path_t *lwd_vpath; /* Last Working Directory */
99 GList *dir_history; /* directory history */
100 GList *dir_history_current; /* pointer to the current history item */
101 char *hist_name; /* directory history name for history file */
102 int count; /* Number of files in dir structure */
103 int marked; /* Count of marked files */
104 int dirs_marked; /* Count of marked directories */
105 uintmax_t total; /* Bytes in marked files */
106 int top_file; /* The file showed on the top of the panel */
107 int selected; /* Index to the selected file */
108 int split; /* Split panel to allow two columns */
109 gboolean is_panelized; /* Flag: special filelisting, can't reload */
110 panel_display_t frame_size; /* half or full frame */
111 char *filter; /* File name filter */
113 /* sort */
114 panel_sort_info_t sort_info;
115 const panel_field_t *sort_field;
117 int dirty; /* Should we redisplay the panel? */
119 int user_mini_status; /* Is user_status_format used */
120 char *user_format; /* User format */
121 char *user_status_format[LIST_TYPES]; /* User format for status line */
123 struct format_e *format; /* Display format */
124 struct format_e *status_format; /* Mini status format */
126 int format_modified; /* If the format was changed this is set */
128 char *panel_name; /* The panel name */
129 struct stat dir_stat; /* Stat of current dir: used by execute () */
131 #ifdef HAVE_CHARSET
132 int codepage; /* panel codepage */
133 #endif
135 gboolean searching;
136 char search_buffer[MC_MAXFILENAMELEN];
137 char prev_search_buffer[MC_MAXFILENAMELEN];
138 char search_char[MB_LEN_MAX]; /*buffer for multibytes characters */
139 int search_chpoint; /*point after last characters in search_char */
140 int content_shift; /* Number of characters of filename need to skip from left side. */
141 int max_shift; /* Max shift for visible part of current panel */
142 } WPanel;
144 /*** global variables defined in .c file *********************************************************/
146 extern panelized_panel_t panelized_panel;
148 extern panel_field_t panel_fields[];
150 extern hook_t *select_file_hook;
152 extern mc_fhl_t *mc_filehighlight;
154 /*** declarations of public functions ************************************************************/
156 WPanel *panel_new (const char *panel_name);
157 WPanel *panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath);
158 void panel_clean_dir (WPanel * panel);
160 void panel_reload (WPanel * panel);
161 void panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order);
162 void panel_re_sort (WPanel * panel);
164 #ifdef HAVE_CHARSET
165 void panel_change_encoding (WPanel * panel);
166 vfs_path_t *remove_encoding_from_path (const vfs_path_t * vpath);
167 #endif
169 void update_panels (panel_update_flags_t flags, const char *current_file);
170 int set_panel_formats (WPanel * p);
171 void panel_update_cols (Widget * widget, panel_display_t frame_size);
173 void try_to_select (WPanel * panel, const char *name);
175 void unmark_files (WPanel * panel);
176 void select_item (WPanel * panel);
178 void recalculate_panel_summary (WPanel * panel);
179 void file_mark (WPanel * panel, int idx, int val);
180 void do_file_mark (WPanel * panel, int idx, int val);
182 gboolean do_panel_cd (struct WPanel *panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
184 gsize panel_get_num_of_sortable_fields (void);
185 const char **panel_get_sortable_fields (gsize *);
186 const panel_field_t *panel_get_field_by_id (const char *);
187 const panel_field_t *panel_get_field_by_title (const char *);
188 const panel_field_t *panel_get_field_by_title_hotkey (const char *);
189 gsize panel_get_num_of_user_possible_fields (void);
190 const char **panel_get_user_possible_fields (gsize *);
191 void panel_set_cwd (WPanel * panel, const vfs_path_t * vpath);
192 void panel_set_lwd (WPanel * panel, const vfs_path_t * vpath);
194 void panel_init (void);
195 void panel_deinit (void);
196 gboolean do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
198 /*** inline functions ****************************************************************************/
199 #endif /* MC__PANEL_H */