summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkTextDisp.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index f28ec6a..2171cd0 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