summaryrefslogtreecommitdiff
path: root/src/ui/text_simple.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-04 07:21:29 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-04 07:22:04 +0300
commit11bf1f990329764568f706835d237a9ad4c9f25d (patch)
tree502f4860a80372b6e9aa902fa6c19152d2ced368 /src/ui/text_simple.c
parent2bc59acda6a7417063449e1308e8317e5cbf9723 (diff)
Text: Fixed hang when wrapping a long word
The simple text renderer would get stuck in an infinite loop when encountering a word that wouldn't fit on a line. IssueID #330
Diffstat (limited to 'src/ui/text_simple.c')
-rw-r--r--src/ui/text_simple.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/ui/text_simple.c b/src/ui/text_simple.c
index 3afc631a..e88b09a8 100644
--- a/src/ui/text_simple.c
+++ b/src/ui/text_simple.c
@@ -169,6 +169,7 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
169 if (!notify_WrapText_(wrap, chPos, 0, iMax(xpos, xposExtend) - orig.x, iFalse)) { 169 if (!notify_WrapText_(wrap, chPos, 0, iMax(xpos, xposExtend) - orig.x, iFalse)) {
170 break; 170 break;
171 } 171 }
172 lastWordEnd = NULL;
172 xpos = xposExtend = orig.x; 173 xpos = xposExtend = orig.x;
173 ypos += d->height; 174 ypos += d->height;
174 prevCh = ch; 175 prevCh = ch;
@@ -240,21 +241,19 @@ static iRect runSimple_Font_(iFont *d, const iRunArgs *args) {
240 iAssert(wrap); 241 iAssert(wrap);
241 const char *wrapPos = currentPos; 242 const char *wrapPos = currentPos;
242 int advance = x1 - orig.x; 243 int advance = x1 - orig.x;
243 if (lastWordEnd != args->text.start && wrap->mode == word_WrapTextMode) { 244 if (lastWordEnd && wrap->mode == word_WrapTextMode) {
244 wrapPos = skipSpace_CStr(lastWordEnd); 245 wrapPos = skipSpace_CStr(lastWordEnd); /* go back */
245 wrapPos = iMin(wrapPos, args->text.end); 246 wrapPos = iMin(wrapPos, args->text.end);
246 advance = wrapAdvance; 247 advance = wrapAdvance;
247 } 248 }
248// if (args->continueFrom_out) {
249// *args->continueFrom_out = wrapPos;
250// }
251 if (!notify_WrapText_(wrap, wrapPos, 0, advance, iFalse)) { 249 if (!notify_WrapText_(wrap, wrapPos, 0, advance, iFalse)) {
252 break; 250 break;
253 } 251 }
252 lastWordEnd = NULL;
254 xpos = xposExtend = orig.x; 253 xpos = xposExtend = orig.x;
255 ypos += d->height; 254 ypos += d->height;
256 prevCh = 0; 255 prevCh = 0;
257 chPos = wrapPos; /* go back */ 256 chPos = wrapPos;
258 continue; 257 continue;
259 } 258 }
260 const int yLineMax = ypos + d->height; 259 const int yLineMax = ypos + d->height;