| ... | ... |
@@ -6,6 +6,10 @@ |
| 6 | 6 |
#include "match.h" |
| 7 | 7 |
#include "options.h" |
| 8 | 8 |
|
| 9 |
+#ifdef __cplusplus |
|
| 10 |
+extern "C" {
|
|
| 11 |
+#endif |
|
| 12 |
+ |
|
| 9 | 13 |
struct scored_result {
|
| 10 | 14 |
score_t score; |
| 11 | 15 |
const char *str; |
| ... | ... |
@@ -38,4 +42,8 @@ score_t choices_getscore(choices_t *c, size_t n); |
| 38 | 42 |
void choices_prev(choices_t *c); |
| 39 | 43 |
void choices_next(choices_t *c); |
| 40 | 44 |
|
| 45 |
+#ifdef __cplusplus |
|
| 46 |
+} |
|
| 47 |
+#endif |
|
| 48 |
+ |
|
| 41 | 49 |
#endif |
| ... | ... |
@@ -25,11 +25,10 @@ typedef struct {
|
| 25 | 25 |
size_t selection; |
| 26 | 26 |
|
| 27 | 27 |
unsigned int worker_count; |
| 28 |
- char input_delimiter; |
|
| 29 | 28 |
} choices_t; |
| 30 | 29 |
|
| 31 | 30 |
void choices_init(choices_t *c, options_t *options); |
| 32 |
-void choices_fread(choices_t *c, FILE *file); |
|
| 31 |
+void choices_fread(choices_t *c, FILE *file, char input_delimiter); |
|
| 33 | 32 |
void choices_destroy(choices_t *c); |
| 34 | 33 |
void choices_add(choices_t *c, const char *choice); |
| 35 | 34 |
size_t choices_available(choices_t *c); |
Update tty to print newline as space
Add tty_putc
| ... | ... |
@@ -4,6 +4,7 @@ |
| 4 | 4 |
#include <stdio.h> |
| 5 | 5 |
|
| 6 | 6 |
#include "match.h" |
| 7 |
+#include "options.h" |
|
| 7 | 8 |
|
| 8 | 9 |
struct scored_result {
|
| 9 | 10 |
score_t score; |
| ... | ... |
@@ -26,7 +27,7 @@ typedef struct {
|
| 26 | 27 |
unsigned int worker_count; |
| 27 | 28 |
} choices_t; |
| 28 | 29 |
|
| 29 |
-void choices_init(choices_t *c); |
|
| 30 |
+void choices_init(choices_t *c, options_t *options); |
|
| 30 | 31 |
void choices_fread(choices_t *c, FILE *file); |
| 31 | 32 |
void choices_destroy(choices_t *c); |
| 32 | 33 |
void choices_add(choices_t *c, const char *choice); |
| ... | ... |
@@ -3,8 +3,10 @@ |
| 3 | 3 |
|
| 4 | 4 |
#include <stdio.h> |
| 5 | 5 |
|
| 6 |
+#include "match.h" |
|
| 7 |
+ |
|
| 6 | 8 |
struct scored_result {
|
| 7 |
- double score; |
|
| 9 |
+ score_t score; |
|
| 8 | 10 |
const char *str; |
| 9 | 11 |
}; |
| 10 | 12 |
|
| ... | ... |
@@ -31,7 +33,7 @@ void choices_add(choices_t *c, const char *choice); |
| 31 | 33 |
size_t choices_available(choices_t *c); |
| 32 | 34 |
void choices_search(choices_t *c, const char *search); |
| 33 | 35 |
const char *choices_get(choices_t *c, size_t n); |
| 34 |
-double choices_getscore(choices_t *c, size_t n); |
|
| 36 |
+score_t choices_getscore(choices_t *c, size_t n); |
|
| 35 | 37 |
void choices_prev(choices_t *c); |
| 36 | 38 |
void choices_next(choices_t *c); |
| 37 | 39 |
|
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,36 @@ |
| 1 |
+#ifndef CHOICES_H |
|
| 2 |
+#define CHOICES_H CHOICES_H |
|
| 3 |
+ |
|
| 4 |
+#include <stdio.h> |
|
| 5 |
+ |
|
| 6 |
+struct scored_result {
|
|
| 7 |
+ double score; |
|
| 8 |
+ const char *str; |
|
| 9 |
+}; |
|
| 10 |
+ |
|
| 11 |
+typedef struct {
|
|
| 12 |
+ char *buffer; |
|
| 13 |
+ size_t buffer_size; |
|
| 14 |
+ |
|
| 15 |
+ size_t capacity; |
|
| 16 |
+ size_t size; |
|
| 17 |
+ |
|
| 18 |
+ const char **strings; |
|
| 19 |
+ struct scored_result *results; |
|
| 20 |
+ |
|
| 21 |
+ size_t available; |
|
| 22 |
+ size_t selection; |
|
| 23 |
+} choices_t; |
|
| 24 |
+ |
|
| 25 |
+void choices_init(choices_t *c); |
|
| 26 |
+void choices_fread(choices_t *c, FILE *file); |
|
| 27 |
+void choices_destroy(choices_t *c); |
|
| 28 |
+void choices_add(choices_t *c, const char *choice); |
|
| 29 |
+size_t choices_available(choices_t *c); |
|
| 30 |
+void choices_search(choices_t *c, const char *search); |
|
| 31 |
+const char *choices_get(choices_t *c, size_t n); |
|
| 32 |
+double choices_getscore(choices_t *c, size_t n); |
|
| 33 |
+void choices_prev(choices_t *c); |
|
| 34 |
+void choices_next(choices_t *c); |
|
| 35 |
+ |
|
| 36 |
+#endif |