diff options
| author | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
|---|---|---|
| committer | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
| commit | b3e9e62599532050fc776c5e8f076915b56c2235 (patch) | |
| tree | af252346106a61b18cc6fc6fdbd32e962d096f1c /termin.h | |
Import official C23 code examples for Modern C (Jens Gustedt, 2024)HEADupstream-importmain
- Add official C source files, Makefile, c23-fallback.h, and LICENSE
- Update README.md with study mirror notice
Diffstat (limited to 'termin.h')
| -rw-r--r-- | termin.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/termin.h b/termin.h new file mode 100644 index 0000000..c6ae98d --- /dev/null +++ b/termin.h @@ -0,0 +1,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 |
