sources/coloredline.cpp

changeset 69
eb4c25284a19
parent 63
0da5f358f298
child 73
07dda51a7a8e
equal deleted inserted replaced
68:202e74157de5 69:eb4c25284a19
61 { "Cyan", CYAN, true }, // v 61 { "Cyan", CYAN, true }, // v
62 }; 62 };
63 63
64 // ------------------------------------------------------------------------------------------------- 64 // -------------------------------------------------------------------------------------------------
65 // 65 //
66 METHOD 66 void ColoredLine::finalize()
67 ColoredLine::finalize() -> void
68 { 67 {
69 if (m_activeColor != DEFAULT) 68 if (m_activeColor != DEFAULT)
70 set_color (m_activeColor, false); 69 set_color (m_activeColor, false);
71 70
72 if (m_boldActive) 71 if (m_boldActive)
75 m_final = true; 74 m_final = true;
76 } 75 }
77 76
78 // ------------------------------------------------------------------------------------------------- 77 // -------------------------------------------------------------------------------------------------
79 // 78 //
80 METHOD 79 void ColoredLine::add_char (char ch)
81 ColoredLine::add_char (char ch) -> void
82 { 80 {
83 if (m_final) 81 if (m_final)
84 return; // Don't touch finalized lines. 82 return; // Don't touch finalized lines.
85 83
86 if (ch == '\x1C' and m_colorCodeStage == 0) 84 if (ch == '\x1C' and m_colorCodeStage == 0)
125 } 123 }
126 } 124 }
127 125
128 // ------------------------------------------------------------------------------------------------- 126 // -------------------------------------------------------------------------------------------------
129 // 127 //
130 METHOD 128 void ColoredLine::set_color (Color a, bool on)
131 ColoredLine::set_color (Color a, bool on) -> void
132 { 129 {
133 switch (a) 130 switch (a)
134 { 131 {
135 case BLACK: m_data << (on ? RLINE_ON_BLACK : RLINE_OFF_BLACK); break; 132 case BLACK: m_data << (on ? RLINE_ON_BLACK : RLINE_OFF_BLACK); break;
136 case RED: m_data << (on ? RLINE_ON_RED : RLINE_OFF_RED); break; 133 case RED: m_data << (on ? RLINE_ON_RED : RLINE_OFF_RED); break;
146 } 143 }
147 144
148 // ------------------------------------------------------------------------------------------------- 145 // -------------------------------------------------------------------------------------------------
149 // How many rows does this line take up? 146 // How many rows does this line take up?
150 // 147 //
151 METHOD 148 int ColoredLine::rows (int cols) const
152 ColoredLine::rows (int cols) const -> int
153 { 149 {
154 int rows = length() / cols; 150 int rows = length() / cols;
155 151
156 if (length() % cols != 0) 152 if (length() % cols != 0)
157 rows++; 153 rows++;

mercurial