From f1f614c0c394df314c5741c4e1d0f88ada22bdc4 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 25 Mar 2021 19:40:41 +0200 Subject: Text: Improved word wrapping This was complicated by the wrap position being placed one character later than intended. IssueID #201 --- src/ui/text.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/text.c b/src/ui/text.c index c4ad8172..ac879af4 100644 --- a/src/ui/text.c +++ b/src/ui/text.c @@ -845,9 +845,9 @@ iLocalDef iBool isClosingBracket_(iChar c) { return (c == ')' || c == ']' || c == '}' || c == '>'); } -iLocalDef iBool isBracket_(iChar c) { - return (c == '(' || c == '[' || c == '{' || c == '<' || isClosingBracket_(c)); -} +//iLocalDef iBool isBracket_(iChar c) { +// return (c == '(' || c == '[' || c == '{' || c == '<' || isClosingBracket_(c)); +//} iLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) { /* Line wrapping boundaries are determined by looking at a character and the @@ -857,13 +857,13 @@ iLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) { can wrap text like foo/bar/baz-abc-def.xyz at any puncation boundaries, without wrapping on other punctuation used for expressive purposes like emoticons :-) */ - if (isClosingBracket_(c)) { + if (isClosingBracket_(prevC) && !isWrapPunct_(c)) { return iTrue; } if (isSpace_Char(prevC)) { return iFalse; } - if ((c == '/' || c == '-' || c == '_' || c == '+') && !isWrapPunct_(prevC)) { + if ((prevC == '/' || prevC == '-' || prevC == '_' || prevC == '+') && !isWrapPunct_(c)) { return iTrue; } return isSpace_Char(c); @@ -1102,7 +1102,7 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) { xposExtend = iMax(xposExtend, xpos); xposMax = iMax(xposMax, xposExtend); if (args->continueFrom_out && ((mode & noWrapFlag_RunMode) || isWrapBoundary_(prevCh, ch))) { - lastWordEnd = chPos; + lastWordEnd = currentPos; } #if defined (LAGRANGE_ENABLE_KERNING) /* Check the next character. */ -- cgit v1.2.3