Changeset View
Changeset View
Standalone View
Standalone View
src/Character.h
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | const RenditionFlags RE_CURSOR = (1 << 5); | 49 | const RenditionFlags RE_CURSOR = (1 << 5); | ||
50 | const RenditionFlags RE_EXTENDED_CHAR = (1 << 6); | 50 | const RenditionFlags RE_EXTENDED_CHAR = (1 << 6); | ||
51 | const RenditionFlags RE_FAINT = (1 << 7); | 51 | const RenditionFlags RE_FAINT = (1 << 7); | ||
52 | const RenditionFlags RE_STRIKEOUT = (1 << 8); | 52 | const RenditionFlags RE_STRIKEOUT = (1 << 8); | ||
53 | const RenditionFlags RE_CONCEAL = (1 << 9); | 53 | const RenditionFlags RE_CONCEAL = (1 << 9); | ||
54 | const RenditionFlags RE_OVERLINE = (1 << 10); | 54 | const RenditionFlags RE_OVERLINE = (1 << 10); | ||
55 | 55 | | |||
56 | /** | 56 | /** | ||
57 | * Unicode character in the range of U+2500 ~ U+257F are known as line | | |||
58 | * characters, or box-drawing characters. Currently, konsole draws those | | |||
59 | * characters itself, instead of using the glyph provided by the font. | | |||
60 | * Unfortunately, the triple and quadruple dash lines (┄┅┆┇┈┉┊┋) are too | | |||
61 | * detailed too be drawn cleanly at normal font scales without anti | | |||
62 | * -aliasing, so those are drawn as regular characters. | | |||
63 | */ | | |||
64 | inline bool isSupportedLineChar(uint codePoint) | | |||
65 | { | | |||
66 | return ((codePoint & 0xFF80) == 0x2500 // Unicode block: Mathematical Symbols - Box Drawing | | |||
67 | && !(0x2504 <= codePoint && codePoint <= 0x250B)) || // Triple and quadruple dash range | | |||
68 | (codePoint >= 0x2580 && codePoint <= 0x259F); // Block characters | | |||
69 | } | | |||
70 | | ||||
71 | /** | | |||
72 | * A single character in the terminal which consists of a unicode character | 57 | * A single character in the terminal which consists of a unicode character | ||
73 | * value, foreground and background colors and a set of rendition attributes | 58 | * value, foreground and background colors and a set of rendition attributes | ||
74 | * which specify how it should be drawn. | 59 | * which specify how it should be drawn. | ||
75 | */ | 60 | */ | ||
76 | class Character | 61 | class Character | ||
77 | { | 62 | { | ||
78 | public: | 63 | public: | ||
79 | /** | 64 | /** | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
138 | friend bool operator ==(const Character &a, const Character &b); | 123 | friend bool operator ==(const Character &a, const Character &b); | ||
139 | 124 | | |||
140 | /** | 125 | /** | ||
141 | * Compares two characters and returns true if they have different unicode character values, | 126 | * Compares two characters and returns true if they have different unicode character values, | ||
142 | * renditions or colors. | 127 | * renditions or colors. | ||
143 | */ | 128 | */ | ||
144 | friend bool operator !=(const Character &a, const Character &b); | 129 | friend bool operator !=(const Character &a, const Character &b); | ||
145 | 130 | | |||
146 | inline bool isLineChar() const | | |||
147 | { | | |||
148 | if (rendition & RE_EXTENDED_CHAR) { | | |||
149 | return false; | | |||
150 | } else { | | |||
151 | return isSupportedLineChar(character); | | |||
152 | } | | |||
153 | } | | |||
154 | | ||||
155 | inline bool isSpace() const | 131 | inline bool isSpace() const | ||
156 | { | 132 | { | ||
157 | if (rendition & RE_EXTENDED_CHAR) { | 133 | if (rendition & RE_EXTENDED_CHAR) { | ||
158 | return false; | 134 | return false; | ||
159 | } else { | 135 | } else { | ||
160 | return QChar(character).isSpace(); | 136 | return QChar(character).isSpace(); | ||
161 | } | 137 | } | ||
162 | } | 138 | } | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |