nngn
Loading...
Searching...
No Matches
nngn::Terminal Class Reference

Handles interactions with the output terminal. More...

#include <terminal.h>

Collaboration diagram for nngn::Terminal:

Public Member Functions

 Terminal (void)=default
 
 ~Terminal (void)
 
auto size (void) const
 Size of the terminal in characters.
 
auto pixel_size (void) const
 Size of the terminal in pixels.
 
bool init (int fd)
 Creates an object for a given TTY.
 
std::tuple< bool, boolupdate_size (void)
 Retrieves the terminal size from the operating system.
 
bool write (std::size_t n, const char *p) const
 Outputs the entire contents of a buffer.
 
bool write (const std::ranges::sized_range auto &v) const
 Outputs the entire contents of a range.
 
bool flush (void) const
 
bool drain (void) const
 
bool show_cursor (void) const
 
bool hide_cursor (void) const
 

Private Attributes

int fd = -1
 OS file descriptor.
 
FILE * f = nullptr
 fdopen(3)ed version of fd.
 
int tty_fd = -1
 File descriptor for the controlling TTY.
 
uvec2 m_size = {}
 Size of the terminal in characters.
 
uvec2 m_pixel_size = {}
 Size of the terminal in screen pixels, if available.
 

Detailed Description

Handles interactions with the output terminal.

Constructor & Destructor Documentation

◆ Terminal()

nngn::Terminal::Terminal ( void )
default

◆ ~Terminal()

nngn::Terminal::~Terminal ( void )
Here is the call graph for this function:

Member Function Documentation

◆ drain()

bool nngn::Terminal::drain ( void ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush()

bool nngn::Terminal::flush ( void ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hide_cursor()

bool nngn::Terminal::hide_cursor ( void ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool nngn::Terminal::init ( int fd)

Creates an object for a given TTY.

Parameters
fdOutput file descriptor, dup(2)ed internally.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pixel_size()

auto nngn::Terminal::pixel_size ( void ) const
inline

Size of the terminal in pixels.

◆ show_cursor()

bool nngn::Terminal::show_cursor ( void ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

auto nngn::Terminal::size ( void ) const
inline

Size of the terminal in characters.

Here is the caller graph for this function:

◆ update_size()

std::tuple< bool, bool > nngn::Terminal::update_size ( void )

Retrieves the terminal size from the operating system.

Returns
{changed, ok}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [1/2]

bool nngn::Terminal::write ( const std::ranges::sized_range auto & v) const

Outputs the entire contents of a range.

Here is the call graph for this function:

◆ write() [2/2]

bool nngn::Terminal::write ( std::size_t n,
const char * p ) const

Outputs the entire contents of a buffer.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ f

FILE* nngn::Terminal::f = nullptr
private

fdopen(3)ed version of fd.

◆ fd

int nngn::Terminal::fd = -1
private

OS file descriptor.

◆ m_pixel_size

uvec2 nngn::Terminal::m_pixel_size = {}
private

Size of the terminal in screen pixels, if available.

◆ m_size

uvec2 nngn::Terminal::m_size = {}
private

Size of the terminal in characters.

◆ tty_fd

int nngn::Terminal::tty_fd = -1
private

File descriptor for the controlling TTY.

Different from fd if !isatty(fd).


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