mirror of
https://github.com/NixOS/nix
synced 2025-06-28 13:41:15 +02:00
Split up util.{hh,cc}
All OS and IO operations should be moved out, leaving only some misc portable pure functions. This is useful to avoid copious CPP when doing things like Windows and Emscripten ports. Newly exposed functions to break cycles: - `restoreSignals` - `updateWindowSize`
This commit is contained in:
parent
2678b51b31
commit
ac89bb064a
138 changed files with 3028 additions and 2654 deletions
38
src/libutil/terminal.hh
Normal file
38
src/libutil/terminal.hh
Normal file
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "types.hh"
|
||||
|
||||
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();
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue