Panel update: type accuracy.
[midnight-commander.git] / src / filemanager / panel.h
blobe1b1e5450d7e8d5001ec8b7b86adcea2d3c1a6ff
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 */
15 #include "src/main.h" /* cd_enum */
17 #include "dir.h" /* dir_list */
19 /*** typedefs(not structures) and defined constants **********************************************/
21 #define selection(p) (&(p->dir.list[p->selected]))
22 #define DEFAULT_USER_FORMAT "half type name | size | perm"
24 #define LIST_TYPES 4
26 #define UP_KEEPSEL ((char *) -1)
28 /*** enums ***************************************************************************************/
30 enum list_types
32 list_full, /* Name, size, perm/date */
33 list_brief, /* Name */
34 list_long, /* Like ls -l */
35 list_user /* User defined */
38 typedef enum
40 view_listing = 0, /* Directory listing */
41 view_info = 1, /* Information panel */
42 view_tree = 2, /* Tree view */
43 view_quick = 3, /* Quick view */
44 view_nothing = 4, /* Undefined */
45 } panel_view_mode_t;
47 enum panel_display_enum
49 frame_full, /* full screen frame */
50 frame_half /* half screen frame */
53 typedef enum
55 UP_OPTIMIZE = 0,
56 UP_RELOAD = 1,
57 UP_ONLY_CURRENT = 2
58 } panel_update_flags_t;
60 /*** structures declarations (and typedefs of structures)*****************************************/
62 struct format_e;
64 typedef struct panel_format_struct
66 const char *id;
67 int min_size;
68 int expands;
69 align_crt_t default_just;
70 const char *hotkey;
71 const char *title_hotkey;
72 gboolean is_user_choice;
73 gboolean use_in_user_format;
74 const char *(*string_fn) (file_entry *, int);
75 sortfn *sort_routine; /* used by mouse_sort_col() */
76 } panel_field_t;
78 typedef struct WPanel
80 Widget widget;
81 dir_list dir; /* Directory contents */
83 int list_type; /* listing type (was view_type) */
84 int active; /* If panel is currently selected */
85 char cwd[MC_MAXPATHLEN]; /* Current Working Directory */
86 char lwd[MC_MAXPATHLEN]; /* Last Working Directory */
87 GList *dir_history; /* directory history */
88 char *hist_name; /* directory history name for history file */
89 int count; /* Number of files in dir structure */
90 int marked; /* Count of marked files */
91 int dirs_marked; /* Count of marked directories */
92 uintmax_t total; /* Bytes in marked files */
93 int top_file; /* The file showed on the top of the panel */
94 int selected; /* Index to the selected file */
95 int reverse; /* Show listing in reverse? */
96 int case_sensitive; /* Listing is case sensitive? */
97 int exec_first; /* Show executable top in list? */
98 int split; /* Split panel to allow two columns */
99 int is_panelized; /* Flag: special filelisting, can't reload */
100 int frame_size; /* half or full frame */
101 const panel_field_t *current_sort_field;
102 char *filter; /* File name filter */
104 int dirty; /* Should we redisplay the panel? */
106 int user_mini_status; /* Is user_status_format used */
107 char *user_format; /* User format */
108 char *user_status_format[LIST_TYPES]; /* User format for status line */
110 struct format_e *format; /* Display format */
111 struct format_e *status_format; /* Mini status format */
113 int format_modified; /* If the format was changed this is set */
115 char *panel_name; /* The panel name */
116 struct stat dir_stat; /* Stat of current dir: used by execute () */
118 int codepage; /* panel codepage */
120 gboolean searching;
121 char search_buffer[MC_MAXFILENAMELEN];
122 char prev_search_buffer[MC_MAXFILENAMELEN];
123 char search_char[MB_LEN_MAX]; /*buffer for multibytes characters */
124 int search_chpoint; /*point after last characters in search_char */
125 } WPanel;
127 /*** global variables defined in .c file *********************************************************/
129 extern panel_field_t panel_fields[];
131 extern int torben_fj_mode;
132 extern int show_mini_info;
134 extern hook_t *select_file_hook;
136 /*** declarations of public functions ************************************************************/
138 WPanel *panel_new (const char *panel_name);
139 WPanel *panel_new_with_dir (const char *panel_name, const char *dr);
140 void panel_clean_dir (WPanel * panel);
142 void panel_reload (WPanel * panel);
143 void panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order);
144 void panel_re_sort (WPanel * panel);
145 void panel_change_encoding (WPanel * panel);
147 void update_dirty_panels (void);
148 void update_panels (panel_update_flags_t flags, const char *current_file);
149 void panel_update_cols (Widget * widget, int frame_size);
150 int set_panel_formats (WPanel * p);
152 void try_to_select (WPanel * panel, const char *name);
154 void unmark_files (WPanel * panel);
155 void select_item (WPanel * panel);
157 void recalculate_panel_summary (WPanel * panel);
158 void file_mark (WPanel * panel, int idx, int val);
159 void do_file_mark (WPanel * panel, int idx, int val);
161 gboolean do_panel_cd (struct WPanel *panel, const char *new_dir, enum cd_enum cd_type);
163 void directory_history_add (struct WPanel *panel, const char *dir);
165 char *remove_encoding_from_path (const char *path);
167 gsize panel_get_num_of_sortable_fields (void);
168 const char **panel_get_sortable_fields (gsize *);
169 const panel_field_t *panel_get_field_by_id (const char *);
170 const panel_field_t *panel_get_field_by_title (const char *);
171 const panel_field_t *panel_get_field_by_title_hotkey (const char *);
172 gsize panel_get_num_of_user_possible_fields (void);
173 const char **panel_get_user_possible_fields (gsize *);
175 void panel_init (void);
176 void panel_deinit (void);
178 /*** inline functions ****************************************************************************/
179 #endif /* MC__PANEL_H */