Debian Codegraph @

src/terms.h

raw
1 #ifndef H_TERMS
2 #define H_TERMS
3 /*
4 terms: terminal specifics
5
6 This is a very lightweight terminal library, just the minimum to
7
8 - get at the width of the terminal (if there is one)
9 - be able to read single keys being pressed for control
10 - maybe also switch off echoing of input
11
12 copyright 2008-2022 by the mpg123 project - free software under the terms of the LGPL 2.1
13 see COPYING and AUTHORS files in distribution or http://mpg123.org
14 initially written by Thomas Orgis and Jonathan Yong
15 */
16
17 /* These two functions query terminal properties based on a terminal
18 being connected to the specified file descriptor (either STDIN_FILENO
19 or STDERR_FILENO). */
20
21 /* Return non-zero if full terminal fun is desired/possible. */
22 int term_have_fun(int fd, int want_visuals);
23
24 /* Return width of terminal associated with given descriptor,
25 -1 when there is none. */
26 int term_width(int fd);
27
28 /*
29 This is for more serious work with the terminal: It is sensible to
30 open some internal handle and continue to operate on that on subsequent
31 calls.
32 */
33
34 /** Setup terminal for control work (things like disabling echo and
35 * buffering. You handle your handles internally.
36 * \return 0 on suceess, -1 on trouble
37 */
38 int term_setup(void);
39
40 /** Restore terminal properties to what they were before we messed
41 * around. Failure is not an option.
42 */
43 void term_restore(void);
44
45 /** Check for and return a key press event.
46 * \param do_delay Wait for up to 10 ms for key event if 1, for 1 ms if -1, without delay for 0.
47 * \param val address to store character to
48 * \return 1 if there is a key, 0 if not
49 */
50 int term_get_key(int stopped, int do_delay, char *val);
51
52 #endif