CPGen
C++ project generator
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
Terminal Class Reference

RAII raw-mode terminal handler. More...

#include <Terminal.hpp>

Public Member Functions

 Terminal ()
 Enter raw mode and hide the cursor.
 
 ~Terminal ()
 Restore the original terminal state and show the cursor.
 
 Terminal (const Terminal &)=delete
 Non-copyable.
 
Terminaloperator= (const Terminal &)=delete
 Non-copyable.
 
 Terminal (Terminal &&)=delete
 Non-movable.
 
Terminaloperator= (Terminal &&)=delete
 Non-movable.
 

Detailed Description

RAII raw-mode terminal handler.

Lifecycle

Event Action
Construction Save termios, enable raw mode, hide cursor, install

signal handlers. | | Destruction | Restore termios, show cursor. | | SIGINT/SIGTERM | Restore terminal, call std::_Exit(130). |

Warning
Only one Terminal instance should be alive at a time; the signal handler uses a static copy of the original termios structure.

The class is non-copyable and non-movable to prevent double-restore bugs.

Constructor & Destructor Documentation

◆ Terminal() [1/3]

Terminal::Terminal ( )
inline

Enter raw mode and hide the cursor.

On POSIX: reads the current termios, disables ICANON (line buffering) and ECHO, and applies the modified struct with TCSANOW. On all platforms: hides the cursor with ESC[?25l and installs signal handlers for SIGINT and SIGTERM.

◆ ~Terminal()

Terminal::~Terminal ( )
inline

Restore the original terminal state and show the cursor.

◆ Terminal() [2/3]

Terminal::Terminal ( const Terminal )
delete

Non-copyable.

◆ Terminal() [3/3]

Terminal::Terminal ( Terminal &&  )
delete

Non-movable.

Member Function Documentation

◆ operator=() [1/2]

Terminal & Terminal::operator= ( const Terminal )
delete

Non-copyable.

◆ operator=() [2/2]

Terminal & Terminal::operator= ( Terminal &&  )
delete

Non-movable.


The documentation for this class was generated from the following file: