1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-04 23:51:47 +02:00
nix/src/libutil/terminal.hh
John Ericson 8433027e35 Build a minimized Nix with MinGW
At this point many features are stripped out, but this works:

- Can run libnix{util,store,expr} unit tests
- Can run some Nix commands

Co-Authored-By volth <volth@volth.com>
Co-Authored-By Brian McKenna <brian@brianmckenna.org>
2024-04-17 12:26:10 -04:00

42 lines
994 B
C++

#pragma once
///@file
#include "types.hh"
namespace nix {
/**
* Determine whether ANSI escape sequences are appropriate for the
* present output.
*/
bool isTTY();
/**
* 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.
*/
std::string filterANSIEscapes(std::string_view s,
bool filterAll = false,
unsigned int width = std::numeric_limits<unsigned int>::max());
#ifndef _WIN32
/**
* Recalculate the window size, updating a global variable. Used in the
* `SIGWINCH` signal handler.
*/
void updateWindowSize();
#endif
/**
* @return the number of rows and columns of the terminal.
*
* The value is cached so this is quick. The cached result is computed
* by `updateWindowSize()`.
*/
std::pair<unsigned short, unsigned short> getWindowSize();
}