summaryrefslogtreecommitdiff
path: root/src/ui/text.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-08-24 14:25:02 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-08-24 14:25:02 +0300
commitb181150bad024e35a85386085efb096abd7d6901 (patch)
tree8ea6757d3b46ae77c84e9873b7eb9c5bbdbfab93 /src/ui/text.c
parentb770246f447761d178336c53808a53f567ba4eb9 (diff)
InputWidget: Reverted an earlier change to fix cursor movement regression
In word-wrapped lines, a character will be hit multiple times and the latest hit is what counts.
Diffstat (limited to 'src/ui/text.c')
-rw-r--r--src/ui/text.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index 639d8f13..a499d293 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -195,7 +195,7 @@ static void init_Font(iFont *d, const iBlock *data, int height, float scale,
195 d->vertOffset = height * (1.0f - scale) / 2; 195 d->vertOffset = height * (1.0f - scale) / 2;
196 /* Custom tweaks. */ 196 /* Custom tweaks. */
197 if (data == &fontNotoSansSymbolsRegular_Embedded) { 197 if (data == &fontNotoSansSymbolsRegular_Embedded) {
198 d->vertOffset *= 1.2f; 198 d->vertOffset *= 1.2f;
199 } 199 }
200 else if (data == &fontNotoSansSymbols2Regular_Embedded) { 200 else if (data == &fontNotoSansSymbols2Regular_Embedded) {
201 d->vertOffset /= 2; 201 d->vertOffset /= 2;
@@ -1433,7 +1433,7 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1433 iBool isFirst = iTrue; 1433 iBool isFirst = iTrue;
1434 const iBool checkHitPoint = wrap && !isEqual_I2(wrap->hitPoint, zero_I2()); 1434 const iBool checkHitPoint = wrap && !isEqual_I2(wrap->hitPoint, zero_I2());
1435 const iBool checkHitChar = wrap && wrap->hitChar; 1435 const iBool checkHitChar = wrap && wrap->hitChar;
1436 iBool wasCharHit = iFalse; 1436 //iBool wasCharHit = iFalse;
1437 while (!isEmpty_Range(&wrapRuns)) { 1437 while (!isEmpty_Range(&wrapRuns)) {
1438 if (isFirst) { 1438 if (isFirst) {
1439 isFirst = iFalse; 1439 isFirst = iFalse;
@@ -1453,11 +1453,9 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1453 for (size_t runIndex = wrapRuns.start; runIndex < wrapRuns.end; runIndex++) { 1453 for (size_t runIndex = wrapRuns.start; runIndex < wrapRuns.end; runIndex++) {
1454 const iAttributedRun *run = at_Array(&attrText.runs, runIndex); 1454 const iAttributedRun *run = at_Array(&attrText.runs, runIndex);
1455 if (run->flags.isLineBreak) { 1455 if (run->flags.isLineBreak) {
1456 if (checkHitChar && !wasCharHit) { 1456 if (checkHitChar && wrap->hitChar == sourcePtr_AttributedText_(&attrText, run->logical.start)) {
1457 if (wrap->hitChar == sourcePtr_AttributedText_(&attrText, run->logical.start)) { 1457 wrap->hitAdvance_out = init_I2(wrapAdvance, yCursor);
1458 wrap->hitAdvance_out = init_I2(wrapAdvance, yCursor); 1458// wasCharHit = iTrue;
1459 wasCharHit = iTrue;
1460 }
1461 } 1459 }
1462 wrapPosRange.end = run->logical.start; 1460 wrapPosRange.end = run->logical.start;
1463 wrapResumePos = run->logical.end; 1461 wrapResumePos = run->logical.end;
@@ -1481,11 +1479,9 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1481 if (logPos < wrapPosRange.start || logPos >= wrapPosRange.end) { 1479 if (logPos < wrapPosRange.start || logPos >= wrapPosRange.end) {
1482 continue; 1480 continue;
1483 } 1481 }
1484 if (checkHitChar && !wasCharHit) { 1482 if (checkHitChar && wrap->hitChar == sourcePtr_AttributedText_(&attrText, logPos)) {
1485 if (wrap->hitChar == sourcePtr_AttributedText_(&attrText, logPos)) { 1483 wrap->hitAdvance_out = init_I2(wrapAdvance, yCursor);
1486 wrap->hitAdvance_out = init_I2(wrapAdvance, yCursor); 1484 //wasCharHit = iTrue;
1487 wasCharHit = iTrue;
1488 }
1489 } 1485 }
1490 /* Check if the hit point is on the left side of this line. */ 1486 /* Check if the hit point is on the left side of this line. */
1491 if (isHitPointOnThisLine && !wrap->hitChar_out && wrap->hitPoint.x < orig.x) { 1487 if (isHitPointOnThisLine && !wrap->hitChar_out && wrap->hitPoint.x < orig.x) {
@@ -1872,7 +1868,7 @@ static void drawBoundedN_Text_(int fontId, iInt2 pos, int xposBound, int color,
1872 (color & fillBackground_ColorId ? fillBackground_RunMode : 0) | 1868 (color & fillBackground_ColorId ? fillBackground_RunMode : 0) |
1873 runFlagsFromId_(fontId), 1869 runFlagsFromId_(fontId),
1874 .text = text, 1870 .text = text,
1875 .maxLen = maxLen, 1871 .maxLen = maxLen,
1876 .pos = pos, 1872 .pos = pos,
1877// .xposLayoutBound = xposBound, 1873// .xposLayoutBound = xposBound,
1878 .color = color & mask_ColorId, 1874 .color = color & mask_ColorId,