From 238c8dc129709792369f17447b9888b04089ed83 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 17 Nov 2021 00:27:31 +0100 Subject: [PATCH] Rewrite the while clause I can't get the character if we are outside of the area so we need to first check, then get the character, then do all the other tests --- src/terminalDisplay/TerminalPainter.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/terminalDisplay/TerminalPainter.cpp b/src/terminalDisplay/TerminalPainter.cpp index 01af24bd..b25968a3 100644 --- a/src/terminalDisplay/TerminalPainter.cpp +++ b/src/terminalDisplay/TerminalPainter.cpp @@ -131,10 +131,14 @@ void TerminalPainter::drawContents(Character *image, const Character &char_value = image[display->loc(x, y)]; if (char_value.canBeGrouped(bidiEnabled, doubleWidth)) { - Character next_char = image[display->loc(x + len, y)]; + while (isInsideDrawArea(x + len)) { + Character next_char = image[display->loc(x + len, y)]; + + if (!hasSameColors(x + len) || !hasSameRendition(x + len) || !hasSameWidth(x + len) || !hasSameLineDrawStatus(x + len) + || !isSameScript(next_char) || !next_char.canBeGrouped(bidiEnabled, doubleWidth)) { + break; + } - while (isInsideDrawArea(x + len) && hasSameColors(x + len) && hasSameRendition(x + len) && hasSameWidth(x + len) - && hasSameLineDrawStatus(x + len) && isSameScript(next_char) && next_char.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 @@ -157,7 +161,6 @@ void TerminalPainter::drawContents(Character *image, len++; } len++; - next_char = image[display->loc(x + len, y)]; } } else { // Group spaces following any non-wide character with the character. This allows for