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     dir_list dir;               /* Directory contents */
  94 
  95     list_format_t list_format;  /* listing type */
  96     int active;                 /* If panel is currently selected */
  97     vfs_path_t *cwd_vpath;      /* Current Working Directory */
  98     vfs_path_t *lwd_vpath;      /* Last Working Directory */
  99     GList *dir_history;         /* directory history */
 100     GList *dir_history_current; /* pointer to the current history item */
 101     char *hist_name;            /* directory history name for history file */
 102     int marked;                 /* Count of marked files */
 103     int dirs_marked;            /* Count of marked directories */
 104     uintmax_t total;            /* Bytes in marked files */
 105     int top_file;               /* The file showed on the top of the panel */
 106     int selected;               /* Index to the selected file */
 107     int list_cols;              /* Number of file list columns */
 108     int brief_cols;             /* Number of columns in case of list_brief format */
 109     gboolean is_panelized;      /* Flag: special filelisting, can't reload */
 110     panel_display_t frame_size; /* half or full frame */
 111     char *filter;               /* File name filter */
 112 
 113     /* sort */
 114     dir_sort_options_t sort_info;
 115     const panel_field_t *sort_field;
 116 
 117     int dirty;                  /* Should we redisplay the panel? */
 118 
 119     gboolean user_mini_status;  /* Is user_status_format used */
 120     char *user_format;          /* User format */
 121     char *user_status_format[LIST_FORMATS];     /* User format for status line */
 122 
 123     GSList *format;             /* Display format */
 124     GSList *status_format;      /* Mini status format */
 125 
 126     char *panel_name;           /* The panel name */
 127     struct stat dir_stat;       /* Stat of current dir: used by execute () */
 128 
 129 #ifdef HAVE_CHARSET
 130     int codepage;               /* panel codepage */
 131 #endif
 132 
 133     gboolean searching;
 134     char search_buffer[MC_MAXFILENAMELEN];
 135     char prev_search_buffer[MC_MAXFILENAMELEN];
 136     char search_char[MB_LEN_MAX];       /*buffer for multibytes characters */
 137     int search_chpoint;         /*point after last characters in search_char */
 138     int content_shift;          /* Number of characters of filename need to skip from left side. */
 139     int max_shift;              /* Max shift for visible part of current panel */
 140 } WPanel;
 141 
 142 /*** global variables defined in .c file *********************************************************/
 143 
 144 extern panelized_panel_t panelized_panel;
 145 
 146 extern hook_t *select_file_hook;
 147 
 148 extern mc_fhl_t *mc_filehighlight;
 149 
 150 /*** declarations of public functions ************************************************************/
 151 
 152 WPanel *panel_sized_empty_new (const char *panel_name, int y, int x, int lines, int cols);
 153 WPanel *panel_sized_with_dir_new (const char *panel_name, int y, int x, int lines, int cols,
 154                                   const vfs_path_t * vpath);
 155 
 156 void panel_clean_dir (WPanel * panel);
 157 
 158 void panel_reload (WPanel * panel);
 159 void panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order);
 160 void panel_re_sort (WPanel * panel);
 161 
 162 #ifdef HAVE_CHARSET
 163 void panel_change_encoding (WPanel * panel);
 164 vfs_path_t *remove_encoding_from_path (const vfs_path_t * vpath);
 165 #endif
 166 
 167 void update_panels (panel_update_flags_t flags, const char *current_file);
 168 int set_panel_formats (WPanel * p);
 169 
 170 void try_to_select (WPanel * panel, const char *name);
 171 
 172 void unmark_files (WPanel * panel);
 173 void select_item (WPanel * panel);
 174 
 175 void recalculate_panel_summary (WPanel * panel);
 176 void file_mark (WPanel * panel, int idx, int val);
 177 void do_file_mark (WPanel * panel, int idx, int val);
 178 
 179 gboolean do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
 180 
 181 gsize panel_get_num_of_sortable_fields (void);
 182 char **panel_get_sortable_fields (gsize *);
 183 const panel_field_t *panel_get_field_by_id (const char *);
 184 const panel_field_t *panel_get_field_by_title (const char *);
 185 const panel_field_t *panel_get_field_by_title_hotkey (const char *);
 186 gsize panel_get_num_of_user_possible_fields (void);
 187 char **panel_get_user_possible_fields (gsize *);
 188 void panel_set_cwd (WPanel * panel, const vfs_path_t * vpath);
 189 void panel_set_lwd (WPanel * panel, const vfs_path_t * vpath);
 190 
 191 void panel_init (void);
 192 void panel_deinit (void);
 193 gboolean do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
 194 
 195 /* --------------------------------------------------------------------------------------------- */
 196 /*** inline functions ****************************************************************************/
 197 /* --------------------------------------------------------------------------------------------- */
 198 /**
 199  * Empty panel creation.
 200  *
 201  * @param panel_name name of panel for setup retieving
 202  *
 203  * @return new instance of WPanel
 204  */
 205 
 206 static inline WPanel *
 207 panel_empty_new (const char *panel_name)
     /* [previous][next][first][last][top][bottom][index][help]  */
 208 {
 209     /* Unknown sizes of the panel at startup */
 210     return panel_sized_empty_new (panel_name, 0, 0, 1, 1);
 211 }
 212 
 213 /* --------------------------------------------------------------------------------------------- */
 214 /**
 215  * Panel creation for specified directory.
 216  *
 217  * @param panel_name name of panel for setup retieving
 218  * @param vpath working panel directory. If NULL then current directory is used
 219  *
 220  * @return new instance of WPanel
 221  */
 222 
 223 static inline WPanel *
 224 panel_with_dir_new (const char *panel_name, const vfs_path_t * vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
 225 {
 226     /* Unknown sizes of the panel at startup */
 227     return panel_sized_with_dir_new (panel_name, 0, 0, 1, 1, vpath);
 228 }
 229 
 230 
 231 /* --------------------------------------------------------------------------------------------- */
 232 /**
 233  * Panel creation.
 234  *
 235  * @param panel_name name of panel for setup retieving
 236  *
 237  * @return new instance of WPanel
 238  */
 239 
 240 static inline WPanel *
 241 panel_new (const char *panel_name)
     /* [previous][next][first][last][top][bottom][index][help]  */
 242 {
 243     return panel_with_dir_new (panel_name, NULL);
 244 }
 245 
 246 /* --------------------------------------------------------------------------------------------- */
 247 /**
 248  * Panel creation with specified size.
 249  *
 250  * @param panel_name name of panel for setup retieving
 251  * @param y y coordinate of top-left corner
 252  * @param x x coordinate of top-left corner
 253  * @param lines vertical size
 254  * @param cols horizontal size
 255  *
 256  * @return new instance of WPanel
 257  */
 258 
 259 static inline WPanel *
 260 panel_sized_new (const char *panel_name, int y, int x, int lines, int cols)
     /* [previous][next][first][last][top][bottom][index][help]  */
 261 {
 262     return panel_sized_with_dir_new (panel_name, y, x, lines, cols, NULL);
 263 }
 264 
 265 /* --------------------------------------------------------------------------------------------- */
 266 
 267 #endif /* MC__PANEL_H */

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