forked from xwax/xwax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selector.h
72 lines (58 loc) · 2.1 KB
/
selector.h
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
/*
* Copyright (C) 2021 Mark Hills <mark@xwax.org>
*
* This file is part of "xwax".
*
* "xwax" is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 3 as
* published by the Free Software Foundation.
*
* "xwax" 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 <https://www.gnu.org/licenses/>.
*
*/
#ifndef SELECTOR_H
#define SELECTOR_H
#include <stdbool.h>
#include "library.h"
#include "listbox.h"
#include "index.h"
struct selector {
struct library *library;
struct index
*view_index, /* base_index + search filter applied */
*swap_index, /* used to swap between a and b indexes */
index_a, index_b;
struct listbox records, crates;
bool toggled;
int toggle_back, sort;
struct record *target;
struct observer on_activity, on_refresh, on_addition;
size_t search_len;
char search[256];
struct match match; /* the compiled search, kept in-sync */
struct event changed;
};
void selector_init(struct selector *sel, struct library *lib);
void selector_clear(struct selector *sel);
void selector_set_lines(struct selector *sel, unsigned int lines);
void selector_up(struct selector *sel);
void selector_down(struct selector *sel);
void selector_page_up(struct selector *sel);
void selector_page_down(struct selector *sel);
void selector_top(struct selector *sel);
void selector_bottom(struct selector *sel);
struct record* selector_current(struct selector *sel);
void selector_prev(struct selector *sel);
void selector_next(struct selector *sel);
void selector_toggle(struct selector *sel);
void selector_toggle_order(struct selector *sel);
void selector_rescan(struct selector *sel);
void selector_search_expand(struct selector *sel);
void selector_search_refine(struct selector *sel, char key);
#endif