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

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