blob: 43df5bd702c1ac60ce617cd19c24d4ffc15c3ce0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#pragma once
///@file
#include <limits>
#include <string>
namespace nix {
/**
* Determine whether ANSI escape sequences are appropriate for the
* present output.
*/
bool shouldANSI();
/**
* 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());
/**
* Recalculate the window size, updating a global variable. Used in the
* `SIGWINCH` signal handler.
*/
void updateWindowSize();
/**
* @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();
}
|