← Back to davo.co
summaryrefslogtreecommitdiffstats
path: root/termin.h
blob: c6ae98dab9939060cfeac93ddbcd0c29cbd3cd45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef TERMIN_H
#define TERMIN_H 1

#include "c23-fallback.h"
#include "esc.h"

/**
 ** @brief Set a terminal on stdin to raw mode.
 **
 ** This uses termios.h underneath, so it probably only works on POSIX
 ** systems.
 **
 ** The terminal is automatically reset to its original state on @c
 ** exit or @c quick_exit by means of ::termin_reset.
 **/
void termin_unbuffered(void);

/**
 ** @brief Reset the terminal to its original state.
 **/
void termin_reset(void);

/**
 ** @brief The translation table for escape sequences.
 **
 ** An application that wants to use this module has to provide this
 ** symbol.
 **
 ** @see ::termin_translate
 **/
extern char const*const termin_trans[UCHAR_MAX+1];

/**
 ** @brief Translate and escape sequence to a simple character.
 **
 ** This supposes that you assign a simple character for each escape
 ** sequence that you want to translate.
 **
 ** If an exact match for an escape sequence is fount in
 ** ::termin_trans, its position in the table is the translation.
 **
 ** @see ::termin_trans
 **/
char termin_translate(char const* command);

/**
 ** @brief Read an escape sequence into @a command.
 **
 ** This reads from @c stdin and supposes that the escape character is
 ** already stored in @c command[0].
 **/
char const* termin_read_esc(size_t len, char command[len]);

#endif