diff options
author | vincentdarley <vincentdarley@noemail.net> | 2005-03-15 14:07:47 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley@noemail.net> | 2005-03-15 14:07:47 (GMT) |
commit | 45ca81172fbfd06be02fa43a8c18b13c367f72b7 (patch) | |
tree | 7242f76a7153ca660d31df00d87771a91ab8550c /generic | |
parent | c73b588232dac2b3f16f31260ed82285fd91da7f (diff) | |
download | tk-45ca81172fbfd06be02fa43a8c18b13c367f72b7.zip tk-45ca81172fbfd06be02fa43a8c18b13c367f72b7.tar.gz tk-45ca81172fbfd06be02fa43a8c18b13c367f72b7.tar.bz2 |
fix for display lines bug and panic
FossilOrigin-Name: 0c51bd2954e7aec2ee3dc1dc2e5b7c2342632083
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkTextDisp.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index bef5148..f85e0db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -13,7 +13,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.47 2005/02/14 23:00:44 vincentdarley Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.48 2005/03/15 14:07:47 vincentdarley Exp $ */ #include "tkPort.h" @@ -1804,6 +1804,11 @@ UpdateDisplayInfo(textPtr) */ if (y < maxY) { + /* + * This counts how many vertical pixels we have left to fill + * by pulling in more display pixels either from the first + * currently displayed, or the lines above it. + */ int spaceLeft = maxY - y; if (spaceLeft <= dInfoPtr->newTopPixelOffset) { @@ -1918,16 +1923,27 @@ UpdateDisplayInfo(textPtr) bytesToCount = INT_MAX; } /* - * We've filled in the space we wanted to, and we - * need to store any extra overlap we've just - * created for the top line. + * We've either filled in the space we wanted to or we've + * run out of display lines at the top of the text. Note + * that we already set dInfoPtr->newTopPixelOffset to zero + * above. */ - if (lineNum >= 0) { + if (spaceLeft < 0) { + /* + * We've laid out a few too many vertical pixels at or + * above the first line. Therefore we only want to show + * part of the first displayed line, so that the last + * displayed line just fits in the window. + */ dInfoPtr->newTopPixelOffset = -spaceLeft; - if (spaceLeft > 0 || - dInfoPtr->newTopPixelOffset >= dInfoPtr->dLinePtr->height) { - /* Bad situation */ - Tcl_Panic("Pixel height problem while laying out text widget"); + if (dInfoPtr->newTopPixelOffset >= dInfoPtr->dLinePtr->height) { + /* + * Somehow the entire first line we laid out is + * shorter than the new offset. This should not + * occur and would indicate a bad problem in the + * logic above. + */ + Tcl_Panic("Error in pixel height consistency while filling in spacesLeft"); } } } |