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

Handles interactions with the output terminal. More...

#include <terminal.h>

Collaboration diagram for nngn::term::Terminal:

Public Member Functions

 Terminal (int fd)
 Creates an object for a given TTY.
 
 ~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 (void)
 
std::tuple< bool, boolupdate_size (void)
 Asks the OS for the terminal size.
 
bool write (std::size_t n, const char *p) const
 Outputs the entire contents of a buffer.
 
template<typename T >
bool write (const T &v) const
 Outputs the entire contents of a container.
 
bool flush (void) const
 Synchronizes the output file descriptor.
 
bool drain (void) const
 
 Terminal (int fd)
 Creates an object for a given TTY.
 
 ~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 (void)
 
std::tuple< bool, boolupdate_size (void)
 Asks the OS for the terminal size.
 
bool write (std::size_t n, const char *p) const
 Outputs the entire contents of a buffer.
 
template<typename T >
bool write (const T &v) const
 Outputs the entire contents of a container.
 
bool flush (void) const
 Synchronizes the output file descriptor.
 
bool drain (void) const
 

Private Attributes

int fd = -1
 OS file descriptor.
 
int tty_fd = -1
 
std::FILE * f = nullptr
 fopened version of fd.
 
uvec2 m_size = {}
 
uvec2 pixel = {}
 

Detailed Description

Handles interactions with the output terminal.

Constructor & Destructor Documentation

◆ Terminal() [1/2]

nngn::term::Terminal::Terminal ( int  fd)
inline

Creates an object for a given TTY.

Parameters
fdOS file descriptor, whose lifetime is not managed and must remain valid until the object is destructed.

◆ ~Terminal() [1/2]

nngn::term::Terminal::~Terminal ( void  )

◆ Terminal() [2/2]

nngn::term::Terminal::Terminal ( int  fd)

Creates an object for a given TTY.

Parameters
fdOS file descriptor, whose lifetime is not managed and must remain valid until the object is destructed.

◆ ~Terminal() [2/2]

nngn::term::Terminal::~Terminal ( void  )

Member Function Documentation

◆ drain() [1/2]

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

◆ drain() [2/2]

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

◆ flush() [1/2]

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

Synchronizes the output file descriptor.

◆ flush() [2/2]

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

Synchronizes the output file descriptor.

◆ init() [1/2]

bool nngn::term::Terminal::init ( void  )

◆ init() [2/2]

bool nngn::term::Terminal::init ( void  )

◆ pixel_size() [1/2]

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

Size of the terminal in pixels.

◆ pixel_size() [2/2]

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

Size of the terminal in pixels.

◆ size() [1/2]

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

Size of the terminal in characters.

◆ size() [2/2]

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

Size of the terminal in characters.

◆ update_size() [1/2]

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

Asks the OS for the terminal size.

Returns {changed, ok}.

◆ update_size() [2/2]

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

Asks the OS for the terminal size.

Returns {changed, ok}.

◆ write() [1/4]

template<typename T >
bool nngn::term::Terminal::write ( const T v) const
inline

Outputs the entire contents of a container.

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

◆ write() [2/4]

template<typename T >
bool nngn::term::Terminal::write ( const T v) const
inline

Outputs the entire contents of a container.

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

◆ write() [3/4]

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

Outputs the entire contents of a buffer.

◆ write() [4/4]

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

Outputs the entire contents of a buffer.

Member Data Documentation

◆ f

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

fopened version of fd.

◆ fd

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

OS file descriptor.

◆ m_size

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

◆ pixel

uvec2 nngn::term::Terminal::pixel = {}
private

◆ tty_fd

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

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