diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-08-04 21:19:27 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-08-04 21:19:27 (GMT) |
commit | 17644679ccfb5282c131a7181c9618d92191e7a8 (patch) | |
tree | 1f0676388b30d178a633f3e202a04537bee143ae | |
parent | 08a5c69704132511cb35781483e60ef2e5e534f7 (diff) | |
download | tk-17644679ccfb5282c131a7181c9618d92191e7a8.zip tk-17644679ccfb5282c131a7181c9618d92191e7a8.tar.gz tk-17644679ccfb5282c131a7181c9618d92191e7a8.tar.bz2 |
Fix word-wrapping of non-breaking spaces in the text widget to work reliably.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 24 |
2 files changed, 28 insertions, 12 deletions
@@ -1,16 +1,22 @@ +2009-08-04 Donal K. Fellows <dkf@users.sf.net> + + * generic/tkTextDisp.c (TkTextCharLayoutProc): Make the line breaking + algorithm (in the word-wrap case) do the right thing with non-breaking + spaces by restricting what we break on to ASCII spaces, which is good + enough for most purposes. + 2009-08-02 Jan Nijtmans <nijtmans@users.sf.net> - * win/tkWinClipboard.c correct check for winNT - * win/tkWinDialog.c eliminate many gcc warnings + * win/tkWinClipboard.c Correct check for winNT + * win/tkWinDialog.c Eliminate many gcc warnings * win/tkWinImage.c: * win/tkWinMenu.c: * win/tkWinWm.c: * win/tkWinX.c: - * win/ttkWinXPTheme.c: eliminate msvc warnings + * win/ttkWinXPTheme.c: Eliminate msvc warnings * win/tcl.m4: * win/configure - * win/.cvsignore: prevent files from being checked - in by accident. + * win/.cvsignore: Prevent files from being checked in by accident 2009-08-01 Donal K. Fellows <dkf@users.sf.net> 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) { |