That Terminal
A terminal emulator designed for video making purposes.
ForkPTY Class Reference

#include <forkpty.hh>

Public Member Functions

 ForkPTY (std::size_t width, std::size_t height)
 
 ~ForkPTY ()
 
void Open (std::size_t width, std::size_t height)
 
void Close ()
 
bool Active () const
 
int getfd () const
 
int Send (std::string_view buffer)
 
std::pair< std::string, int > Recv ()
 
void Kill (int signal)
 
void Resize (unsigned xsize, unsigned ysize)
 

Detailed Description

ForkPTY is a communications end point between the terminal emulator and the underlying operating system. As the name suggests, it is a wrapper over the forkpty() call. It launches a shell in the host system.

Constructor & Destructor Documentation

◆ ForkPTY()

ForkPTY::ForkPTY ( std::size_t  width,
std::size_t  height 
)
inline

Constructor. Calls Open() with its parameters.

See also
Open()

◆ ~ForkPTY()

ForkPTY::~ForkPTY ( )

Destructor. Terminates the subprocess if it is still active.

Member Function Documentation

◆ Active()

bool ForkPTY::Active ( ) const
Returns
true if the subprocess was launched successfully.

◆ Close()

void ForkPTY::Close ( )

Terminate the subprocess.

◆ getfd()

int ForkPTY::getfd ( ) const
Returns
the underlying file descriptor.

◆ Kill()

void ForkPTY::Kill ( int  signal)

Send a signal to the subprocess.

◆ Open()

void ForkPTY::Open ( std::size_t  width,
std::size_t  height 
)

Create a subprocess in a virtual terminal with given dimensions. If the opening is successful, the file descriptor is set to non-blocking mode.

◆ Recv()

std::pair< std::string, int > ForkPTY::Recv ( )

Try to receive output from the subprocess in non-blcoking mode.

Returns
The string containing raw data that was read. The second member contains the length of the string if successful, or -1 if read was unsuccesful.

◆ Resize()

void ForkPTY::Resize ( unsigned  xsize,
unsigned  ysize 
)

Inform the subprocess (or its virtual terminal) that the terminal has been resized to the given dimensions.

◆ Send()

int ForkPTY::Send ( std::string_view  buffer)

Try to send the string as input to the subprocess in non-blocking mode. This function is typically called when the user types something.

Parameters
bufferThe string to send to the subprocess; typically whatever the user typed.
Returns
the number of bytes written.

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