sources/coloredline.h

branch
protocol5
changeset 195
be953e1621d9
parent 150
37db42ad451a
parent 191
2e6cbacafdc7
equal deleted inserted replaced
176:060a13878ca0 195:be953e1621d9
1 /* 1 /*
2 Copyright 2014 - 2016 Teemu Piippo 2 Copyright 2014 - 2021 Teemu Piippo
3 All rights reserved. 3 All rights reserved.
4 4
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions 6 modification, are permitted provided that the following conditions
7 are met: 7 are met:
47 WHITE = COLOR_WHITE, 47 WHITE = COLOR_WHITE,
48 DEFAULT = 8, 48 DEFAULT = 8,
49 NUM_COLORS 49 NUM_COLORS
50 }; 50 };
51 51
52 // ------------------------------------------------------------------------------------------------- 52 constexpr int RLINE_ON_COLOR = 256;
53 // 53 constexpr int RLINE_OFF_COLOR = 264;
54 enum 54 constexpr int RLINE_ON_BOLD = 272;
55 { 55 constexpr int RLINE_OFF_BOLD = 273;
56 RLINE_ON_COLOR = 256,
57 RLINE_OFF_COLOR = 264,
58 RLINE_ON_BOLD = 272,
59 RLINE_OFF_BOLD
60 };
61 56
62 // -------------------------------------------------------------------------------------------------
63 //
64 class ColoredLine 57 class ColoredLine
65 { 58 {
66 public: 59 public:
67 ColoredLine(); 60 ColoredLine();
68 61
69 const Vector<int>& data() const { return m_data; } 62 const std::vector<int>& data() const { return m_data; }
70 int length() const { return m_length; } 63 int length() const { return m_length; }
71 void addChar(char ch); 64 void addChar(char ch);
72 void addString(const String& msg); 65 void addString(const std::string& msg);
73 void finalize(); 66 void finalize();
74 int rows(int cols) const; 67 int rows(int cols) const;
75 68
76 private: 69 private:
77 void activateColor(Color color, bool bold); 70 void activateColor(Color color, bool bold);
78 void setColor(Color a, bool on); 71 void setColor(Color a, bool on);
79 72
80 Vector<int> m_data; 73 std::vector<int> m_data;
81 int m_length; 74 int m_length;
82 bool m_final; 75 bool m_final;
83 Color m_activeColor; 76 Color m_activeColor;
84 bool m_boldActive; 77 bool m_boldActive;
85 int m_colorCodeStage; 78 int m_colorCodeStage;
86 String m_string; 79 std::string m_string;
87 String m_incomingColorName; 80 std::string m_incomingColorName;
88 }; 81 };
89 82
90 END_ZFC_NAMESPACE 83 END_ZFC_NAMESPACE

mercurial