2 * \brief Header: defines WPanel structure
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"
25 #define UP_KEEPSEL ((char *) -1)
27 /*** enums ***************************************************************************************/
31 list_full
, /* Name, size, perm/date */
32 list_brief
, /* Name */
33 list_long
, /* Like ls -l */
34 list_user
/* User defined */
39 frame_full
, /* full screen frame */
40 frame_half
/* half screen frame */
48 } panel_update_flags_t
;
50 /* run mode and params */
58 /*** structures declarations (and typedefs of structures)*****************************************/
62 typedef struct panel_field_struct
67 align_crt_t default_just
;
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 sortfn
*sort_routine
; /* used by mouse_sort_col() */
80 vfs_path_t
*root_vpath
;
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 const panel_field_t
*sort_field
;
94 dir_list dir
; /* Directory contents */
96 int list_type
; /* listing type (was view_type) */
97 int active
; /* If panel is currently selected */
98 vfs_path_t
*cwd_vpath
; /* Current Working Directory */
99 vfs_path_t
*lwd_vpath
; /* Last Working Directory */
100 GList
*dir_history
; /* directory history */
101 GList
*dir_history_current
; /* pointer to the current history item */
102 char *hist_name
; /* directory history name for history file */
103 int count
; /* Number of files in dir structure */
104 int marked
; /* Count of marked files */
105 int dirs_marked
; /* Count of marked directories */
106 uintmax_t total
; /* Bytes in marked files */
107 int top_file
; /* The file showed on the top of the panel */
108 int selected
; /* Index to the selected file */
109 int split
; /* Split panel to allow two columns */
110 gboolean is_panelized
; /* Flag: special filelisting, can't reload */
111 panel_display_t frame_size
; /* half or full frame */
112 char *filter
; /* File name filter */
113 panel_sort_info_t sort_info
; /* Sort descriptor */
115 int dirty
; /* Should we redisplay the panel? */
117 int user_mini_status
; /* Is user_status_format used */
118 char *user_format
; /* User format */
119 char *user_status_format
[LIST_TYPES
]; /* User format for status line */
121 struct format_e
*format
; /* Display format */
122 struct format_e
*status_format
; /* Mini status format */
124 int format_modified
; /* If the format was changed this is set */
126 char *panel_name
; /* The panel name */
127 struct stat dir_stat
; /* Stat of current dir: used by execute () */
130 int codepage
; /* panel codepage */
134 char search_buffer
[MC_MAXFILENAMELEN
];
135 char prev_search_buffer
[MC_MAXFILENAMELEN
];
136 char search_char
[MB_LEN_MAX
]; /*buffer for multibytes characters */
137 int search_chpoint
; /*point after last characters in search_char */
138 int content_shift
; /* Number of characters of filename need to skip from left side. */
139 int max_shift
; /* Max shift for visible part of current panel */
142 /*** global variables defined in .c file *********************************************************/
144 extern panelized_panel_t panelized_panel
;
146 extern panel_field_t panel_fields
[];
148 extern hook_t
*select_file_hook
;
150 extern mc_fhl_t
*mc_filehighlight
;
152 /*** declarations of public functions ************************************************************/
154 WPanel
*panel_new (const char *panel_name
);
155 WPanel
*panel_new_with_dir (const char *panel_name
, const char *dr
);
156 void panel_clean_dir (WPanel
* panel
);
158 void panel_reload (WPanel
* panel
);
159 void panel_set_sort_order (WPanel
* panel
, const panel_field_t
* sort_order
);
160 void panel_re_sort (WPanel
* panel
);
163 void panel_change_encoding (WPanel
* panel
);
164 vfs_path_t
*remove_encoding_from_path (const vfs_path_t
* vpath
);
167 void update_panels (panel_update_flags_t flags
, const char *current_file
);
168 int set_panel_formats (WPanel
* p
);
169 void panel_update_cols (Widget
* widget
, panel_display_t frame_size
);
171 void try_to_select (WPanel
* panel
, const char *name
);
173 void unmark_files (WPanel
* panel
);
174 void select_item (WPanel
* panel
);
176 void recalculate_panel_summary (WPanel
* panel
);
177 void file_mark (WPanel
* panel
, int idx
, int val
);
178 void do_file_mark (WPanel
* panel
, int idx
, int val
);
180 gboolean
do_panel_cd (struct WPanel
*panel
, const vfs_path_t
* new_dir_vpath
, enum cd_enum cd_type
);
182 gsize
panel_get_num_of_sortable_fields (void);
183 const char **panel_get_sortable_fields (gsize
*);
184 const panel_field_t
*panel_get_field_by_id (const char *);
185 const panel_field_t
*panel_get_field_by_title (const char *);
186 const panel_field_t
*panel_get_field_by_title_hotkey (const char *);
187 gsize
panel_get_num_of_user_possible_fields (void);
188 const char **panel_get_user_possible_fields (gsize
*);
189 void panel_set_cwd (WPanel
* panel
, const char *path_str
);
190 void panel_set_lwd (WPanel
* panel
, const char *path_str
);
192 void panel_init (void);
193 void panel_deinit (void);
194 gboolean
do_cd (const vfs_path_t
* new_dir_vpath
, enum cd_enum cd_type
);
196 /*** inline functions ****************************************************************************/
197 #endif /* MC__PANEL_H */