sources/coloredline.h

branch
protocol5
changeset 106
7b156b764d11
parent 78
c1d43ade656e
parent 100
d301ead29d7c
child 131
4996c8684b93
equal deleted inserted replaced
104:a76af67a3a4b 106:7b156b764d11
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #pragma once 31 #pragma once
32 #include "main.h" 32 #include "main.h"
33 BEGIN_ZFC_NAMESPACE
34
35 // The order of these colors appears to differ between curses distributions (PDCurses and its
36 // win32a for instance have blue and red swapped). So we need to explicitly define the values
37 // of the enumerators based on their curses values.
38 enum Color
39 {
40 BLACK = COLOR_BLACK,
41 RED = COLOR_RED,
42 GREEN = COLOR_GREEN,
43 YELLOW = COLOR_YELLOW,
44 BLUE = COLOR_BLUE,
45 MAGENTA = COLOR_MAGENTA,
46 CYAN = COLOR_CYAN,
47 WHITE = COLOR_WHITE,
48 DEFAULT = 8,
49 NUM_COLORS
50 };
33 51
34 // ------------------------------------------------------------------------------------------------- 52 // -------------------------------------------------------------------------------------------------
35 // 53 //
36 enum 54 enum
37 { 55 {
38 RLINE_ON_BLACK = 256, 56 RLINE_ON_COLOR = 256,
39 RLINE_ON_RED, 57 RLINE_OFF_COLOR = 264,
40 RLINE_ON_GREEN, 58 RLINE_ON_BOLD = 272,
41 RLINE_ON_YELLOW, 59 RLINE_OFF_BOLD
42 RLINE_ON_BLUE,
43 RLINE_ON_MAGENTA,
44 RLINE_ON_CYAN,
45 RLINE_ON_WHITE,
46 RLINE_ON_BOLD,
47 RLINE_OFF_BLACK,
48 RLINE_OFF_RED,
49 RLINE_OFF_GREEN,
50 RLINE_OFF_YELLOW,
51 RLINE_OFF_BLUE,
52 RLINE_OFF_MAGENTA,
53 RLINE_OFF_CYAN,
54 RLINE_OFF_WHITE,
55 RLINE_OFF_BOLD,
56 }; 60 };
57 61
58 // ------------------------------------------------------------------------------------------------- 62 // -------------------------------------------------------------------------------------------------
59 // 63 //
60 class ColoredLine 64 class ColoredLine
61 { 65 {
62 public: 66 public:
63 ColoredLine() {} 67 ColoredLine();
64 68
65 const Vector<int>& data() const { return m_data; } 69 const Vector<int>& data() const { return m_data; }
66 int length() const { return m_length; } 70 int length() const { return m_length; }
67 void add_char (char ch); 71 void add_char (char ch);
68 void add_string (const String& msg); 72 void add_string (const String& msg);
71 75
72 private: 76 private:
73 void set_color (Color a, bool on); 77 void set_color (Color a, bool on);
74 78
75 Vector<int> m_data; 79 Vector<int> m_data;
76 int m_length = 0; 80 int m_length;
77 bool m_final = false; 81 bool m_final;
78 Color m_activeColor = DEFAULT; 82 Color m_activeColor;
79 bool m_boldActive = false; 83 bool m_boldActive;
80 int m_colorCodeStage = 0; 84 int m_colorCodeStage;
81 String m_string; 85 String m_string;
82 }; 86 };
87
88 END_ZFC_NAMESPACE

mercurial