fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
choices.h
(1175B)
1 #ifndef CHOICES_H
2 #define CHOICES_H CHOICES_H
3
4 #include <stdio.h>
5
6 #include "match.h"
7 #include "options.h"
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 struct scored_result {
14 score_t score;
15 const char *str;
16 size_t index;
17 };
18
19 typedef struct {
20 char *buffer;
21 size_t buffer_size;
22
23 size_t capacity;
24 size_t size;
25
26 const char **strings;
27 struct scored_result *results;
28
29 size_t available;
30 size_t selection;
31
32 unsigned char *multiselections;
33 size_t multiselection_size;
34
35 unsigned int worker_count;
36 } choices_t;
37
38 void choices_init(choices_t *c, options_t *options);
39 void choices_fread(choices_t *c, FILE *file, char input_delimiter);
40 void choices_destroy(choices_t *c);
41 void choices_add(choices_t *c, const char *choice);
42 size_t choices_available(choices_t *c);
43 void choices_search(choices_t *c, const char *search);
44 const char *choices_get(choices_t *c, size_t n);
45 const char *choices_getmulti(choices_t *c, size_t n);
46 score_t choices_getscore(choices_t *c, size_t n);
47 void choices_prev(choices_t *c);
48 void choices_next(choices_t *c);
49 void choices_multiselect_toggle(choices_t *c);
50 size_t choices_selected(choices_t *c, size_t n);
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif