| ... | ... |
@@ -5,6 +5,10 @@ |
| 5 | 5 |
#include "options.h" |
| 6 | 6 |
#include "tty.h" |
| 7 | 7 |
|
| 8 |
+#ifdef __cplusplus |
|
| 9 |
+extern "C" {
|
|
| 10 |
+#endif |
|
| 11 |
+ |
|
| 8 | 12 |
#define SEARCH_SIZE_MAX 4096 |
| 9 | 13 |
|
| 10 | 14 |
typedef struct {
|
| ... | ... |
@@ -25,4 +29,8 @@ typedef struct {
|
| 25 | 29 |
void tty_interface_init(tty_interface_t *state, tty_t *tty, choices_t *choices, options_t *options); |
| 26 | 30 |
int tty_interface_run(tty_interface_t *state); |
| 27 | 31 |
|
| 32 |
+#ifdef __cplusplus |
|
| 33 |
+} |
|
| 34 |
+#endif |
|
| 35 |
+ |
|
| 28 | 36 |
#endif |
Index the cursor from the beginning instead of the end, which is easier
(at least for me) to think about.
This also fixes issues with Ctrl-W in the previous implementation.
This allows us to avoid explicitly calling out to choices_search
| ... | ... |
@@ -13,9 +13,11 @@ typedef struct {
|
| 13 | 13 |
options_t *options; |
| 14 | 14 |
|
| 15 | 15 |
char search[SEARCH_SIZE_MAX + 1]; |
| 16 |
+ |
|
| 17 |
+ int exit; |
|
| 16 | 18 |
} tty_interface_t; |
| 17 | 19 |
|
| 18 | 20 |
void tty_interface_init(tty_interface_t *state, tty_t *tty, choices_t *choices, options_t *options); |
| 19 |
-void tty_interface_run(tty_interface_t *state); |
|
| 21 |
+int tty_interface_run(tty_interface_t *state); |
|
| 20 | 22 |
|
| 21 | 23 |
#endif |
| ... | ... |
@@ -7,6 +7,15 @@ |
| 7 | 7 |
|
| 8 | 8 |
#define SEARCH_SIZE_MAX 4096 |
| 9 | 9 |
|
| 10 |
-void tty_interface_run(tty_t *tty, choices_t *choices, options_t *options); |
|
| 10 |
+typedef struct {
|
|
| 11 |
+ tty_t *tty; |
|
| 12 |
+ choices_t *choices; |
|
| 13 |
+ options_t *options; |
|
| 14 |
+ |
|
| 15 |
+ char search[SEARCH_SIZE_MAX + 1]; |
|
| 16 |
+} tty_interface_t; |
|
| 17 |
+ |
|
| 18 |
+void tty_interface_init(tty_interface_t *state, tty_t *tty, choices_t *choices, options_t *options); |
|
| 19 |
+void tty_interface_run(tty_interface_t *state); |
|
| 11 | 20 |
|
| 12 | 21 |
#endif |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,12 @@ |
| 1 |
+#ifndef TTY_INTERFACE_H |
|
| 2 |
+#define TTY_INTERFACE_H TTY_INTERFACE_H |
|
| 3 |
+ |
|
| 4 |
+#include "choices.h" |
|
| 5 |
+#include "options.h" |
|
| 6 |
+#include "tty.h" |
|
| 7 |
+ |
|
| 8 |
+#define SEARCH_SIZE_MAX 4096 |
|
| 9 |
+ |
|
| 10 |
+void tty_interface_run(tty_t *tty, choices_t *choices, options_t *options); |
|
| 11 |
+ |
|
| 12 |
+#endif |