Browse code

Add extern C

Ben Judd authored on 03/01/2024 16:38:45
Showing 1 changed files
... ...
@@ -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
Browse code

Simplify input_delimiter handling

John Hawthorn authored on 16/08/2019 08:09:29
Showing 1 changed files
... ...
@@ -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);
Browse code

Add ability to use null as input delimiter.

Update tty to print newline as space
Add tty_putc

Ashkan Kiani authored on 03/05/2019 10:30:13 • John Hawthorn committed on 16/08/2019 08:05:01
Showing 1 changed files
... ...
@@ -25,6 +25,7 @@ typedef struct {
25 25
 	size_t selection;
26 26
 
27 27
 	unsigned int worker_count;
28
+	char input_delimiter;
28 29
 } choices_t;
29 30
 
30 31
 void choices_init(choices_t *c, options_t *options);
Browse code

Pass options to choices_init

John Hawthorn authored on 01/02/2017 02:06:42
Showing 1 changed files
... ...
@@ -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);
Browse code

Use score_t instead of double

John Hawthorn authored on 27/06/2016 08:14:44
Showing 1 changed files
... ...
@@ -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
 
Browse code

Store worker_count on choices_t

John Hawthorn authored on 23/06/2016 04:26:21
Showing 1 changed files
... ...
@@ -20,6 +20,8 @@ typedef struct {
20 20
 
21 21
 	size_t available;
22 22
 	size_t selection;
23
+
24
+	unsigned int worker_count;
23 25
 } choices_t;
24 26
 
25 27
 void choices_init(choices_t *c);
Browse code

Move sources into src directory

John Hawthorn authored on 21/05/2016 21:56:03
Showing 1 changed files
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