That Terminal
A terminal emulator designed for video making purposes.
cell.hh
Go to the documentation of this file.
1 #ifndef bqtCellHH
2 #define bqtCellHH
6 #include <cstdint>
7 #include <cstring>
8 
38 struct Cell
39 {
40  // 24-bit color foreground,background = 48 bits total
41  // 32-bit character
42  std::uint_least32_t fgcolor;
43  std::uint_least32_t bgcolor;
44  char32_t ch;
45  bool bold: 1;
46  bool dim: 1;
47  bool italic: 1;
48  bool underline: 1;
49  bool underline2: 1;
50  bool overstrike: 1;
51  bool inverse: 1;
52  bool framed: 1;
53  bool encircled: 1;
54  bool overlined: 1;
55  bool fraktur: 1;
56  bool conceal: 1;
57  unsigned char render_size: 2;
58  unsigned char blink: 2;
59 
60  unsigned char scriptsize: 2;
61  bool proportional: 1;
62  bool ideo_underline: 1;
63  bool ideo_underline2: 1;
64  bool ideo_overline: 1;
65  bool ideo_overline2: 1;
66  bool ideo_stress: 1;
67  unsigned padding: 6;
68 
69  bool protect: 1;
70  bool dirty: 1;
71 
72  /* Total size: 4 * 32 bits = 128 bits (16 bytes) */
73 
74  /* Constructor: Initializes the object with default attributes.
75  * Sets the character as a space, color as light-gray on black, and the dirty flag.
76  */
77  Cell()
78  {
79  std::memset(this, 0, sizeof(Cell));
80  fgcolor = 0xCCCCCC;
81  bgcolor = 0x000000;
82  ch = U' ';
83  dirty = true;
84  }
85 
91  bool operator== (const Cell& b) const
92  {
93  Cell tmp1 = *this;
94  Cell tmp2 = b;
95  tmp1.dirty = false; tmp1.protect = false;
96  tmp2.dirty = false; tmp2.protect = false;
97  return std::memcmp(&tmp1, &tmp2, sizeof(Cell)) == 0;
98  /*
99  return std::tuple(fgcolor,bgcolor,ch,bold,dim,italic,
100  underline,underline2,overstrike,inverse,blink,
101  framed,encircled,fraktur,conceal,overlined,
102  scriptsize,proportional,
103  ideo_underline,ideo_underline2,ideo_overline,ideo_overline2,ideo_stress,
104  render_size)
105  == std::tuple(b.fgcolor,b.bgcolor,b.ch,b.bold,b.dim,b.italic,
106  b.underline,b.underline2,b.overstrike,b.inverse,b.blink,
107  b.framed,b.encircled,b.fraktur,b.conceal,b.overlined,
108  b.scriptsize,b.proportional,
109  b.ideo_underline,b.ideo_underline2,b.ideo_overline,b.ideo_overline2,b.ideo_stress,
110  b.render_size);
111  */
112  }
113 
118  bool operator!= (const Cell& b) const
119  {
120  return !operator==(b);
121  }
122 };
123 
124 #endif
Definition: cell.hh:39
bool ideo_overline2
bit 22
Definition: cell.hh:65
bool operator==(const Cell &b) const
Definition: cell.hh:91
bool framed
bit 7
Definition: cell.hh:52
unsigned char blink
bit 14-15
Definition: cell.hh:58
bool ideo_overline
bit 21
Definition: cell.hh:64
bool fraktur
bit 10
Definition: cell.hh:55
bool inverse
bit 6
Definition: cell.hh:51
std::uint_least32_t fgcolor
foreground color
Definition: cell.hh:42
bool conceal
bit 11
Definition: cell.hh:56
bool underline
bit 3
Definition: cell.hh:48
unsigned char render_size
bit 12-13 0=normal,1=doublewidth,2=doublewidth+topline,3=doublewidth+bottomline
Definition: cell.hh:57
bool dirty
bit 31 (placed last for efficient access)
Definition: cell.hh:70
unsigned char scriptsize
bit 16-17: 0=normal,1=superscript,2=subscript
Definition: cell.hh:60
unsigned padding
bit 24,25,26, 27,28,29
Definition: cell.hh:67
std::uint_least32_t bgcolor
background color
Definition: cell.hh:43
bool encircled
bit 8
Definition: cell.hh:53
bool protect
bit 30
Definition: cell.hh:69
bool overlined
bit 9
Definition: cell.hh:54
bool proportional
bit 18
Definition: cell.hh:61
bool underline2
bit 4
Definition: cell.hh:49
bool dim
bit 1
Definition: cell.hh:46
bool bold
bit 0
Definition: cell.hh:45
bool ideo_stress
bit 23
Definition: cell.hh:66
bool overstrike
bit 5
Definition: cell.hh:50
bool operator!=(const Cell &b) const
Definition: cell.hh:118
bool italic
bit 2
Definition: cell.hh:47
bool ideo_underline2
bit 20
Definition: cell.hh:63
bool ideo_underline
bit 19
Definition: cell.hh:62
char32_t ch
the character symbol (unicode codepoint)
Definition: cell.hh:44