1 #pragma once
2 
3 #include "highlight.h"
4 #include "konsole_wcwidth.h"
5 
6 #include <QColor>
7 
8 class Cell {
9 public:
10 	/// Create a cell having a specified HighlightAttribute
Cell(uint character,const HighlightAttribute & attribute)11 	Cell(uint character, const HighlightAttribute& attribute) noexcept :
12 		m_highlight(attribute)
13 	{
14 		SetCharacter(character);
15 	}
16 
Cell(uint character,QColor fgColor,QColor bgColor,QColor spColor,bool bold,bool italic,bool underline,bool undercurl,bool reverse)17 	Cell(
18 		uint character,
19 		QColor fgColor,
20 		QColor bgColor,
21 		QColor spColor,
22 		bool bold,
23 		bool italic,
24 		bool underline,
25 		bool undercurl,
26 		bool reverse) noexcept :
27 		Cell{
28 			character,
29 			{ fgColor, bgColor, spColor, reverse, italic, bold, underline, undercurl } }
30 	{
31 	}
32 
33 	/// Create an empty Cell with a background color
Cell(QColor bgColor)34 	Cell(QColor bgColor) noexcept :
35 		Cell{
36 			' ',
37 			{ QColor::Invalid, bgColor, QColor::Invalid, false, false, false, false, false } }
38 	{
39 	}
40 
41 	/// Default cells are space characters using invalid/default colors
42 	Cell() = default;
43 
44 	/// Create a cell marked as invalid
45 	static Cell MakeInvalidCell();
46 
47 	void SetCharacter(uint character);
48 
GetCharacter()49 	uint GetCharacter() const { return m_character; };
50 
IsDoubleWidth()51 	bool IsDoubleWidth() const { return m_isDoubleWidth; };
52 
GetForegroundColor()53 	QColor GetForegroundColor() const { return m_highlight.GetForegroundColor(); }
54 
GetBackgroundColor()55 	QColor GetBackgroundColor() const { return m_highlight.GetBackgroundColor(); }
56 
GetSpecialColor()57 	QColor GetSpecialColor() const { return m_highlight.GetSpecialColor(); }
58 
IsReverse()59 	bool IsReverse() const { return m_highlight.IsReverse(); }
60 
IsItalic()61 	bool IsItalic() const { return m_highlight.IsItalic(); }
62 
IsBold()63 	bool IsBold() const { return m_highlight.IsBold(); }
64 
IsUnderline()65 	bool IsUnderline() const { return m_highlight.IsUnderline(); }
66 
IsUndercurl()67 	bool IsUndercurl() const { return m_highlight.IsUndercurl(); }
68 
69 	/// Two cells are equal if both are valid, and all attributes are the same
70 	bool operator==(const Cell& other) const;
71 
72 private:
73 	uint m_character{ ' ' };
74 	bool m_isValid{ true };
75 	bool m_isDoubleWidth{ false };
76 
77 	HighlightAttribute m_highlight;
78 };
79