File: fvtermattribute.h

package info (click to toggle)
finalcut 0.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,832 kB
  • sloc: cpp: 90,264; makefile: 546; sh: 412
file content (374 lines) | stat: -rw-r--r-- 14,518 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
/***********************************************************************
* fvtermattribute.h - Manipulation of FChar colors and attributes      *
*                                                                      *
* This file is part of the FINAL CUT widget toolkit                    *
*                                                                      *
* Copyright 2021-2022 Markus Gans                                      *
*                                                                      *
* FINAL CUT is free software; you can redistribute it and/or modify    *
* it under the terms of the GNU Lesser General Public License as       *
* published by the Free Software Foundation; either version 3 of       *
* the License, or (at your option) any later version.                  *
*                                                                      *
* FINAL CUT is distributed in the hope that it will be useful, but     *
* WITHOUT ANY WARRANTY; without even the implied warranty of           *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
* GNU Lesser General Public License for more details.                  *
*                                                                      *
* You should have received a copy of the GNU Lesser General Public     *
* License along with this program.  If not, see                        *
* <http://www.gnu.org/licenses/>.                                      *
***********************************************************************/

/*  Standalone class
 *  ════════════════
 *
 * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
 * ▕ FVTermAttribute ▏
 * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
 */

#ifndef FVTERMATTRIBUTE_H
#define FVTERMATTRIBUTE_H

#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
  #error "Only <final/final.h> can be included directly."
#endif

#include "final/ftypes.h"
#include "final/util/fstring.h"

namespace finalcut
{

// class forward declaration
class FColorPair;
class FStyle;

//----------------------------------------------------------------------
// class FVTermAttribute
//----------------------------------------------------------------------

class FVTermAttribute
{
  public:
    // Constructors
    FVTermAttribute();

    // Disable copy constructor
    FVTermAttribute (const FVTermAttribute&) = delete;

    // Disable move constructor
    FVTermAttribute (FVTermAttribute&&) noexcept = delete;

    // Destructor
    virtual ~FVTermAttribute() noexcept;

    // Disable copy assignment operator (=)
    auto operator = (const FVTermAttribute&) -> FVTermAttribute& = delete;

    // Disable move assignment operator (=)
    auto operator = (FVTermAttribute&&) noexcept -> FVTermAttribute& = delete;

    // Accessors
    virtual auto getClassName() const -> FString;
    static auto  getTermForegroundColor() -> FColor;
    static auto  getTermBackgroundColor() -> FColor;
    static auto  getAttribute() -> FChar&;

    // Mutators
    static void  setColor (FColor, FColor);
    static void  setNormal();
    static void  setBold (bool = true);
    static void  unsetBold();
    static void  setDim (bool = true);
    static void  unsetDim();
    static void  setItalic (bool = true);
    static void  unsetItalic();
    static void  setUnderline (bool = true);
    static void  unsetUnderline();
    static void  setBlink (bool = true);
    static void  unsetBlink();
    static void  setReverse (bool = true);
    static void  unsetReverse();
    static void  setStandout (bool = true);
    static void  unsetStandout();
    static void  setInvisible (bool = true);
    static void  unsetInvisible();
    static void  setProtected (bool = true);
    static void  unsetProtected();
    static void  setCrossedOut (bool = true);
    static void  unsetCrossedOut();
    static void  setDoubleUnderline (bool = true);
    static void  unsetDoubleUnderline();
    static void  setAltCharset (bool = true);
    static void  unsetAltCharset();
    static void  setPCcharset (bool = true);
    static void  unsetPCcharset();
    static void  setTransparent (bool = true);
    static void  unsetTransparent();
    static void  setColorOverlay (bool = true);
    static void  unsetColorOverlay();
    static void  setInheritBackground (bool = true);
    static void  unsetInheritBackground();

    // Inquiries
    static auto  isBold() -> bool;
    static auto  isDim() -> bool;
    static auto  isItalic() -> bool;
    static auto  isUnderline() -> bool;
    static auto  isBlink() -> bool;
    static auto  isReverse() -> bool;
    static auto  isStandout() -> bool;
    static auto  isInvisible() -> bool;
    static auto  isProtected() -> bool;
    static auto  isCrossedOut() -> bool;
    static auto  isDoubleUnderline() -> bool;
    static auto  isAltCharset() -> bool;
    static auto  isPCcharset() -> bool;
    static auto  isTransparent() -> bool;
    static auto  isColorOverlay() -> bool;
    static auto  isInheritBackground() -> bool;

    // Methods
    static void  initAttribute();
    static void  print (const FStyle&);
    static void  print (const FColorPair&);

  private:
    // Data members
    static FChar next_attribute;
};


// FVTermAttribute inline functions
//----------------------------------------------------------------------
inline auto FVTermAttribute::getClassName() const -> FString
{ return "FVTermAttribute"; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::getTermForegroundColor() -> FColor
{ return next_attribute.fg_color; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::getTermBackgroundColor() -> FColor
{ return next_attribute.bg_color; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::getAttribute() -> FChar&
{ return next_attribute; }

//----------------------------------------------------------------------
inline void FVTermAttribute::setColor (FColor fg, FColor bg)
{
  // Changes colors
  next_attribute.fg_color = fg;
  next_attribute.bg_color = bg;
}

//----------------------------------------------------------------------
inline void FVTermAttribute::setNormal()
{
  // Reset all character attributes
  next_attribute.attr.byte[0] = 0;
  next_attribute.attr.byte[1] = 0;
  next_attribute.attr.bit.no_changes = false;
  next_attribute.fg_color = FColor::Default;
  next_attribute.bg_color = FColor::Default;
}

//----------------------------------------------------------------------
inline void FVTermAttribute::setBold (bool enable)
{ next_attribute.attr.bit.bold = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetBold()
{ setBold(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setDim (bool enable)
{ next_attribute.attr.bit.dim = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetDim()
{ setDim(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setItalic (bool enable)
{ next_attribute.attr.bit.italic = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetItalic()
{ setItalic(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setUnderline (bool enable)
{ next_attribute.attr.bit.underline = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetUnderline()
{ setUnderline(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setBlink (bool enable)
{ next_attribute.attr.bit.blink = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetBlink()
{ setBlink(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setReverse (bool enable)
{ next_attribute.attr.bit.reverse = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetReverse()
{ setReverse(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setStandout (bool enable)
{ next_attribute.attr.bit.standout = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetStandout()
{ setStandout(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setInvisible (bool enable)
{ next_attribute.attr.bit.invisible = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetInvisible()
{ setInvisible(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setProtected (bool enable)
{ next_attribute.attr.bit.protect = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetProtected()
{ setProtected(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setCrossedOut (bool enable)
{ next_attribute.attr.bit.crossed_out = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetCrossedOut()
{ setCrossedOut(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setDoubleUnderline (bool enable)
{ next_attribute.attr.bit.dbl_underline = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetDoubleUnderline()
{ setDoubleUnderline(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setAltCharset (bool enable)
{ next_attribute.attr.bit.alt_charset = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetAltCharset()
{ setAltCharset(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setPCcharset (bool enable)
{ next_attribute.attr.bit.pc_charset = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetPCcharset()
{ setPCcharset(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setTransparent (bool enable)
{ next_attribute.attr.bit.transparent = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetTransparent()
{ setTransparent(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setColorOverlay (bool enable)
{ next_attribute.attr.bit.color_overlay = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetColorOverlay()
{ setColorOverlay(false); }

//----------------------------------------------------------------------
inline void FVTermAttribute::setInheritBackground (bool enable)
{ next_attribute.attr.bit.inherit_background = enable; }

//----------------------------------------------------------------------
inline void FVTermAttribute::unsetInheritBackground()
{ setInheritBackground(false); }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isBold() -> bool
{ return next_attribute.attr.bit.bold; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isDim() -> bool
{ return next_attribute.attr.bit.dim; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isItalic() -> bool
{ return next_attribute.attr.bit.italic; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isUnderline() -> bool
{ return next_attribute.attr.bit.underline; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isBlink() -> bool
{ return next_attribute.attr.bit.blink; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isReverse() -> bool
{ return next_attribute.attr.bit.reverse; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isStandout() -> bool
{ return next_attribute.attr.bit.standout; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isInvisible() -> bool
{ return next_attribute.attr.bit.invisible; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isProtected() -> bool
{ return next_attribute.attr.bit.protect; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isCrossedOut() -> bool
{ return next_attribute.attr.bit.crossed_out; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isDoubleUnderline() -> bool
{ return next_attribute.attr.bit.dbl_underline; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isAltCharset() -> bool
{ return next_attribute.attr.bit.alt_charset; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isPCcharset() -> bool
{ return next_attribute.attr.bit.pc_charset; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isTransparent() -> bool
{ return next_attribute.attr.bit.transparent; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isColorOverlay() -> bool
{ return next_attribute.attr.bit.color_overlay; }

//----------------------------------------------------------------------
inline auto FVTermAttribute::isInheritBackground() -> bool
{ return next_attribute.attr.bit.inherit_background; }

}  // namespace finalcut

#endif  // FVTERMATTRIBUTE_H