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
  5. panel_current_entry

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

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