[escher/src/text_area] Add char limit in text_area line

Change-Id: I9284936f0202d788edc785aa3f7c82b45ab34cf5
This commit is contained in:
Hugo Saint-Vignes
2020-09-03 17:19:59 +02:00
committed by Émilie Feral
parent 51002066e9
commit b92c819ea2
8 changed files with 122 additions and 13 deletions

View File

@@ -28,6 +28,7 @@ KDPoint KDContext::pushOrPullString(const char * text, KDPoint p, const KDFont *
while (codePoint != UCodePointNull && (maxByteLength < 0 || codePointPointer < text + maxByteLength)) {
codePointPointer = decoder.stringPosition();
if (codePoint == UCodePointLineFeed) {
assert(position.y() < KDCOORDINATE_MAX - glyphSize.height());
position = KDPoint(0, position.y() + glyphSize.height());
codePoint = decoder.nextCodePoint();
} else if (codePoint == UCodePointTabulation) {

View File

@@ -30,6 +30,7 @@ KDSize KDFont::stringSizeUntil(const char * text, const char * limit) const {
currentStringPosition = decoder.stringPosition();
codePoint = decoder.nextCodePoint();
}
assert(stringSize.width() >= 0 && stringSize.height() >= 0);
return stringSize;
}

View File

@@ -1,6 +1,10 @@
#include <kandinsky/point.h>
#include <assert.h>
KDPoint KDPoint::translatedBy(KDPoint other) const {
assert((other.x() >= 0 && m_x <= KDCOORDINATE_MAX - other.x()) || (other.x() < 0 && m_x >= KDCOORDINATE_MIN - other.x()));
assert((other.y() >= 0 && m_y <= KDCOORDINATE_MAX - other.y()) || (other.y() < 0 && m_y >= KDCOORDINATE_MIN - other.y()));
return KDPoint(m_x+other.x(), m_y+other.y());
}