Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions
terminal.hpp File Reference
#include "string_util.hpp"
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <mutex>
#include <optional>
#include <ranges>
#include <string>
#include <string_view>
#include <utility>
#include <variant>
Include dependency graph for terminal.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  terminal::RGBColor
 
class  terminal::TerminalStyle
 
struct  terminal::toggle
 A simple yes/no toggle that parses from a string. More...
 

Namespaces

namespace  terminal
 

Typedefs

using terminal::BGColor = std::variant< BackgroundColor, RGBColor >
 
using terminal::FGColor = std::variant< ForegroundColor, RGBColor >
 

Enumerations

enum class  terminal::BackgroundColor {
  terminal::Default = 49 , terminal::Black = 40 , terminal::Red = 41 , terminal::Green = 42 ,
  terminal::Yellow = 43 , terminal::Blue = 44 , terminal::Magenta = 45 , terminal::Cyan = 46 ,
  terminal::LightGray = 47 , terminal::DarkGray = 100 , terminal::LightRed = 101 , terminal::LightGreen = 102 ,
  terminal::LightYellow = 103 , terminal::LightBlue = 104 , terminal::LightMagenta = 105 , terminal::LightCyan = 106 ,
  terminal::White = 107
}
 
enum class  terminal::ColorAttribute : unsigned { terminal::None = 0 , terminal::Bold = 1 << 0 , terminal::Dim = 1 << 1 , terminal::Underline = 1 << 2 }
 
enum class  terminal::ForegroundColor {
  terminal::Default = 39 , terminal::Black = 30 , terminal::Red = 31 , terminal::Green = 32 ,
  terminal::Yellow = 33 , terminal::Blue = 34 , terminal::Magenta = 35 , terminal::Cyan = 36 ,
  terminal::LightGray = 37 , terminal::DarkGray = 90 , terminal::LightRed = 91 , terminal::LightGreen = 92 ,
  terminal::LightYellow = 93 , terminal::LightBlue = 94 , terminal::LightMagenta = 95 , terminal::LightCyan = 96 ,
  terminal::White = 97
}
 

Functions

std::string terminal::cmdline (int argc, char **argv)
 
std::string terminal::color_if (std::string_view s, bool b, const TerminalStyle &ts)
 
std::string terminal::color_text (std::string_view s, const TerminalStyle &ts)
 
int terminal::columns ()
 Return the output terminal column count.
 
int terminal::columns (std::FILE *stream)
 Return the terminal column count associated with a C stream.
 
bool terminal::env_exists (std::string const &str)
 
std::string terminal::expand_environment (std::string const &s)
 
template<typename T , typename U >
T terminal::getenv_or_default (const std::string &var, const U &default_value)
 
char const * terminal::getenv_or_default (std::string const &str, char const *Default)
 
bool terminal::is_a_terminal (std::FILE *stream)
 Test whether a C output stream refers to a terminal.
 
bool terminal::no_color_requested ()
 Return whether NO_COLOR requests suppressing default ANSI color output.
 
constexpr ColorAttribute terminal::operator| (ColorAttribute lhs, ColorAttribute rhs)
 
constexpr ColorAttribute & terminal::operator|= (ColorAttribute &lhs, ColorAttribute rhs)
 
TerminalStyle terminal::parseTerminalStyle (const std::string &styleStr)
 
std::string terminal::quote_shell (std::string_view s)
 
int terminal::rows ()
 Return the output terminal row count.
 
int terminal::rows (std::FILE *stream)
 Return the terminal row count associated with a C stream.
 
std::pair< int, int > terminal::size ()
 Return the output terminal size as (rows, columns).
 
std::pair< int, int > terminal::size (std::FILE *stream)
 Return the terminal size associated with a C stream.