summaryrefslogtreecommitdiff
path: root/src/ui/text.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-25 15:08:57 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-25 15:08:57 +0200
commit978421e3b55833439b0701bf78a18974a17bb79e (patch)
tree401be0fe351bc9ba4ecb9594a6e8438dfff4bebf /src/ui/text.c
parentc69b6bb31e7a4ffefc725e95be50de1d64cf27ed (diff)
Text: Trying more conservative word wrapping rules
IssueID #201
Diffstat (limited to 'src/ui/text.c')
-rw-r--r--src/ui/text.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index 8107b886..c4ad8172 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -836,6 +836,19 @@ static enum iFontId fontId_Text_(const iFont *font) {
836 return (enum iFontId) (font - text_.fonts); 836 return (enum iFontId) (font - text_.fonts);
837} 837}
838 838
839iLocalDef iBool isWrapPunct_(iChar c) {
840 /* Punctuation that participates in word-wrapping. */
841 return (c == '/' || c == '=' || c == '-' || c == ',' || c == ';' || c == '.' || c == ':' || c == 0xad);
842}
843
844iLocalDef iBool isClosingBracket_(iChar c) {
845 return (c == ')' || c == ']' || c == '}' || c == '>');
846}
847
848iLocalDef iBool isBracket_(iChar c) {
849 return (c == '(' || c == '[' || c == '{' || c == '<' || isClosingBracket_(c));
850}
851
839iLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) { 852iLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) {
840 /* Line wrapping boundaries are determined by looking at a character and the 853 /* Line wrapping boundaries are determined by looking at a character and the
841 last character processed. We want to wrap at natural word boundaries where 854 last character processed. We want to wrap at natural word boundaries where
@@ -844,14 +857,13 @@ iLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) {
844 can wrap text like foo/bar/baz-abc-def.xyz at any puncation boundaries, 857 can wrap text like foo/bar/baz-abc-def.xyz at any puncation boundaries,
845 without wrapping on other punctuation used for expressive purposes like 858 without wrapping on other punctuation used for expressive purposes like
846 emoticons :-) */ 859 emoticons :-) */
847 if (c == '.' && (prevC == '(' || prevC == '[' || prevC == '.')) { 860 if (isClosingBracket_(c)) {
848 /* Start of a [...], perhaps? */ 861 return iTrue;
849 return iFalse;
850 } 862 }
851 if (isSpace_Char(prevC)) { 863 if (isSpace_Char(prevC)) {
852 return iFalse; 864 return iFalse;
853 } 865 }
854 if (c == '/' || c == '-' || c == ',' || c == ';' || c == ':' || c == '.' || c == 0xad) { 866 if ((c == '/' || c == '-' || c == '_' || c == '+') && !isWrapPunct_(prevC)) {
855 return iTrue; 867 return iTrue;
856 } 868 }
857 return isSpace_Char(c); 869 return isSpace_Char(c);