cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
terminfo.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
12#include <array>
13#include <cstdint>
14#include <string>
15
16namespace Term
17{
18
20{
21public:
22 // indicates the color mode (basically the original color resolution)
23 // also used to manually override the original color resolution
24 enum class ColorMode : std::uint8_t
25 {
27 // no color was used
29 // a 3bit color was used
30 Bit3,
31 // a 4bit color was used
32 Bit4,
33 // a 8bit color was used
34 Bit8,
35 // a 24bit (RGB) color was used
36 Bit24
37 };
38 enum class Bool : std::uint8_t
39 {
40 UTF8 = 0,
41 Legacy,
43 };
44 enum class String : std::uint8_t
45 {
46 TermEnv,
47 TermName,
49 };
50 enum class Integer : std::uint8_t
51 {
52
53 };
54
55 static bool get(const Term::Terminfo::Bool& key);
56 static std::uint32_t get(const Term::Terminfo::Integer& key);
57 static std::string get(const Term::Terminfo::String& key);
58
59private:
60 static const constexpr std::size_t BoolNumber{3};
61 static const constexpr std::size_t StringNumber{3};
62 static const constexpr std::size_t IntegerNumber{0};
63
64public:
65 using Booleans = std::array<bool, BoolNumber>;
66 using Strings = std::array<std::string, StringNumber>;
67 using Integers = std::array<std::uint32_t, IntegerNumber>;
68
69 Terminfo();
70
71 static ColorMode getColorMode();
72
73private:
74 static void check();
75 static void checkTermEnv();
76 static void checkTerminalName();
77 static void checkTerminalVersion();
78 static void checkColorMode();
79 static void checkUTF8();
80 static void checkLegacy();
81 static void checkControlSequences();
82
83 static void set(const Term::Terminfo::Bool& key, const bool& value);
84 static void set(const Term::Terminfo::Integer& key, const std::uint32_t& value);
85 static void set(const Term::Terminfo::String& key, const std::string& value);
86
88 static Booleans m_booleans;
89 static Integers m_integers;
90 static Strings m_strings;
91};
92
93} // namespace Term
static bool get(const Term::Terminfo::Bool &key)
Definition terminfo.cpp:30
static const constexpr std::size_t IntegerNumber
Definition terminfo.hpp:62
static const constexpr std::size_t BoolNumber
Definition terminfo.hpp:60
static void checkTerminalName()
Definition terminfo.cpp:109
static void checkControlSequences()
Definition terminfo.cpp:162
static void checkLegacy()
Definition terminfo.cpp:84
static const constexpr std::size_t StringNumber
Definition terminfo.hpp:61
static ColorMode getColorMode()
Definition terminfo.cpp:136
@ Legacy
Terminal is in legacy mode (Windows only).
@ ControlSequences
Terminal support control sequences.
@ UTF8
terminal has UTF-8 activated.
static void checkColorMode()
Definition terminfo.cpp:144
static Strings m_strings
Definition terminfo.hpp:28
static void check()
Definition terminfo.cpp:120
static void set(const Term::Terminfo::Bool &key, const bool &value)
Definition terminfo.cpp:48
static void checkTermEnv()
Definition terminfo.cpp:107
static void checkUTF8()
Definition terminfo.cpp:172
std::array< bool, BoolNumber > Booleans
Definition terminfo.hpp:65
std::array< std::uint32_t, IntegerNumber > Integers
Definition terminfo.hpp:67
static ColorMode m_colorMode
Definition terminfo.hpp:25
static Integers m_integers
Definition terminfo.hpp:27
@ TermName
Name of the terminal program if available.
@ TermVersion
Terminal version.
@ TermEnv
TERM environment variable value.
static Booleans m_booleans
Definition terminfo.hpp:26
std::array< std::string, StringNumber > Strings
Definition terminfo.hpp:66
static void checkTerminalVersion()
Definition terminfo.cpp:118
Definition args.cpp:13