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 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);
75 std::array<char, tname_size> tname;
79 using TCapMapType = std::array<TCapMap, 86>;
80 using PutCharFunc = std::decay_t<int(int)>;
81 using PutStringFunc = std::decay_t<int(const std::string&)>;
87 auto getClassName()
const ->
FString;
88 static auto getFlag (
const std::string&) -> bool;
89 static auto getNumber (
const std::string&) -> int;
90 static auto getString (
const std::string&) ->
char*;
91 static auto encodeMotionParameter (
const std::string&,
int,
int) -> std::string;
92 template <
typename... Args>
93 static auto encodeParameter (
const std::string&, Args&&...) -> std::string;
94 static auto paddingPrint (
const std::string&,
int) -> Status;
95 static auto stringPrint (
const std::string&) -> Status;
98 static auto isInitialized() -> bool;
101 template<
typename PutChar>
102 static void setPutCharFunction (
const PutChar&);
103 static void setDefaultPutCharFunction();
104 template<
typename PutString>
105 static void setPutStringFunction (
const PutString&);
106 static void setDefaultPutStringFunction();
107 static void setBaudrate (
int);
113 static bool background_color_erase;
114 static bool can_change_color_palette;
115 static bool automatic_left_margin;
116 static bool automatic_right_margin;
117 static bool eat_nl_glitch;
118 static bool has_ansi_escape_sequences;
119 static bool ansi_default_color;
120 static bool osc_support;
121 static bool no_utf8_acs_chars;
122 static bool no_padding_char;
123 static bool xon_xoff_flow_control;
124 static int max_color;
126 static int padding_baudrate;
127 static int attr_without_color;
128 static TCapMapType strings;
132 using string_iterator = std::string::const_iterator;
135 static void termcap();
136 static void termcapError (
int);
137 static void termcapVariables();
138 static void termcapBoleans();
139 static void termcapNumerics();
140 static void termcapStrings();
141 static void termcapKeys();
142 static auto encodeParams (
const std::string&
143 ,
const std::array<int, 9>& ) -> std::string;
144 static auto hasDelay (
const std::string&) -> bool;
145 static void delayOutput (
int);
146 static auto readNumber (string_iterator&,
int,
bool&) -> int;
147 static void readDigits (string_iterator&,
int&);
148 static void decimalPoint (string_iterator&,
int&);
149 static void asteriskSlash (string_iterator&,
int&,
int,
bool&);
152 static bool initialized;
156 static char** buffer_addr;
157 static PutCharFunc outc;
158 static PutStringFunc outs;
163 inline auto FTermcap::getClassName()
const ->
FString 164 {
return "FTermcap"; }
167 template <
typename... Args>
168 auto FTermcap::encodeParameter (
const std::string& cap, Args&&... args) -> std::string
170 std::array<int, 9> attr {{
static_cast<int>(args)...}};
171 std::fill(attr.begin() +
sizeof...(args), attr.end(), 0);
172 return encodeParams(cap, attr);
176 inline auto FTermcap::isInitialized() ->
bool 180 return initialized && outc && outs;
184 template<
typename PutChar>
185 inline void FTermcap::setPutCharFunction (
const PutChar& put_char)
189 template<
typename PutString>
190 inline void FTermcap::setPutStringFunction (
const PutString& put_string)
191 { outs = put_string; }
194 inline void FTermcap::setBaudrate (
int baud)
200 inline void FTermcap::delayOutput (
int ms)
202 if ( no_padding_char )
204 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
208 static constexpr
int baudbyte = 9;
210 for (
int pad_char_count = (ms * baudrate) / (baudbyte * 1000);
Definition: ftermcap.h:59
Definition: class_template.cpp:25
Definition: ftermcap.h:72