1 /* 2 * Samba Unix/Linux SMB client library 3 * Registry Editor 4 * Copyright (C) Christopher Davis 2014 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef _REGEDIT_LIST_H_ 21 #define _REGEDIT_LIST_H_ 22 23 #include "includes.h" 24 #include <ncurses.h> 25 26 struct multilist_accessors { 27 /* (optional) return the column header for col */ 28 const char *(*get_column_header)(const void *data, unsigned col); 29 30 /* return a pointer to the first row of data */ 31 const void *(*get_first_row)(const void *data); 32 33 /* (optional) return a count of all data rows */ 34 size_t (*get_row_count)(const void *data); 35 36 /* return the next row or NULL if there aren't any more */ 37 const void *(*get_next_row)(const void *data, const void *row); 38 39 /* (optional) return the previous row or NULL if row is on top. */ 40 const void *(*get_prev_row)(const void *data, const void *row); 41 42 /* (optional) return row n of data */ 43 const void *(*get_row_n)(const void *data, size_t n); 44 45 /* return the label for row and col */ 46 const char *(*get_item_label)(const void *row, unsigned col); 47 48 /* (optional) return a prefix string to be prepended to an item's 49 label. */ 50 const char *(*get_item_prefix)(const void *row, unsigned col); 51 }; 52 53 struct multilist_column { 54 size_t width; 55 unsigned int align_right:1; 56 }; 57 58 struct multilist; 59 60 struct multilist *multilist_new(TALLOC_CTX *ctx, WINDOW *window, 61 const struct multilist_accessors *cb, 62 unsigned ncol); 63 struct multilist_column *multilist_column_config(struct multilist *list, 64 unsigned col); 65 WERROR multilist_set_window(struct multilist *list, WINDOW *window); 66 const void *multilist_get_data(struct multilist *list); 67 WERROR multilist_set_data(struct multilist *list, const void *data); 68 void multilist_refresh(struct multilist *list); 69 70 enum { 71 ML_CURSOR_UP, 72 ML_CURSOR_DOWN, 73 ML_CURSOR_PGUP, 74 ML_CURSOR_PGDN, 75 ML_CURSOR_HOME, 76 ML_CURSOR_END 77 }; 78 void multilist_driver(struct multilist *list, int c); 79 const void *multilist_get_current_row(struct multilist *list); 80 void multilist_set_current_row(struct multilist *list, const void *row); 81 82 #endif 83