Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
terminal.hh File Reference
#include <limits>
#include <string>

Go to the source code of this file.

Functions

bool nix::isTTY ()
 
std::string nix::filterANSIEscapes (std::string_view s, bool filterAll, unsigned int width)
 
void nix::updateWindowSize ()
 
std::pair< unsigned short, unsigned short > nix::getWindowSize ()
 

Function Documentation

◆ filterANSIEscapes()

std::string nix::filterANSIEscapes ( std::string_view s,
bool filterAll = false,
unsigned int width = std::numeric_limits< unsigned int >::max() )

Truncate a string to 'width' printable characters. If 'filterAll' is true, all ANSI escape sequences are filtered out. Otherwise, some escape sequences (such as colour setting) are copied but not included in the character count. Also, tabs are expanded to spaces.

◆ getWindowSize()

std::pair< unsigned short, unsigned short > nix::getWindowSize ( )
Returns
the number of rows and columns of the terminal.

The value is cached so this is quick. The cached result is computed by updateWindowSize().

◆ isTTY()

bool nix::isTTY ( )

Determine whether ANSI escape sequences are appropriate for the present output.

◆ updateWindowSize()

void nix::updateWindowSize ( )

Recalculate the window size, updating a global variable.

Used in the SIGWINCH signal handler on Unix, for example.