diff options
Diffstat (limited to 'apps/plugins/lib/printcell_helper.h')
-rw-r--r-- | apps/plugins/lib/printcell_helper.h | 68 |
1 files changed, 55 insertions, 13 deletions
diff --git a/apps/plugins/lib/printcell_helper.h b/apps/plugins/lib/printcell_helper.h index adc98e5a5f..f58e73c0a5 100644 --- a/apps/plugins/lib/printcell_helper.h +++ b/apps/plugins/lib/printcell_helper.h @@ -21,25 +21,67 @@ #ifndef _PRINTCELL_LIST_H_ #define _PRINTCELL_LIST_H_ +#ifndef PRINTCELL_MAX_COLUMNS +#define PRINTCELL_MAX_COLUMNS 16 /* Max 32 (hidecol_flags)*/ +#endif + #define PRINTCELL_MAXLINELEN MAX_PATH +#define PC_COL_FLAG(col) ((uint32_t)(col >= 0 \ + && col < PRINTCELL_MAX_COLUMNS) ? 1u<<col : -1u) + +#define PRINTCELL_COLUMN_IS_VISIBLE(flag, col) ((flag & PC_COL_FLAG(col)) == 0) +#define PRINTCELL_COLUMN_FLAG(col) (PC_COL_FLAG(col)) -/* sets the printcell function enabled */ -void printcell_enable(struct gui_synclist *gui_list, bool enable, bool separator); +struct printcell_settings +{ + bool cell_separator; + char title_delimeter; + char text_delimeter; + uint32_t hidecol_flags; +}; -/* sets title and calculates cell widths each column is identified by '$' character - ex 3 columns title = "Col1$Col2$Col3" also accepts $*WIDTH$ - ex 3 columns varying width title = "$*64$Col1$*128$Col2$Col3 - returns number of columns +/* Printcell initialization - Sets title and calculates cell widths +* by default each column is identified by '$' character +* ex 3 columns title = "Col1$Col2$Col3" also accepts $*WIDTH$ +* ex 3 columns varying width title = "$*64$Col1$*128$Col2$Col3 +* supplying struct printcell_settings pcs allows changing default settings +* supply NULL to use defaults +* +* Returns number of columns */ -int printcell_set_columns(struct gui_synclist *gui_list, - char * title, enum themable_icons icon); +int printcell_set_columns(struct gui_synclist *gui_list, + struct printcell_settings * pcs, + char * title, enum themable_icons icon); + +/* Sets the printcell function enabled (use after initializing with set_column) + * Note you should call printcell_enable(false) if the list might be reused */ +void printcell_enable(bool enable); -/* increments the current selected column negative increment is allowed - returns the selected column +/* Increments the current selected column negative increment is allowed + returns the selected column range: -1(no selection) to ncols - 1 */ -int printcell_increment_column(struct gui_synclist *gui_list, int increment, bool wrap); +int printcell_increment_column(int increment, bool wrap); + +/* Return index of the currently selected column (-1 to ncols - 1) */ +int printcell_get_column_selected(void); + +/* Return the text of currently selected column buffer should be sized + * for max item len, buf[PRINTCELL_MAXLINELEN] is a safe bet */ +char *printcell_get_column_text(int selcol, char *buf, size_t bufsz); -/* return the text of currently selected column buffer should be sized +/* Return the text of currently selected column title should be sized * for max item len, buf[PRINTCELL_MAXLINELEN] is a safe bet */ -char *printcell_get_selected_column_text(struct gui_synclist *gui_list, char *buf, size_t bufsz); +char *printcell_get_title_text(int selcol, char *buf, size_t bufsz); + + +/* Hide or show a specified column - supply col = -1 to affect all columns */ +void printcell_set_column_visible(int col, bool visible); + +/* Return visibility of a specified column +* returns (1 visible or 0 hidden) +* if supply col == -1 a flag with visibility of all columns will be returned +* NOTE: flag denotes a hidden column by a 1 in the column bit (1 << col#) +* PRINTCELL_COLUMN_IS_VISIBLE(flag,col) macro will convert to bool +*/ +uint32_t printcell_get_column_visibility(int col); #endif /*_PRINTCELL_LIST_H_*/ |