Browse code

Add extern C

Ben Judd authored on 03/01/2024 16:38:45
Showing 1 changed files
... ...
@@ -1,8 +1,14 @@
1 1
 #ifndef TTY_H
2 2
 #define TTY_H TTY_H
3 3
 
4
+#include <stddef.h>
5
+#include <stdio.h>
4 6
 #include <termios.h>
5 7
 
8
+#ifdef __cplusplus 
9
+extern "C" {
10
+#endif
11
+
6 12
 typedef struct {
7 13
 	int fdin;
8 14
 	FILE *fout;
... ...
@@ -57,4 +63,8 @@ void tty_flush(tty_t *tty);
57 63
 size_t tty_getwidth(tty_t *tty);
58 64
 size_t tty_getheight(tty_t *tty);
59 65
 
66
+#ifdef __cplusplus
67
+}
68
+#endif
69
+
60 70
 #endif
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
... ...
@@ -51,6 +51,7 @@ void tty_moveup(tty_t *tty, int i);
51 51
 void tty_setcol(tty_t *tty, int col);
52 52
 
53 53
 void tty_printf(tty_t *tty, const char *fmt, ...);
54
+void tty_putc(tty_t *tty, char c);
54 55
 void tty_flush(tty_t *tty);
55 56
 
56 57
 size_t tty_getwidth(tty_t *tty);
Browse code

Allow -1 timeout to mean infinite

John Hawthorn authored on 16/09/2018 00:15:42
Showing 1 changed files
... ...
@@ -17,7 +17,7 @@ void tty_close(tty_t *tty);
17 17
 void tty_init(tty_t *tty, const char *tty_filename);
18 18
 void tty_getwinsz(tty_t *tty);
19 19
 char tty_getchar(tty_t *tty);
20
-int tty_input_ready(tty_t *tty, int timeout, int return_on_signal);
20
+int tty_input_ready(tty_t *tty, long int timeout, int return_on_signal);
21 21
 
22 22
 void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
Browse code

Allow masking signals in tty_input_ready

John Hawthorn authored on 15/09/2018 21:15:28
Showing 1 changed files
... ...
@@ -17,7 +17,7 @@ void tty_close(tty_t *tty);
17 17
 void tty_init(tty_t *tty, const char *tty_filename);
18 18
 void tty_getwinsz(tty_t *tty);
19 19
 char tty_getchar(tty_t *tty);
20
-int tty_input_ready(tty_t *tty, unsigned long timeout);
20
+int tty_input_ready(tty_t *tty, int timeout, int return_on_signal);
21 21
 
22 22
 void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
Browse code

Pass a timeout to tty_input_ready

John Hawthorn authored on 15/09/2018 20:55:10
Showing 1 changed files
... ...
@@ -17,7 +17,7 @@ void tty_close(tty_t *tty);
17 17
 void tty_init(tty_t *tty, const char *tty_filename);
18 18
 void tty_getwinsz(tty_t *tty);
19 19
 char tty_getchar(tty_t *tty);
20
-int tty_input_ready(tty_t *tty, int pending);
20
+int tty_input_ready(tty_t *tty, unsigned long timeout);
21 21
 
22 22
 void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
Browse code

Merge branch 'abort_on_escape'

John Hawthorn authored on 10/09/2018 04:02:45
Showing 0 changed files
Browse code

Add sequence to disable line wrap

John Hawthorn authored on 09/09/2018 19:53:08
Showing 1 changed files
... ...
@@ -23,6 +23,8 @@ void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
24 24
 void tty_setunderline(tty_t *tty);
25 25
 void tty_setnormal(tty_t *tty);
26
+void tty_setnowrap(tty_t *tty);
27
+void tty_setwrap(tty_t *tty);
26 28
 
27 29
 #define TTY_COLOR_BLACK 0
28 30
 #define TTY_COLOR_RED 1
Browse code

Add support for underlining selected item

Michael Mackus authored on 18/07/2018 21:54:22
Showing 1 changed files
... ...
@@ -21,6 +21,7 @@ int tty_input_ready(tty_t *tty);
21 21
 
22 22
 void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
24
+void tty_setunderline(tty_t *tty);
24 25
 void tty_setnormal(tty_t *tty);
25 26
 
26 27
 #define TTY_COLOR_BLACK 0
Browse code

Abort if Esc is pressed

Jason Felice authored on 04/05/2018 16:32:40
Showing 1 changed files
... ...
@@ -17,7 +17,7 @@ void tty_close(tty_t *tty);
17 17
 void tty_init(tty_t *tty, const char *tty_filename);
18 18
 void tty_getwinsz(tty_t *tty);
19 19
 char tty_getchar(tty_t *tty);
20
-int tty_input_ready(tty_t *tty);
20
+int tty_input_ready(tty_t *tty, int pending);
21 21
 
22 22
 void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
Browse code

Batch together input for searches

John Hawthorn authored on 21/06/2016 06:29:15
Showing 1 changed files
... ...
@@ -17,6 +17,7 @@ void tty_close(tty_t *tty);
17 17
 void tty_init(tty_t *tty, const char *tty_filename);
18 18
 void tty_getwinsz(tty_t *tty);
19 19
 char tty_getchar(tty_t *tty);
20
+int tty_input_ready(tty_t *tty);
20 21
 
21 22
 void tty_setfg(tty_t *tty, int fg);
22 23
 void tty_setinvert(tty_t *tty);
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,55 @@
1
+#ifndef TTY_H
2
+#define TTY_H TTY_H
3
+
4
+#include <termios.h>
5
+
6
+typedef struct {
7
+	int fdin;
8
+	FILE *fout;
9
+	struct termios original_termios;
10
+	int fgcolor;
11
+	size_t maxwidth;
12
+	size_t maxheight;
13
+} tty_t;
14
+
15
+void tty_reset(tty_t *tty);
16
+void tty_close(tty_t *tty);
17
+void tty_init(tty_t *tty, const char *tty_filename);
18
+void tty_getwinsz(tty_t *tty);
19
+char tty_getchar(tty_t *tty);
20
+
21
+void tty_setfg(tty_t *tty, int fg);
22
+void tty_setinvert(tty_t *tty);
23
+void tty_setnormal(tty_t *tty);
24
+
25
+#define TTY_COLOR_BLACK 0
26
+#define TTY_COLOR_RED 1
27
+#define TTY_COLOR_GREEN 2
28
+#define TTY_COLOR_YELLOW 3
29
+#define TTY_COLOR_BLUE 4
30
+#define TTY_COLOR_MAGENTA 5
31
+#define TTY_COLOR_CYAN 6
32
+#define TTY_COLOR_WHITE 7
33
+#define TTY_COLOR_NORMAL 9
34
+
35
+/* tty_newline
36
+ * Move cursor to the beginning of the next line, clearing to the end of the
37
+ * current line
38
+ */
39
+void tty_newline(tty_t *tty);
40
+
41
+/* tty_clearline
42
+ * Clear to the end of the current line without advancing the cursor.
43
+ */
44
+void tty_clearline(tty_t *tty);
45
+
46
+void tty_moveup(tty_t *tty, int i);
47
+void tty_setcol(tty_t *tty, int col);
48
+
49
+void tty_printf(tty_t *tty, const char *fmt, ...);
50
+void tty_flush(tty_t *tty);
51
+
52
+size_t tty_getwidth(tty_t *tty);
53
+size_t tty_getheight(tty_t *tty);
54
+
55
+#endif