choices.h (870B)
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 struct scored_result { 10 score_t score; 11 const char *str; 12 }; 13 14 typedef struct { 15 char *buffer; 16 size_t buffer_size; 17 18 size_t capacity; 19 size_t size; 20 21 const char **strings; 22 struct scored_result *results; 23 24 size_t available; 25 size_t selection; 26 27 unsigned int worker_count; 28 } choices_t; 29 30 void choices_init(choices_t *c, options_t *options); 31 void choices_fread(choices_t *c, FILE *file, char input_delimiter); 32 void choices_destroy(choices_t *c); 33 void choices_add(choices_t *c, const char *choice); 34 size_t choices_available(choices_t *c); 35 void choices_search(choices_t *c, const char *search); 36 const char *choices_get(choices_t *c, size_t n); 37 score_t choices_getscore(choices_t *c, size_t n); 38 void choices_prev(choices_t *c); 39 void choices_next(choices_t *c); 40 41 #endif