mirror of
https://github.com/NixOS/nix.git
synced 2025-12-15 05:21:03 +01:00
treewide: Fix MinGW build
Several bugs to squash: - Apparently DELETE is an already used macro with Win32. We can avoid it by using Camel case instead (slightly hacky but also fits the naming convention better) - Gets rid of the raw usage of isatty. Added an isTTY impl to abstract over the raw API.
This commit is contained in:
parent
f8141a2c26
commit
8165419a0c
10 changed files with 44 additions and 25 deletions
|
|
@ -4,7 +4,15 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include "nix/util/file-descriptor.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
/**
|
||||
* Determine whether \param fd is a terminal.
|
||||
*/
|
||||
bool isTTY(Descriptor fd);
|
||||
|
||||
/**
|
||||
* Determine whether ANSI escape sequences are appropriate for the
|
||||
* present output.
|
||||
|
|
|
|||
|
|
@ -64,6 +64,16 @@ inline std::pair<int, size_t> charWidthUTF8Helper(std::string_view s)
|
|||
|
||||
namespace nix {
|
||||
|
||||
bool isTTY(Descriptor fd)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
return isatty(fd);
|
||||
#else
|
||||
DWORD mode;
|
||||
return GetConsoleMode(fd, &mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool isTTY()
|
||||
{
|
||||
static const bool tty = isatty(STDERR_FILENO) && getEnv("TERM").value_or("dumb") != "dumb"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue