diff options
author | vincentdarley <vincentdarley> | 2004-01-07 16:28:23 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2004-01-07 16:28:23 (GMT) |
commit | 46eead19d1ac38c3bcc59c7b24ab3a621b29eb3b (patch) | |
tree | 182b6e90e0039b2a56b8eff89176999a750beb26 /generic/tkTextDisp.c | |
parent | 635a8263e2a11333a1940f788b530eaeeda89275 (diff) | |
download | tk-46eead19d1ac38c3bcc59c7b24ab3a621b29eb3b.zip tk-46eead19d1ac38c3bcc59c7b24ab3a621b29eb3b.tar.gz tk-46eead19d1ac38c3bcc59c7b24ab3a621b29eb3b.tar.bz2 |
fix to text widget yview bug
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r-- | generic/tkTextDisp.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1fbf4cf..9cab7f8 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.38 2003/12/15 11:51:06 vincentdarley Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.39 2004/01/07 16:28:23 vincentdarley Exp $ */ #include "tkPort.h" @@ -5193,14 +5193,23 @@ TkTextYviewCmd(textPtr, interp, objc, objv) switch (type) { case TKTEXT_SCROLL_ERROR: return TCL_ERROR; - case TKTEXT_SCROLL_MOVETO: + case TKTEXT_SCROLL_MOVETO: { + int numPixels = TkBTreeNumPixels(textPtr->tree); + if (numPixels == 0) { + /* + * If the window is totally empty no scrolling is + * needed, and the TkTextMakePixelIndex call + * below will fail. + */ + break; + } if (fraction > 1.0) { fraction = 1.0; } if (fraction < 0) { fraction = 0; } - fraction *= (TkBTreeNumPixels(textPtr->tree)-1); + fraction *= (numPixels - 1); /* * This function returns the number of pixels by which the * given line should overlap the top of the visible screen. @@ -5211,6 +5220,7 @@ TkTextYviewCmd(textPtr, interp, objc, objv) (int) (0.5 + fraction), &index); TkTextSetYView(textPtr, &index, pixels); break; + } case TKTEXT_SCROLL_PAGES: { /* * Scroll up or down by screenfuls. Actually, use the |