summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-10-09 18:28:50 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-10-09 18:28:50 (GMT)
commit6aadb98795f902f7b7d8ca8ce580a4cb6e18daca (patch)
tree41908f946cdc75973cf2aa8f7ca984168ce82144 /generic/tkTextDisp.c
parent6c0dafab46875ddb6dd0a91f5e056a8d87722ca6 (diff)
parent47ddcd1deb1c2db07e34e62d6f337b13efaaa9ad (diff)
downloadtk-6aadb98795f902f7b7d8ca8ce580a4cb6e18daca.zip
tk-6aadb98795f902f7b7d8ca8ce580a4cb6e18daca.tar.gz
tk-6aadb98795f902f7b7d8ca8ce580a4cb6e18daca.tar.bz2
Fixed [1082213fff] - word wrapping should trim excess spaces
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index eb917cf..a6e665a 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -7542,6 +7542,9 @@ TkTextCharLayoutProc(
* (b) at least one pixel of the character is visible, we have not
* already exceeded the character limit, and the next character is a
* white space character.
+ * In the specific case of 'word' wrapping mode however, include all space
+ * characters following the characters that fit in the space we've got,
+ * even if no pixel of them is visible.
*/
p = segPtr->body.chars + byteOffset;
@@ -7604,6 +7607,21 @@ TkTextCharLayoutProc(
nextX = maxX;
bytesThatFit++;
}
+ if (wrapMode == TEXT_WRAPMODE_WORD) {
+ while (p[bytesThatFit] == ' ') {
+ /*
+ * Space characters that would go at the beginning of the
+ * next line are allocated to the current line. This gives
+ * the effect of trimming white spaces that would otherwise
+ * be seen at the beginning of wrapped lines.
+ * Note that testing for '\t' is useless here because the
+ * chunk always includes at most one trailing \t, see
+ * LayoutDLine.
+ */
+
+ bytesThatFit++;
+ }
+ }
if (p[bytesThatFit] == '\n') {
/*
* A newline character takes up no space, so if the previous