Commit 01b73503 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Move isSameRendition to Character

This also simplifies a bit of TerminalPainter
parent 8d9cdd1b
......@@ -190,6 +190,11 @@ public:
{
return lhs.foregroundColor == foregroundColor && lhs.backgroundColor == backgroundColor;
}
inline bool hasSameRendition(const Character &lhs) const
{
return (lhs.rendition & ~RE_EXTENDED_CHAR) == (rendition & ~RE_EXTENDED_CHAR);
};
};
constexpr bool operator==(const Character &a, const Character &b)
......
......@@ -102,9 +102,6 @@ void TerminalPainter::drawContents(Character *image,
return column <= rect.right();
};
const auto hasSameRendition = [&](int column) {
return (image[display->loc(column, y)].rendition & ~RE_EXTENDED_CHAR) == (currentRendition & ~RE_EXTENDED_CHAR);
};
const auto hasSameWidth = [&](int column) {
const int characterLoc = qMin(display->loc(column, y) + 1, imageSize - 1);
return (image[characterLoc].character == 0) == doubleWidth;
......@@ -119,8 +116,8 @@ void TerminalPainter::drawContents(Character *image,
while (isInsideDrawArea(x + len)) {
Character next_char = image[display->loc(x + len, y)];
if (!char_value.hasSameColors(next_char) || !hasSameRendition(x + len) || !hasSameWidth(x + len) || !hasSameLineDrawStatus(x + len)
|| !char_value.isSameScript(next_char) || !next_char.canBeGrouped(bidiEnabled, doubleWidth)) {
if (!char_value.hasSameColors(next_char) || !char_value.hasSameRendition(next_char) || !hasSameWidth(x + len)
|| !hasSameLineDrawStatus(x + len) || !char_value.isSameScript(next_char) || !next_char.canBeGrouped(bidiEnabled, doubleWidth)) {
break;
}
......@@ -152,7 +149,7 @@ void TerminalPainter::drawContents(Character *image,
// rendering ambiguous characters with wide glyphs without clipping them.
while (!doubleWidth && isInsideDrawArea(x + len)) {
const Character next_char = image[display->loc(x + len, y)];
if (next_char.character == ' ' && char_value.hasSameColors(next_char) && hasSameRendition(x + len)) {
if (next_char.character == ' ' && char_value.hasSameColors(next_char) && char_value.hasSameRendition(next_char)) {
// univec intentionally not modified - trailing spaces are meaningless
len++;
}
......
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