Commit 1cd4dea4 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Move canGroup code to Character.h

This is a function that's completely related to character
and has nothing to do with painting, so the correct place
for it is on the Character class.

This will make testing easier, too.
parent b1410ced
......@@ -153,6 +153,15 @@ public:
QVector<uint> ucs4Str = str.toUcs4();
return stringWidth(ucs4Str.constData(), ucs4Str.length());
}
inline bool canBeGrouped(bool bidirectionalEnabled, bool isDoubleWidth) const
{
if (QChar::script(character) == QChar::Script_Braille) {
return false;
}
return character <= 0x7e || (rendition & RE_EXTENDED_CHAR) || (bidirectionalEnabled && !isDoubleWidth);
}
};
constexpr bool operator==(const Character &a, const Character &b)
......
......@@ -138,24 +138,11 @@ void TerminalPainter::drawContents(Character *image,
return currentScript == script;
};
// returns true if it's a braile char, false otherwise.
const auto isBraileChar = [&](int column) -> bool {
char32_t maybeBraile = image[display->loc(column, y)].character;
return maybeBraile >= 0x2800 && maybeBraile <= 0x28FF;
};
const auto canBeGrouped = [&](int column) {
if (isBraileChar(x)) {
return false;
}
return image[display->loc(column, y)].character <= 0x7e || (image[display->loc(column, y)].rendition & RE_EXTENDED_CHAR)
|| (bidiEnabled && !doubleWidth);
};
const Character &char_value = image[display->loc(x, y)];
if (canBeGrouped(x)) {
if (char_value.canBeGrouped(bidiEnabled, doubleWidth)) {
while (isInsideDrawArea(x + len) && hasSameColors(x + len) && hasSameRendition(x + len) && hasSameWidth(x + len)
&& hasSameLineDrawStatus(x + len) && isSameScript(x + len) && canBeGrouped(x + len)) {
&& hasSameLineDrawStatus(x + len) && isSameScript(x + len) && image[display->loc(x + len, y)].canBeGrouped(bidiEnabled, doubleWidth)) {
const uint c = image[display->loc(x + len, y)].character;
if ((image[display->loc(x + len, y)].rendition & RE_EXTENDED_CHAR) != 0) {
// sequence of characters
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment