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