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
 
 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() [1/2]

nngn::Terminal::Terminal ( void  )
default

◆ ~Terminal() [1/2]

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

◆ Terminal() [2/2]

nngn::Terminal::Terminal ( void  )
default

◆ ~Terminal() [2/2]

nngn::Terminal::~Terminal ( void  )

Member Function Documentation

◆ drain() [1/2]

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

◆ drain() [2/2]

bool nngn::Terminal::drain ( void  ) const

◆ flush() [1/2]

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

◆ flush() [2/2]

bool nngn::Terminal::flush ( void  ) const

◆ hide_cursor() [1/2]

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

◆ hide_cursor() [2/2]

bool nngn::Terminal::hide_cursor ( void  ) const

◆ init() [1/2]

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:

◆ init() [2/2]

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

Creates an object for a given TTY.

Parameters
fdOutput file descriptor, dup(2)ed internally.

◆ pixel_size() [1/2]

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

Size of the terminal in pixels.

◆ pixel_size() [2/2]

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

Size of the terminal in pixels.

◆ show_cursor() [1/2]

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

◆ show_cursor() [2/2]

bool nngn::Terminal::show_cursor ( void  ) const

◆ size() [1/2]

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

Size of the terminal in characters.

Here is the caller graph for this function:

◆ size() [2/2]

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

Size of the terminal in characters.

◆ update_size() [1/2]

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:

◆ update_size() [2/2]

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

Retrieves the terminal size from the operating system.

Returns
{changed, ok}

◆ write() [1/4]

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/4]

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

Outputs the entire contents of a range.

◆ write() [3/4]

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:

◆ write() [4/4]

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

Outputs the entire contents of a buffer.

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: