fe
terminal file explorer and picker
git clone https://9o.is/git/fe.git
tty.h
(1127B)
1 #ifndef TTY_H
2 #define TTY_H TTY_H
3
4 #include <stddef.h>
5 #include <stdio.h>
6 #include <termios.h>
7
8 typedef struct {
9 int fdin;
10 FILE *fout;
11 struct termios original_termios;
12 int fgcolor;
13 size_t maxwidth;
14 size_t maxheight;
15 } tty_t;
16
17 void tty_close(tty_t *tty);
18 void tty_init(tty_t *tty, const char *tty_filename);
19 char tty_getchar(const tty_t *tty);
20 int tty_input_ready(const tty_t *tty, long int timeout, int return_on_signal);
21
22 void tty_setfg(tty_t *tty, int fg);
23 void tty_setinvert(tty_t *tty);
24 void tty_setnormal(tty_t *tty);
25 void tty_title(tty_t *tty, char *title);
26
27 /* tty_newline
28 * Move cursor to the beginning of the next line, clearing to the end of the
29 * current line
30 */
31 void tty_newline(tty_t *tty);
32
33 /* tty_clearline
34 * Clear to the end of the current line without advancing the cursor.
35 */
36 void tty_clearline(tty_t *tty);
37
38 void tty_moveup(tty_t *tty, int i);
39 void tty_setcol(tty_t *tty, int col);
40 void tty_printf(tty_t *tty, const char *fmt, ...);
41 void tty_flush(tty_t *tty);
42 size_t tty_getheight(const tty_t *tty);
43 void tty_hide_cursor(tty_t *tty);
44 void tty_unhide_cursor(tty_t *tty);
45
46 #endif