root/src/filemanager/panel.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. panel_empty_new
  2. panel_with_dir_new
  3. panel_new
  4. panel_sized_new

   1 /** \file panel.h
   2  *  \brief Header: defines WPanel structure
   3  */
   4 
   5 #ifndef MC__PANEL_H
   6 #define MC__PANEL_H
   7 
   8 #include <inttypes.h>           /* uintmax_t */
   9 #include <limits.h>             /* MB_LEN_MAX */
  10 
  11 #include "lib/global.h"         /* gboolean */
  12 #include "lib/fs.h"             /* MC_MAXPATHLEN */
  13 #include "lib/strutil.h"
  14 #include "lib/widget.h"         /* Widget */
  15 #include "lib/filehighlight.h"
  16 #include "lib/file-entry.h"
  17 
  18 #include "dir.h"                /* dir_list */
  19 
  20 /*** typedefs(not structures) and defined constants **********************************************/
  21 
  22 #define PANEL(x) ((WPanel *)(x))
  23 
  24 #define LIST_FORMATS 4
  25 
  26 #define UP_KEEPSEL ((char *) -1)
  27 
  28 /*** enums ***************************************************************************************/
  29 
  30 typedef enum
  31 {
  32     list_full,                  /* Name, size, perm/date */
  33     list_brief,                 /* Name */
  34     list_long,                  /* Like ls -l */
  35     list_user                   /* User defined */
  36 } list_format_t;
  37 
  38 typedef enum
  39 {
  40     frame_full,                 /* full screen frame */
  41     frame_half                  /* half screen frame */
  42 } panel_display_t;
  43 
  44 typedef enum
  45 {
  46     UP_OPTIMIZE = 0,
  47     UP_RELOAD = 1,
  48     UP_ONLY_CURRENT = 2
  49 } panel_update_flags_t;
  50 
  51 /* run mode and params */
  52 enum cd_enum
  53 {
  54     cd_parse_command,
  55     cd_exact
  56 };
  57 
  58 /*** structures declarations (and typedefs of structures)*****************************************/
  59 
  60 typedef struct panel_field_struct
  61 {
  62     const char *id;
  63     int min_size;
  64     gboolean expands;
  65     align_crt_t default_just;
  66     const char *hotkey;
  67     const char *title_hotkey;
  68     gboolean is_user_choice;
  69     gboolean use_in_user_format;
  70     const char *(*string_fn) (const file_entry_t * fe, int len);
  71     GCompareFunc sort_routine;  /* used by mouse_sort_col() */
  72 } panel_field_t;
  73 
  74 typedef struct
  75 {
  76     dir_list list;
  77     vfs_path_t *root_vpath;
  78 } panelized_descr_t;
  79 
  80 typedef struct
  81 {
  82     Widget widget;
  83 
  84     char *name;                 /* The panel name */
  85 
  86     panel_display_t frame_size; /* half or full frame */
  87 
  88     gboolean active;            /* If panel is currently selected */
  89     gboolean dirty;             /* Should we redisplay the panel? */
  90 
  91     gboolean is_panelized;      /* Panelization: special mode, can't reload the file list */
  92     panelized_descr_t *panelized_descr; /* Panelization descriptor */
  93 
  94 #ifdef HAVE_CHARSET
  95     int codepage;               /* Panel codepage */
  96 #endif
  97 
  98     dir_list dir;               /* Directory contents */
  99     struct stat dir_stat;       /* Stat of current dir: used by execute () */
 100 
 101     vfs_path_t *cwd_vpath;      /* Current Working Directory */
 102     vfs_path_t *lwd_vpath;      /* Last Working Directory */
 103 
 104     list_format_t list_format;  /* Listing type */
 105     GSList *format;             /* Display format */
 106     char *user_format;          /* User format */
 107     int list_cols;              /* Number of file list columns */
 108     int brief_cols;             /* Number of columns in case of list_brief format */
 109     /* sort */
 110     dir_sort_options_t sort_info;
 111     const panel_field_t *sort_field;
 112 
 113     int marked;                 /* Count of marked files */
 114     int dirs_marked;            /* Count of marked directories */
 115     uintmax_t total;            /* Bytes in marked files */
 116 
 117     int top;                    /* The file shown on the top of the panel */
 118     int current;                /* Index to the currently selected file */
 119 
 120     GSList *status_format;      /* Mini status format */
 121     gboolean user_mini_status;  /* Is user_status_format used */
 122     char *user_status_format[LIST_FORMATS];     /* User format for status line */
 123 
 124     file_filter_t filter;       /* File name filter */
 125 
 126     struct
 127     {
 128         char *name;             /* Directory history name for history file */
 129         GList *list;            /* Directory history */
 130         GList *current;         /* Pointer to the current history item */
 131     } dir_history;
 132 
 133     struct
 134     {
 135         gboolean active;
 136         GString *buffer;
 137         GString *prev_buffer;
 138         char ch[MB_LEN_MAX];    /* Buffer for multi-byte character */
 139         int chpoint;            /* Point after last characters in @ch */
 140     } quick_search;
 141 
 142     int content_shift;          /* Number of characters of filename need to skip from left side. */
 143     int max_shift;              /* Max shift for visible part of current panel */
 144 } WPanel;
 145 
 146 /*** global variables defined in .c file *********************************************************/
 147 
 148 extern hook_t *select_file_hook;
 149 
 150 extern mc_fhl_t *mc_filehighlight;
 151 
 152 /*** declarations of public functions ************************************************************/
 153 
 154 WPanel *panel_sized_empty_new (const char *panel_name, const WRect * r);
 155 WPanel *panel_sized_with_dir_new (const char *panel_name, const WRect * r,
 156                                   const vfs_path_t * vpath);
 157 
 158 void panel_clean_dir (WPanel * panel);
 159 
 160 void panel_reload (WPanel * panel);
 161 void panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order);
 162 void panel_re_sort (WPanel * panel);
 163 
 164 #ifdef HAVE_CHARSET
 165 void panel_change_encoding (WPanel * panel);
 166 vfs_path_t *remove_encoding_from_path (const vfs_path_t * vpath);
 167 #endif
 168 
 169 void update_panels (panel_update_flags_t flags, const char *current_file);
 170 int set_panel_formats (WPanel * p);
 171 
 172 void panel_set_filter (WPanel * panel, const file_filter_t * filter);
 173 
 174 file_entry_t *panel_current_entry (const WPanel *panel);
 175 void panel_set_current_by_name (WPanel * panel, const char *name);
 176 
 177 void unmark_files (WPanel * panel);
 178 void select_item (WPanel * panel);
 179 
 180 void recalculate_panel_summary (WPanel * panel);
 181 void file_mark (WPanel * panel, int idx, int val);
 182 void do_file_mark (WPanel * panel, int idx, int val);
 183 const GString *panel_find_marked_file (const WPanel *panel, int *current_file);
 184 const GString *panel_get_marked_file (const WPanel *panel, int *current_file);
 185 
 186 gboolean panel_do_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
 187 MC_MOCKABLE gboolean panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath,
 188                                enum cd_enum cd_type);
 189 
 190 gsize panel_get_num_of_sortable_fields (void);
 191 char **panel_get_sortable_fields (gsize * array_size);
 192 const panel_field_t *panel_get_field_by_id (const char *name);
 193 const panel_field_t *panel_get_field_by_title (const char *name);
 194 const panel_field_t *panel_get_field_by_title_hotkey (const char *name);
 195 gsize panel_get_num_of_user_possible_fields (void);
 196 char **panel_get_user_possible_fields (gsize * array_size);
 197 void panel_set_cwd (WPanel * panel, const vfs_path_t * vpath);
 198 void panel_set_lwd (WPanel * panel, const vfs_path_t * vpath);
 199 
 200 void panel_panelize_cd (void);
 201 void panel_panelize_change_root (WPanel * panel, const vfs_path_t * new_root);
 202 void panel_panelize_absolutize_if_needed (WPanel * panel);
 203 void panel_panelize_save (WPanel * panel);
 204 
 205 void panel_init (void);
 206 void panel_deinit (void);
 207 
 208 /* --------------------------------------------------------------------------------------------- */
 209 /*** inline functions ****************************************************************************/
 210 /* --------------------------------------------------------------------------------------------- */
 211 /**
 212  * Empty panel creation.
 213  *
 214  * @param panel_name name of panel for setup retrieving
 215  *
 216  * @return new instance of WPanel
 217  */
 218 
 219 static inline WPanel *
 220 panel_empty_new (const char *panel_name)
     /* [previous][next][first][last][top][bottom][index][help]  */
 221 {
 222     /* Unknown sizes of the panel at startup */
 223     WRect r = { 0, 0, 1, 1 };
 224 
 225     return panel_sized_empty_new (panel_name, &r);
 226 }
 227 
 228 /* --------------------------------------------------------------------------------------------- */
 229 /**
 230  * Panel creation for specified directory.
 231  *
 232  * @param panel_name name of panel for setup retrieving
 233  * @param vpath working panel directory. If NULL then current directory is used
 234  *
 235  * @return new instance of WPanel
 236  */
 237 
 238 static inline WPanel *
 239 panel_with_dir_new (const char *panel_name, const vfs_path_t *vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
 240 {
 241     /* Unknown sizes of the panel at startup */
 242     WRect r = { 0, 0, 1, 1 };
 243 
 244     return panel_sized_with_dir_new (panel_name, &r, vpath);
 245 }
 246 
 247 
 248 /* --------------------------------------------------------------------------------------------- */
 249 /**
 250  * Panel creation.
 251  *
 252  * @param panel_name name of panel for setup retrieving
 253  *
 254  * @return new instance of WPanel
 255  */
 256 
 257 static inline WPanel *
 258 panel_new (const char *panel_name)
     /* [previous][next][first][last][top][bottom][index][help]  */
 259 {
 260     return panel_with_dir_new (panel_name, NULL);
 261 }
 262 
 263 /* --------------------------------------------------------------------------------------------- */
 264 /**
 265  * Panel creation with specified size.
 266  *
 267  * @param panel_name name of panel for setup retrieving
 268  * @param r panel area
 269  *
 270  * @return new instance of WPanel
 271  */
 272 
 273 static inline WPanel *
 274 panel_sized_new (const char *panel_name, const WRect *r)
     /* [previous][next][first][last][top][bottom][index][help]  */
 275 {
 276     return panel_sized_with_dir_new (panel_name, r, NULL);
 277 }
 278 
 279 /* --------------------------------------------------------------------------------------------- */
 280 
 281 #endif /* MC__PANEL_H */

/* [previous][next][first][last][top][bottom][index][help]  */