34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 35 #error "Only <final/final.h> can be included directly." 42 #include <type_traits> 46 #include "final/ftypes.h" 47 #include "final/util/fstring.h" 50 #define TCAP(...) FTermcap::strings[int(Termcap::__VA_ARGS__)].string 63 enum class Status : sInt8
69 static constexpr std::size_t tname_min_size = 4u;
70 static constexpr std::size_t tname_size = std::max(
alignof(
void*), tname_min_size);
81 std::array<char, tname_size> tname;
85 using TCapMapType = std::array<TCapMap, 86>;
86 using PutCharFunc = std::decay_t<int(int)>;
87 using PutStringFunc = std::decay_t<int(const char*, uInt32)>;
93 auto getClassName()
const ->
FString;
94 static auto getFlag (
const std::string&) -> bool;
95 static auto getNumber (
const std::string&) -> int;
96 static auto getString (
const std::string&) ->
char*;
98 template <
typename... Args>
100 static auto paddingPrint (
const char*, uInt32,
int) -> Status;
101 static auto stringPrint (
const char*, uInt32) -> Status;
104 static auto isInitialized() noexcept -> bool;
107 template<
typename PutChar>
108 static void setPutCharFunction (
const PutChar&) noexcept;
109 static void setDefaultPutCharFunction();
110 template<
typename PutString>
111 static void setPutStringFunction (
const PutString&) noexcept;
112 static void setDefaultPutStringFunction();
113 static void setBaudrate (
int) noexcept;
114 static void clearMotionCache();
120 static bool background_color_erase;
121 static bool can_change_color_palette;
122 static bool automatic_left_margin;
123 static bool automatic_right_margin;
124 static bool eat_nl_glitch;
125 static bool has_ansi_escape_sequences;
126 static bool ansi_default_color;
127 static bool osc_support;
128 static bool no_utf8_acs_chars;
129 static bool no_padding_char;
130 static bool xon_xoff_flow_control;
131 static int max_color;
133 static int padding_baudrate;
134 static int attr_without_color;
135 static TCapMapType strings;
139 using string_iterator = std::string::const_iterator;
142 static void termcap();
143 static void termcapError (
int);
144 static void termcapVariables();
145 static void termcapBoleans();
146 static void termcapNumerics();
147 static void termcapStrings();
148 static void termcapKeys();
151 static auto hasDelay (
const std::string&) noexcept -> bool;
152 static void delayOutput (
int) noexcept;
153 static auto readNumber (
const char*&,
int,
bool&) noexcept -> int;
154 static void readDigits (
const char*&,
int&) noexcept;
155 static void decimalPoint (
const char*&,
int&) noexcept;
156 static void asteriskSlash (
const char*&,
int&,
int,
bool&) noexcept;
159 static bool initialized;
163 static char** buffer_addr;
164 static PutCharFunc outc;
165 static PutStringFunc outs;
170 inline auto FTermcap::getClassName()
const ->
FString 171 {
return "FTermcap"; }
174 template <
typename... Args>
177 std::array<int, 9> attr {{
static_cast<int>(args)...}};
178 return encodeParams(cap, attr);
182 inline auto FTermcap::isInitialized() noexcept ->
bool 186 return initialized && outc && outs;
190 template<
typename PutChar>
191 inline void FTermcap::setPutCharFunction (
const PutChar& put_char) noexcept
195 template<
typename PutString>
196 inline void FTermcap::setPutStringFunction (
const PutString& put_string) noexcept
197 { outs = put_string; }
200 inline void FTermcap::setBaudrate (
int baud) noexcept
206 inline void FTermcap::delayOutput (
int ms) noexcept
208 if ( no_padding_char )
210 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
214 static constexpr
int baudbyte = 9;
216 for (
int pad_char_count = (ms * baudrate) / (baudbyte * 1000);
Definition: ftermcap.h:72
Definition: ftermcap.h:59
Definition: class_template.cpp:25
Definition: ftermcap.h:78