34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 35 #error "Only <final/final.h> can be included directly." 43 #include "final/ftypes.h" 44 #include "final/output/tty/ftermcap.h" 45 #include "final/output/tty/sgr_optimizer.h" 46 #include "final/util/fstring.h" 75 int attr_without_color;
76 bool ansi_default_color;
102 auto getClassName()
const ->
FString;
106 void setTermEnvironment (
const TermEnv&);
107 void setMaxColor (
int) noexcept;
108 void setNoColorVideo (
int) noexcept;
109 void setDefaultColorSupport() noexcept;
110 void unsetDefaultColorSupport() noexcept;
148 static auto isNormal (
const FChar&) noexcept -> bool;
152 static auto vga2ansi (FColor) noexcept -> FColor;
170 Capability a_foreground{};
171 Capability a_background{};
172 Capability foreground{};
173 Capability background{};
174 Capability color_pair{};
175 Capability orig_pair{};
176 Capability orig_colors{};
177 int attr_without_color{0};
179 bool monochron{
true};
180 bool ansi_default_color{
false};
183 struct AttributeChanges
190 using SetFunctionCall = std::function<bool(FOptiAttr*, FChar&)>;
192 struct AttributeHandlerEntry
195 SetFunctionCall
function;
198 using AttributeHandlers = std::array<AttributeHandlerEntry, 13>;
199 using NoColorVideoHandler = std::function<void(FOptiAttr*, FChar&)>;
200 using NoColorVideoHandlerTable = std::array<NoColorVideoHandler, 18>;
203 enum init_reset_tests : uInt8
206 test_ansi_reset = 0x01,
207 test_adm3_reset = 0x02,
218 auto setTermBold (
FChar&) noexcept -> bool;
219 auto unsetTermBold (
FChar&) noexcept -> bool;
220 auto setTermDim (
FChar&) noexcept -> bool;
221 auto unsetTermDim (
FChar&) noexcept -> bool;
222 auto setTermItalic (
FChar&) noexcept -> bool;
223 auto unsetTermItalic (
FChar&) noexcept -> bool;
224 auto setTermUnderline (
FChar&) noexcept -> bool;
225 auto unsetTermUnderline (
FChar&) noexcept -> bool;
226 auto setTermBlink (
FChar&) noexcept -> bool;
227 auto unsetTermBlink (
FChar&) noexcept -> bool;
228 auto setTermReverse (
FChar&) noexcept -> bool;
229 auto unsetTermReverse (
FChar&) noexcept -> bool;
230 auto setTermStandout (
FChar&) noexcept -> bool;
231 auto unsetTermStandout (
FChar&) noexcept -> bool;
232 auto setTermInvisible (
FChar&) noexcept -> bool;
233 auto unsetTermInvisible (
FChar&) noexcept -> bool;
234 auto setTermProtected (
FChar&) noexcept -> bool;
235 auto unsetTermProtected (
FChar&) noexcept -> bool;
236 auto setTermCrossedOut (
FChar&) noexcept -> bool;
237 auto unsetTermCrossedOut (
FChar&) noexcept -> bool;
238 auto setTermDoubleUnderline (
FChar&) noexcept -> bool;
239 auto unsetTermDoubleUnderline (
FChar&) noexcept -> bool;
240 auto setTermAttributes (
FChar&,
const FChar&) -> bool;
241 auto unsetTermAttributes (
FChar&) noexcept -> bool;
242 auto setTermAltCharset (
FChar&) noexcept -> bool;
243 auto unsetTermAltCharset (
FChar&) noexcept -> bool;
244 auto setTermPCcharset (
FChar&) noexcept -> bool;
245 auto unsetTermPCcharset (
FChar&) noexcept -> bool;
246 auto setTermDefaultColor (
FChar&) -> bool;
247 void setAttributesOn (
FChar&);
248 void setAttributesOff (
FChar&);
249 void setAttributes (uInt32,
const AttributeHandlers&,
FChar&);
252 static auto hasColor (
const FChar&) noexcept -> bool;
253 static auto hasAttribute (
const FChar&) noexcept -> bool;
254 static auto hasNoAttribute (
const FChar&) noexcept -> bool;
255 auto isItalicsUsed (
const FChar&,
const FChar&)
const noexcept -> bool;
256 auto isCrossedOutUsed (
const FChar&,
const FChar&)
const noexcept -> bool;
257 auto isDoubleUnderlineUsed (
const FChar&,
const FChar&)
const noexcept -> bool;
258 auto isPCcharsetUsed (
const FChar&,
const FChar&)
const noexcept -> bool;
259 auto isPCcharsetUsable (
FChar&,
const FChar&) noexcept -> bool;
260 auto hasColorChanged (
const FChar&,
const FChar&)
const noexcept -> bool;
263 void resetColor (
FChar&)
const noexcept ;
264 void prevent_no_color_video_attributes (
FChar&,
bool =
false);
267 void changeAttributeSeparately (
FChar&,
FChar&);
270 void handleDefaultColors (
FChar&,
FChar&, FColor&, FColor&);
271 void change_to_default_color (
FChar&,
FChar&, FColor&, FColor&);
272 void setDefaultForeground (
FChar&);
273 void setDefaultBackground (
FChar&);
274 void change_current_color (
const FChar&,
const FColor,
const FColor);
275 void resetAttribute (
FChar&)
const noexcept;
276 void reset (
FChar&)
const noexcept;
278 void init_reset_attribute (Capability&, uChar = all_tests)
const noexcept;
279 auto fake_reverse_color_change (
const FChar& term)
const noexcept -> bool;
280 auto hasCharsetEquivalence()
const noexcept -> bool;
281 static auto getNoColorVideoHandlerTable() ->
const NoColorVideoHandlerTable&;
282 static auto getAttributeOnHandlers() ->
const AttributeHandlers&;
283 static auto getAttributeOffHandlers() ->
const AttributeHandlers&;
284 void detectSwitchOn (
const FChar&,
const FChar&) noexcept;
285 void detectSwitchOff (
const FChar&,
const FChar&) noexcept;
286 auto switchOn()
const noexcept -> bool;
287 auto switchOff()
const noexcept -> bool;
288 template <
typename CharT
289 , enable_if_char_ptr_t<CharT> =
nullptr>
290 auto append_sequence (CharT) noexcept -> bool;
291 template <
typename CharT
292 , enable_if_char_array_t<CharT> =
nullptr>
293 auto append_sequence (CharT) noexcept -> bool;
295 auto append_sequence (
const std::string&) noexcept -> bool;
300 TextStyle F_italics{};
301 TextStyle F_underline{};
303 TextStyle F_reverse{};
304 TextStyle F_standout{};
305 TextStyle F_secure{};
306 TextStyle F_protected{};
307 TextStyle F_crossed_out{};
308 TextStyle F_dbl_underline{};
309 TextStyle F_attributes{};
310 TextStyle F_alt_charset{};
311 TextStyle F_pc_charset{};
312 ColorStyle F_color{};
314 AttributeChanges changes{};
315 std::string attr_buf{};
317 bool alt_equal_pc_charset{
false};
318 bool fake_reverse{
false};
324 inline auto FOptiAttr::getClassName()
const ->
FString 325 {
return "FOptiAttr"; }
328 inline void FOptiAttr::setMaxColor (
int c) noexcept
329 { F_color.max_color = c; }
332 inline void FOptiAttr::setNoColorVideo (
int attr) noexcept
333 { F_color.attr_without_color = attr; }
336 inline void FOptiAttr::setDefaultColorSupport() noexcept
337 { F_color.ansi_default_color =
true; }
340 inline void FOptiAttr::unsetDefaultColorSupport() noexcept
341 { F_color.ansi_default_color =
false; }
344 template <
typename CharT
345 , enable_if_char_ptr_t<CharT>>
346 inline auto FOptiAttr::append_sequence (CharT seq) noexcept ->
bool 350 ? append_sequence(std::string(seq))
355 template <
typename CharT
356 , enable_if_char_array_t<CharT>>
357 inline auto FOptiAttr::append_sequence (CharT seq) noexcept ->
bool 360 return append_sequence(std::string(seq));
365 #endif // FOPTIATTR_H Definition: ftermcap.h:72
Definition: class_template.cpp:25
Definition: foptiattr.h:59
Definition: ftypes.h:1081
Definition: foptiattr.h:56
Definition: foptiattr.h:79
Definition: sgr_optimizer.h:49
Definition: foptiattr.h:65