summaryrefslogtreecommitdiffstats
path: root/source3/utils/regedit_list.h
blob: abd6ffd23e6f13bb230692695d5dd72783080f33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Samba Unix/Linux SMB client library
 * Registry Editor
 * Copyright (C) Christopher Davis 2014
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _REGEDIT_LIST_H_
#define _REGEDIT_LIST_H_

#include "includes.h"
#include <ncurses.h>

struct multilist_accessors {
	/* (optional) return the column header for col */
	const char *(*get_column_header)(const void *data, unsigned col);

	/* return a pointer to the first row of data */
	const void *(*get_first_row)(const void *data);

	/* (optional) return a count of all data rows */
	size_t (*get_row_count)(const void *data);

	/* return the next row or NULL if there aren't any more */
	const void *(*get_next_row)(const void *data, const void *row);

	/* (optional) return the previous row or NULL if row is on top. */
	const void *(*get_prev_row)(const void *data, const void *row);

	/* (optional) return row n of data */
	const void *(*get_row_n)(const void *data, size_t n);

	/* return the label for row and col */
	const char *(*get_item_label)(const void *row, unsigned col);

	/* (optional) return a prefix string to be prepended to an item's
	   label. */
	const char *(*get_item_prefix)(const void *row, unsigned col);
};

struct multilist_column {
	size_t width;
	unsigned int align_right:1;
};

struct multilist;

struct multilist *multilist_new(TALLOC_CTX *ctx, WINDOW *window,
				const struct multilist_accessors *cb,
				unsigned ncol);
struct multilist_column *multilist_column_config(struct multilist *list,
						 unsigned col);
WERROR multilist_set_window(struct multilist *list, WINDOW *window);
const void *multilist_get_data(struct multilist *list);
WERROR multilist_set_data(struct multilist *list, const void *data);
void multilist_refresh(struct multilist *list);

enum {
	ML_CURSOR_UP,
	ML_CURSOR_DOWN,
	ML_CURSOR_PGUP,
	ML_CURSOR_PGDN,
	ML_CURSOR_HOME,
	ML_CURSOR_END
};
void multilist_driver(struct multilist *list, int c);
const void *multilist_get_current_row(struct multilist *list);
void multilist_set_current_row(struct multilist *list, const void *row);

#endif