CPGen
C++ project generator
Loading...
Searching...
No Matches
Classes
Terminal.hpp File Reference

RAII wrapper that manages terminal raw mode for the TUI. More...

#include <termios.h>
#include <unistd.h>
#include <csignal>
#include <cstdio>
#include <cstdlib>
Include dependency graph for Terminal.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Terminal
 RAII raw-mode terminal handler. More...
 

Detailed Description

RAII wrapper that manages terminal raw mode for the TUI.

Author
Darleanow

Constructing a Terminal puts stdin into raw mode (no line buffering, no echo) so that key presses can be read one character at a time. The destructor unconditionally restores the original terminal settings.

Signal handlers for SIGINT and SIGTERM are installed to guarantee that the terminal is restored even when the user presses Ctrl+C or the process is killed externally.