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 */
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"
26 #define UP_KEEPSEL ((char *) -1)
28 /*** enums ***************************************************************************************/
32 list_full
, /* Name, size, perm/date */
33 list_brief
, /* Name */
34 list_long
, /* Like ls -l */
35 list_user
/* User defined */
40 frame_full
, /* full screen frame */
41 frame_half
/* half screen frame */
49 } panel_update_flags_t
;
51 /*** structures declarations (and typedefs of structures)*****************************************/
55 typedef struct panel_field_struct
60 align_crt_t default_just
;
62 const char *title_hotkey
;
63 gboolean is_user_choice
;
64 gboolean use_in_user_format
;
65 const char *(*string_fn
) (file_entry
*, int);
66 sortfn
*sort_routine
; /* used by mouse_sort_col() */
73 vfs_path_t
*root_vpath
;
76 typedef struct panel_sort_info_struct
78 gboolean reverse
; /* Show listing in reverse? */
79 gboolean case_sensitive
; /* Listing is case sensitive? */
80 gboolean exec_first
; /* Show executable top in list? */
81 const panel_field_t
*sort_field
;
87 dir_list dir
; /* Directory contents */
89 int list_type
; /* listing type (was view_type) */
90 int active
; /* If panel is currently selected */
91 vfs_path_t
*cwd_vpath
; /* Current Working Directory */
92 vfs_path_t
*lwd_vpath
; /* Last Working Directory */
93 GList
*dir_history
; /* directory history */
94 GList
*dir_history_current
; /* pointer to the current history item */
95 char *hist_name
; /* directory history name for history file */
96 int count
; /* Number of files in dir structure */
97 int marked
; /* Count of marked files */
98 int dirs_marked
; /* Count of marked directories */
99 uintmax_t total
; /* Bytes in marked files */
100 int top_file
; /* The file showed on the top of the panel */
101 int selected
; /* Index to the selected file */
102 int split
; /* Split panel to allow two columns */
103 gboolean is_panelized
; /* Flag: special filelisting, can't reload */
104 panel_display_t frame_size
; /* half or full frame */
105 char *filter
; /* File name filter */
106 panel_sort_info_t sort_info
; /* Sort descriptor */
108 int dirty
; /* Should we redisplay the panel? */
110 int user_mini_status
; /* Is user_status_format used */
111 char *user_format
; /* User format */
112 char *user_status_format
[LIST_TYPES
]; /* User format for status line */
114 struct format_e
*format
; /* Display format */
115 struct format_e
*status_format
; /* Mini status format */
117 int format_modified
; /* If the format was changed this is set */
119 char *panel_name
; /* The panel name */
120 struct stat dir_stat
; /* Stat of current dir: used by execute () */
122 int codepage
; /* panel codepage */
125 char search_buffer
[MC_MAXFILENAMELEN
];
126 char prev_search_buffer
[MC_MAXFILENAMELEN
];
127 char search_char
[MB_LEN_MAX
]; /*buffer for multibytes characters */
128 int search_chpoint
; /*point after last characters in search_char */
129 int content_shift
; /* Number of characters of filename need to skip from left side. */
130 int max_shift
; /* Max shift for visible part of current panel */
133 /*** global variables defined in .c file *********************************************************/
135 extern panelized_panel_t panelized_panel
;
137 extern panel_field_t panel_fields
[];
139 extern hook_t
*select_file_hook
;
141 /*** declarations of public functions ************************************************************/
143 WPanel
*panel_new (const char *panel_name
);
144 WPanel
*panel_new_with_dir (const char *panel_name
, const char *dr
);
145 void panel_clean_dir (WPanel
* panel
);
147 void panel_reload (WPanel
* panel
);
148 void panel_set_sort_order (WPanel
* panel
, const panel_field_t
* sort_order
);
149 void panel_re_sort (WPanel
* panel
);
150 void panel_change_encoding (WPanel
* panel
);
152 void update_panels (panel_update_flags_t flags
, const char *current_file
);
153 int set_panel_formats (WPanel
* p
);
154 void panel_update_cols (Widget
* widget
, panel_display_t frame_size
);
156 void try_to_select (WPanel
* panel
, const char *name
);
158 void unmark_files (WPanel
* panel
);
159 void select_item (WPanel
* panel
);
161 void recalculate_panel_summary (WPanel
* panel
);
162 void file_mark (WPanel
* panel
, int idx
, int val
);
163 void do_file_mark (WPanel
* panel
, int idx
, int val
);
165 gboolean
do_panel_cd (struct WPanel
*panel
, const vfs_path_t
* new_dir_vpath
, enum cd_enum cd_type
);
167 vfs_path_t
*remove_encoding_from_path (const vfs_path_t
* vpath
);
169 gsize
panel_get_num_of_sortable_fields (void);
170 const char **panel_get_sortable_fields (gsize
*);
171 const panel_field_t
*panel_get_field_by_id (const char *);
172 const panel_field_t
*panel_get_field_by_title (const char *);
173 const panel_field_t
*panel_get_field_by_title_hotkey (const char *);
174 gsize
panel_get_num_of_user_possible_fields (void);
175 const char **panel_get_user_possible_fields (gsize
*);
176 void panel_set_cwd (WPanel
* panel
, const char *path_str
);
177 void panel_set_lwd (WPanel
* panel
, const char *path_str
);
179 void panel_init (void);
180 void panel_deinit (void);
182 /*** inline functions ****************************************************************************/
183 #endif /* MC__PANEL_H */