summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c16
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