Browse code

Add extern C

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

Abort if Esc is pressed

Jason Felice authored on 04/05/2018 16:32:40
Showing 1 changed files
... ...
@@ -16,6 +16,7 @@ typedef struct {
16 16
 	char last_search[SEARCH_SIZE_MAX + 1];
17 17
 	size_t cursor;
18 18
 
19
+	int ambiguous_key_pending;
19 20
 	char input[32]; /* Pending input buffer */
20 21
 
21 22
 	int exit;
Browse code

Rewrite cursor implementation

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.

John Hawthorn authored on 16/10/2017 06:32:41
Showing 1 changed files
... ...
@@ -14,7 +14,7 @@ typedef struct {
14 14
 
15 15
 	char search[SEARCH_SIZE_MAX + 1];
16 16
 	char last_search[SEARCH_SIZE_MAX + 1];
17
-	int offset;
17
+	size_t cursor;
18 18
 
19 19
 	char input[32]; /* Pending input buffer */
20 20
 
Browse code

Support arrow key movements

Keith Smiley authored on 22/07/2017 03:58:04
Showing 1 changed files
... ...
@@ -14,6 +14,7 @@ typedef struct {
14 14
 
15 15
 	char search[SEARCH_SIZE_MAX + 1];
16 16
 	char last_search[SEARCH_SIZE_MAX + 1];
17
+	int offset;
17 18
 
18 19
 	char input[32]; /* Pending input buffer */
19 20
 
Browse code

Use a struct to store keybindings

John Hawthorn authored on 20/06/2016 08:45:09
Showing 1 changed files
... ...
@@ -15,6 +15,8 @@ typedef struct {
15 15
 	char search[SEARCH_SIZE_MAX + 1];
16 16
 	char last_search[SEARCH_SIZE_MAX + 1];
17 17
 
18
+	char input[32]; /* Pending input buffer */
19
+
18 20
 	int exit;
19 21
 } tty_interface_t;
20 22
 
Browse code

Track last search

This allows us to avoid explicitly calling out to choices_search

John Hawthorn authored on 20/06/2016 06:58:44
Showing 1 changed files
... ...
@@ -13,6 +13,7 @@ typedef struct {
13 13
 	options_t *options;
14 14
 
15 15
 	char search[SEARCH_SIZE_MAX + 1];
16
+	char last_search[SEARCH_SIZE_MAX + 1];
16 17
 
17 18
 	int exit;
18 19
 } tty_interface_t;
Browse code

Return exit code from run

John Hawthorn authored on 20/06/2016 06:36:39
Showing 1 changed files
... ...
@@ -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
Browse code

Store state in tty_interface_t

John Hawthorn authored on 20/06/2016 06:17:53
Showing 1 changed files
... ...
@@ -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
Browse code

Extract tty interface to own file

John Hawthorn authored on 20/06/2016 06:08:00
Showing 1 changed files
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