summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-08-04 21:19:27 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-08-04 21:19:27 (GMT)
commit17644679ccfb5282c131a7181c9618d92191e7a8 (patch)
tree1f0676388b30d178a633f3e202a04537bee143ae /generic/tkTextDisp.c
parent08a5c69704132511cb35781483e60ef2e5e534f7 (diff)
downloadtk-17644679ccfb5282c131a7181c9618d92191e7a8.zip
tk-17644679ccfb5282c131a7181c9618d92191e7a8.tar.gz
tk-17644679ccfb5282c131a7181c9618d92191e7a8.tar.bz2
Fix word-wrapping of non-breaking spaces in the text widget to work reliably.
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 164fc5d..721647d 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkTextDisp.c,v 1.73 2009/06/30 00:56:29 das Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.74 2009/08/04 21:19:27 dkf Exp $
*/
#include "tkInt.h"
@@ -5391,18 +5391,18 @@ TkTextSeeCmd(
oneThird = lineWidth/3;
if (delta < 0) {
if (delta < -oneThird) {
- dInfoPtr->newXPixelOffset = (x - lineWidth/2);
+ dInfoPtr->newXPixelOffset = x - lineWidth/2;
} else {
- dInfoPtr->newXPixelOffset -= ((-delta) );
+ dInfoPtr->newXPixelOffset += delta;
}
} else {
delta -= lineWidth - width;
if (delta <= 0) {
return TCL_OK;
} else if (delta > oneThird) {
- dInfoPtr->newXPixelOffset = (x - lineWidth/2);
+ dInfoPtr->newXPixelOffset = x - lineWidth/2;
} else {
- dInfoPtr->newXPixelOffset += (delta );
+ dInfoPtr->newXPixelOffset += delta;
}
}
}
@@ -7203,11 +7203,21 @@ TkTextCharLayoutProc(
} else {
for (count = bytesThatFit, p += bytesThatFit - 1; count > 0;
count--, p--) {
- if (isspace(UCHAR(*p))) {
+ /*
+ * Don't use isspace(); effects are unpredictable and can lead to
+ * odd word-wrapping problems on some platforms. Also don't use
+ * Tcl_UniCharIsSpace here either, as it identifies non-breaking
+ * spaces as places to break. What we actually want is only the
+ * ASCII space characters, so use them explicitly...
+ */
+
+ switch (*p) {
+ case '\t': case '\n': case '\v': case '\f': case '\r': case ' ':
chunkPtr->breakIndex = count;
- break;
+ goto checkForNextChunk;
}
}
+ checkForNextChunk:
if ((bytesThatFit + byteOffset) == segPtr->size) {
for (nextPtr = segPtr->nextPtr; nextPtr != NULL;
nextPtr = nextPtr->nextPtr) {