31 #ifndef FVTERMATTRIBUTE_H 32 #define FVTERMATTRIBUTE_H 34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 35 #error "Only <final/final.h> can be included directly." 38 #include "final/ftypes.h" 39 #include "final/util/fstring.h" 40 #include "final/vterm/fcolorpair.h" 48 constexpr
auto getAttrResetMask() noexcept -> uInt32
50 FCharAttribute mask{};
54 mask.underline =
true;
58 mask.invisible =
true;
60 mask.crossed_out =
true;
61 mask.dbl_underline =
true;
62 mask.alt_charset =
true;
63 mask.pc_charset =
true;
64 mask.transparent =
true;
65 mask.color_overlay =
true;
66 mask.inherit_background =
true;
67 mask.no_changes =
true;
68 return 0xffffffff & ~(FCharAttribute_to_uInt32(mask));
73 static constexpr
auto reset_mask = getAttrResetMask();
108 virtual auto getClassName()
const ->
FString;
109 static auto getTermForegroundColor() noexcept -> FColor;
110 static auto getTermBackgroundColor() noexcept -> FColor;
111 static auto getAttribute() noexcept ->
FChar&;
114 static void setColor (FColor, FColor) noexcept;
115 static void setColor (
const FColorPair&) noexcept;
116 static void setNormal() noexcept;
117 static void setBold (
bool) noexcept;
118 static void setBold() noexcept;
119 static void unsetBold() noexcept;
120 static void setDim (
bool) noexcept;
121 static void setDim() noexcept;
122 static void unsetDim() noexcept;
123 static void setItalic (
bool) noexcept;
124 static void setItalic() noexcept;
125 static void unsetItalic() noexcept;
126 static void setUnderline (
bool) noexcept;
127 static void setUnderline() noexcept;
128 static void unsetUnderline() noexcept;
129 static void setBlink (
bool) noexcept;
130 static void setBlink() noexcept;
131 static void unsetBlink() noexcept;
132 static void setReverse (
bool) noexcept;
133 static void setReverse() noexcept;
134 static void unsetReverse() noexcept;
135 static void setStandout (
bool) noexcept;
136 static void setStandout() noexcept;
137 static void unsetStandout() noexcept;
138 static void setInvisible (
bool) noexcept;
139 static void setInvisible() noexcept;
140 static void unsetInvisible() noexcept;
141 static void setProtected (
bool) noexcept;
142 static void setProtected() noexcept;
143 static void unsetProtected() noexcept;
144 static void setCrossedOut (
bool) noexcept;
145 static void setCrossedOut() noexcept;
146 static void unsetCrossedOut() noexcept;
147 static void setDoubleUnderline (
bool) noexcept;
148 static void setDoubleUnderline() noexcept;
149 static void unsetDoubleUnderline() noexcept;
150 static void setAltCharset (
bool) noexcept;
151 static void setAltCharset() noexcept;
152 static void unsetAltCharset() noexcept;
153 static void setPCcharset (
bool) noexcept;
154 static void setPCcharset() noexcept;
155 static void unsetPCcharset() noexcept;
156 static void setTransparent (
bool) noexcept;
157 static void setTransparent() noexcept;
158 static void unsetTransparent() noexcept;
159 static void setColorOverlay (
bool) noexcept;
160 static void setColorOverlay() noexcept;
161 static void unsetColorOverlay() noexcept;
162 static void setInheritBackground (
bool) noexcept;
163 static void setInheritBackground() noexcept;
164 static void unsetInheritBackground() noexcept;
167 static auto isBold() noexcept -> bool;
168 static auto isDim() noexcept -> bool;
169 static auto isItalic() noexcept -> bool;
170 static auto isUnderline() noexcept -> bool;
171 static auto isBlink() noexcept -> bool;
172 static auto isReverse() noexcept -> bool;
173 static auto isStandout() noexcept -> bool;
174 static auto isInvisible() noexcept -> bool;
175 static auto isProtected() noexcept -> bool;
176 static auto isCrossedOut() noexcept -> bool;
177 static auto isDoubleUnderline() noexcept -> bool;
178 static auto isAltCharset() noexcept -> bool;
179 static auto isPCcharset() noexcept -> bool;
180 static auto isTransparent() noexcept -> bool;
181 static auto isColorOverlay() noexcept -> bool;
182 static auto isInheritBackground() noexcept -> bool;
185 static void initAttribute() noexcept;
186 static void print (
const FStyle&);
187 static void print (
const FColorPair&) noexcept;
191 static FChar next_attribute;
197 inline auto FVTermAttribute::getClassName()
const ->
FString 198 {
return "FVTermAttribute"; }
201 inline auto FVTermAttribute::getTermForegroundColor() noexcept -> FColor
202 {
return next_attribute.color.getPair().fg; }
205 inline auto FVTermAttribute::getTermBackgroundColor() noexcept -> FColor
206 {
return next_attribute.color.getPair().bg; }
209 inline auto FVTermAttribute::getAttribute() noexcept ->
FChar&
210 {
return next_attribute; }
213 inline void FVTermAttribute::setColor (FColor fg, FColor bg) noexcept
216 next_attribute.color.setPair({fg, bg});
220 inline void FVTermAttribute::setColor (
const FColorPair& pair) noexcept
222 setColor (pair.getForegroundColor(), pair.getBackgroundColor());
226 inline void FVTermAttribute::setNormal() noexcept
229 next_attribute.color = default_color_pair;
230 next_attribute.unsetBit(internal::attr_var::reset_mask);
234 inline void FVTermAttribute::setBold (
bool enable) noexcept
236 next_attribute.setBit(FAttribute::set::bold, enable);
240 inline void FVTermAttribute::setBold() noexcept
242 next_attribute.setBit(FAttribute::set::bold);
246 inline void FVTermAttribute::unsetBold() noexcept
248 next_attribute.unsetBit(FAttribute::unset::bold);
252 inline void FVTermAttribute::setDim (
bool enable) noexcept
254 next_attribute.setBit(FAttribute::set::dim, enable);
258 inline void FVTermAttribute::setDim() noexcept
260 next_attribute.setBit(FAttribute::set::dim);
264 inline void FVTermAttribute::unsetDim() noexcept
266 next_attribute.unsetBit(FAttribute::unset::dim);
270 inline void FVTermAttribute::setItalic (
bool enable) noexcept
272 next_attribute.setBit(FAttribute::set::italic, enable);
276 inline void FVTermAttribute::setItalic() noexcept
278 next_attribute.setBit(FAttribute::set::italic);
282 inline void FVTermAttribute::unsetItalic() noexcept
284 next_attribute.unsetBit(FAttribute::unset::italic);
288 inline void FVTermAttribute::setUnderline (
bool enable) noexcept
290 next_attribute.setBit(FAttribute::set::underline, enable);
294 inline void FVTermAttribute::setUnderline() noexcept
296 next_attribute.setBit(FAttribute::set::underline);
300 inline void FVTermAttribute::unsetUnderline() noexcept
302 next_attribute.unsetBit(FAttribute::unset::underline);
306 inline void FVTermAttribute::setBlink (
bool enable) noexcept
308 next_attribute.setBit(FAttribute::set::blink, enable);
312 inline void FVTermAttribute::setBlink() noexcept
314 next_attribute.setBit(FAttribute::set::blink);
318 inline void FVTermAttribute::unsetBlink() noexcept
320 next_attribute.unsetBit(FAttribute::unset::blink);
324 inline void FVTermAttribute::setReverse (
bool enable) noexcept
326 next_attribute.setBit(FAttribute::set::reverse, enable);
330 inline void FVTermAttribute::setReverse() noexcept
332 next_attribute.setBit(FAttribute::set::reverse);
336 inline void FVTermAttribute::unsetReverse() noexcept
338 next_attribute.unsetBit(FAttribute::unset::reverse);
342 inline void FVTermAttribute::setStandout (
bool enable) noexcept
344 next_attribute.setBit(FAttribute::set::standout, enable);
348 inline void FVTermAttribute::setStandout() noexcept
350 next_attribute.setBit(FAttribute::set::standout);
354 inline void FVTermAttribute::unsetStandout() noexcept
356 next_attribute.unsetBit(FAttribute::unset::standout);
360 inline void FVTermAttribute::setInvisible (
bool enable) noexcept
362 next_attribute.setBit(FAttribute::set::invisible, enable);
366 inline void FVTermAttribute::setInvisible() noexcept
368 next_attribute.setBit(FAttribute::set::invisible);
372 inline void FVTermAttribute::unsetInvisible() noexcept
374 next_attribute.unsetBit(FAttribute::unset::invisible);
378 inline void FVTermAttribute::setProtected (
bool enable) noexcept
380 next_attribute.setBit(FAttribute::set::protect, enable);
384 inline void FVTermAttribute::setProtected() noexcept
386 next_attribute.setBit(FAttribute::set::protect);
390 inline void FVTermAttribute::unsetProtected() noexcept
392 next_attribute.unsetBit(FAttribute::unset::protect);
396 inline void FVTermAttribute::setCrossedOut (
bool enable) noexcept
398 next_attribute.setBit(FAttribute::set::crossed_out, enable);
402 inline void FVTermAttribute::setCrossedOut() noexcept
404 next_attribute.setBit(FAttribute::set::crossed_out);
408 inline void FVTermAttribute::unsetCrossedOut() noexcept
410 next_attribute.unsetBit(FAttribute::unset::crossed_out);
414 inline void FVTermAttribute::setDoubleUnderline (
bool enable) noexcept
416 next_attribute.setBit(FAttribute::set::dbl_underline, enable);
420 inline void FVTermAttribute::setDoubleUnderline() noexcept
422 next_attribute.setBit(FAttribute::set::dbl_underline);
426 inline void FVTermAttribute::unsetDoubleUnderline() noexcept
428 next_attribute.unsetBit(FAttribute::unset::dbl_underline);
432 inline void FVTermAttribute::setAltCharset (
bool enable) noexcept
434 next_attribute.setBit(FAttribute::set::alt_charset, enable);
438 inline void FVTermAttribute::setAltCharset() noexcept
440 next_attribute.setBit(FAttribute::set::alt_charset);
444 inline void FVTermAttribute::unsetAltCharset() noexcept
446 next_attribute.unsetBit(FAttribute::unset::alt_charset);
450 inline void FVTermAttribute::setPCcharset (
bool enable) noexcept
452 next_attribute.setBit(FAttribute::set::pc_charset, enable);
456 inline void FVTermAttribute::setPCcharset() noexcept
458 next_attribute.setBit(FAttribute::set::pc_charset);
462 inline void FVTermAttribute::unsetPCcharset() noexcept
464 next_attribute.unsetBit(FAttribute::unset::pc_charset);
468 inline void FVTermAttribute::setTransparent (
bool enable) noexcept
470 next_attribute.setBit(FAttribute::set::transparent, enable);
474 inline void FVTermAttribute::setTransparent() noexcept
476 next_attribute.setBit(FAttribute::set::transparent);
480 inline void FVTermAttribute::unsetTransparent() noexcept
482 next_attribute.unsetBit(FAttribute::unset::transparent);
486 inline void FVTermAttribute::setColorOverlay (
bool enable) noexcept
488 next_attribute.setBit(FAttribute::set::color_overlay, enable);
492 inline void FVTermAttribute::setColorOverlay() noexcept
494 next_attribute.setBit(FAttribute::set::color_overlay);
498 inline void FVTermAttribute::unsetColorOverlay() noexcept
500 next_attribute.unsetBit(FAttribute::unset::color_overlay);
504 inline void FVTermAttribute::setInheritBackground (
bool enable) noexcept
506 next_attribute.setBit(FAttribute::set::inherit_background, enable);
510 inline void FVTermAttribute::setInheritBackground() noexcept
512 next_attribute.setBit(FAttribute::set::inherit_background);
516 inline void FVTermAttribute::unsetInheritBackground() noexcept
518 next_attribute.unsetBit(FAttribute::unset::inherit_background);
522 inline auto FVTermAttribute::isBold() noexcept ->
bool 524 return next_attribute.isBitSet(FAttribute::set::bold);
528 inline auto FVTermAttribute::isDim() noexcept ->
bool 530 return next_attribute.isBitSet(FAttribute::set::dim);
534 inline auto FVTermAttribute::isItalic() noexcept ->
bool 536 return next_attribute.isBitSet(FAttribute::set::italic);
540 inline auto FVTermAttribute::isUnderline() noexcept ->
bool 542 return next_attribute.isBitSet(FAttribute::set::underline);
546 inline auto FVTermAttribute::isBlink() noexcept ->
bool 548 return next_attribute.isBitSet(FAttribute::set::blink);
552 inline auto FVTermAttribute::isReverse() noexcept ->
bool 554 return next_attribute.isBitSet(FAttribute::set::reverse);
558 inline auto FVTermAttribute::isStandout() noexcept ->
bool 560 return next_attribute.isBitSet(FAttribute::set::standout);
564 inline auto FVTermAttribute::isInvisible() noexcept ->
bool 566 return next_attribute.isBitSet(FAttribute::set::invisible);
570 inline auto FVTermAttribute::isProtected() noexcept ->
bool 572 return next_attribute.isBitSet(FAttribute::set::protect);
576 inline auto FVTermAttribute::isCrossedOut() noexcept ->
bool 578 return next_attribute.isBitSet(FAttribute::set::crossed_out);
582 inline auto FVTermAttribute::isDoubleUnderline() noexcept ->
bool 584 return next_attribute.isBitSet(FAttribute::set::dbl_underline);
588 inline auto FVTermAttribute::isAltCharset() noexcept ->
bool 590 return next_attribute.isBitSet(FAttribute::set::alt_charset);
594 inline auto FVTermAttribute::isPCcharset() noexcept ->
bool 596 return next_attribute.isBitSet(FAttribute::set::pc_charset);
600 inline auto FVTermAttribute::isTransparent() noexcept ->
bool 602 return next_attribute.isBitSet(FAttribute::set::transparent);
606 inline auto FVTermAttribute::isColorOverlay() noexcept ->
bool 608 return next_attribute.isBitSet(FAttribute::set::color_overlay);
612 inline auto FVTermAttribute::isInheritBackground() noexcept ->
bool 614 return next_attribute.isBitSet(FAttribute::set::inherit_background);
619 #endif // FVTERMATTRIBUTE_H Definition: class_template.cpp:25
Definition: ftypes.h:1081
Definition: fvtermattribute.h:71
Definition: fcolorpair.h:49
Definition: fvtermattribute.h:86