Refactored IPV4/IPV6 FTP connection setup code
[midnight-commander.git] / src / panel.h
blob65bde53052961b3d4350e7a8fd344511c9d7d2cd
2 /** \file panel.h
3 * \brief Header: defines WPanel structure
4 */
6 #ifndef MC_PANEL_H
7 #define MC_PANEL_H
9 #include "lib/global.h"
10 #include "lib/fs.h" /* MC_MAXPATHLEN */
11 #include "lib/strutil.h"
13 #include "dir.h" /* dir_list */
14 #include "dialog.h" /* Widget */
15 #include "main.h" /* cd_enum */
17 #define selection(p) (&(p->dir.list[p->selected]))
18 #define DEFAULT_USER_FORMAT "half type name | size | perm"
20 #define LIST_TYPES 4
22 enum list_types {
23 list_full, /* Name, size, perm/date */
24 list_brief, /* Name */
25 list_long, /* Like ls -l */
26 list_user /* User defined */
29 typedef enum {
30 view_listing = 0, /* Directory listing */
31 view_info = 1, /* Information panel */
32 view_tree = 2, /* Tree view */
33 view_quick = 3, /* Quick view */
34 view_nothing = 4, /* Undefined */
35 } panel_view_mode_t;
37 enum panel_display_enum {
38 frame_full, /* full screen frame */
39 frame_half /* half screen frame */
42 struct format_e;
44 typedef struct panel_format_struct {
45 const char *id;
46 int min_size;
47 int expands;
48 align_crt_t default_just;
49 const char *hotkey;
50 const char *title_hotkey;
51 gboolean is_user_choice;
52 gboolean use_in_user_format;
53 const char *(*string_fn)(file_entry *, int);
54 sortfn *sort_routine; /* used by mouse_sort_col() */
55 } panel_field_t;
57 extern panel_field_t panel_fields [];
59 typedef struct WPanel {
60 Widget widget;
61 dir_list dir; /* Directory contents */
63 int list_type; /* listing type (was view_type) */
64 int active; /* If panel is currently selected */
65 char cwd [MC_MAXPATHLEN];/* Current Working Directory */
66 char lwd [MC_MAXPATHLEN];/* Last Working Directory */
67 GList *dir_history; /* directory history */
68 char *hist_name; /* directory history name for history file */
69 int count; /* Number of files in dir structure */
70 int marked; /* Count of marked files */
71 int dirs_marked; /* Count of marked directories */
72 double total; /* Bytes in marked files */
73 int top_file; /* The file showed on the top of the panel */
74 int selected; /* Index to the selected file */
75 int reverse; /* Show listing in reverse? */
76 int case_sensitive; /* Listing is case sensitive? */
77 int exec_first; /* Show executable top in list? */
78 int split; /* Split panel to allow two columns */
79 int is_panelized; /* Flag: special filelisting, can't reload */
80 int frame_size; /* half or full frame */
81 const panel_field_t *current_sort_field;
82 char *filter; /* File name filter */
84 int dirty; /* Should we redisplay the panel? */
86 int user_mini_status; /* Is user_status_format used */
87 char *user_format; /* User format */
88 char *user_status_format[LIST_TYPES];/* User format for status line */
90 struct format_e *format; /* Display format */
91 struct format_e *status_format; /* Mini status format */
93 int format_modified; /* If the format was changed this is set */
95 char *panel_name; /* The panel name */
96 struct stat dir_stat; /* Stat of current dir: used by execute () */
98 gboolean searching;
99 char search_buffer [256];
100 char search_char [MB_LEN_MAX]; /*buffer for multibytes characters*/
101 int search_chpoint; /*point after last characters in search_char*/
102 } WPanel;
104 WPanel *panel_new (const char *panel_name);
105 WPanel *panel_new_with_dir (const char *panel_name, const char *dr);
106 void panel_clean_dir (WPanel *panel);
108 extern int torben_fj_mode;
109 extern int show_mini_info;
111 void panel_reload (WPanel *panel);
112 void panel_set_sort_order (WPanel *panel, const panel_field_t *sort_order);
113 void panel_re_sort (WPanel *panel);
114 void set_panel_encoding (WPanel *);
116 #define UP_OPTIMIZE 0
117 #define UP_RELOAD 1
118 #define UP_ONLY_CURRENT 2
120 #define UP_KEEPSEL ((char *) -1)
122 void update_dirty_panels (void);
123 void update_panels (int force_update, const char *current_file);
124 void panel_update_cols (Widget *widget, int frame_size);
125 int set_panel_formats (WPanel *p);
127 #define other_panel get_other_panel()
129 extern WPanel *left_panel;
130 extern WPanel *right_panel;
131 extern WPanel *current_panel;
133 void try_to_select (WPanel *panel, const char *name);
135 void unmark_files (WPanel *panel);
136 void select_item (WPanel *panel);
138 extern Hook *select_file_hook;
140 void recalculate_panel_summary (WPanel *panel);
141 void file_mark (WPanel *panel, int idx, int val);
142 void do_file_mark (WPanel *panel, int idx, int val);
144 gboolean do_panel_cd (struct WPanel *panel, const char *new_dir, enum cd_enum cd_type);
146 void directory_history_add (struct WPanel *panel, const char *dir);
148 gsize panel_get_num_of_sortable_fields(void);
149 const char **panel_get_sortable_fields(gsize *);
150 const panel_field_t *panel_get_field_by_id(const char *);
151 const panel_field_t *panel_get_field_by_title(const char *);
152 const panel_field_t *panel_get_field_by_title_hotkey(const char *);
153 gsize panel_get_num_of_user_possible_fields(void);
154 const char **panel_get_user_possible_fields(gsize *);
156 void panel_init(void);
157 void panel_deinit(void);
159 #endif /* MC_PANEL_H */