diff options
author | hobbs <hobbs> | 2002-11-22 23:25:19 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2002-11-22 23:25:19 (GMT) |
commit | e41cd186045b78af345b11758be8c161d1f051c6 (patch) | |
tree | d7bbb6ced2f0ee70cb70030483c93d41f03a468e | |
parent | 1b0c4a1cbc8bb29f46cc910618e738000208e4e4 (diff) | |
download | tk-e41cd186045b78af345b11758be8c161d1f051c6.zip tk-e41cd186045b78af345b11758be8c161d1f051c6.tar.gz tk-e41cd186045b78af345b11758be8c161d1f051c6.tar.bz2 |
* tests/textDisp.test:
* generic/tkTextDisp.c (TkTextSeeCmd): handle see for unmapped
text displays. [Bug #641778]
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 59 | ||||
-rw-r--r-- | tests/textDisp.test | 13 |
3 files changed, 53 insertions, 25 deletions
@@ -1,3 +1,9 @@ +2002-11-22 Jeff Hobbs <jeffh@ActiveState.com> + + * tests/textDisp.test: + * generic/tkTextDisp.c (TkTextSeeCmd): handle see for unmapped + text displays. [Bug #641778] + 2002-11-19 Jim Ingham <jingham@apple.com> * macosx/tkMacOSXScrlbr.c (TkpDisplayScrollbar): If the diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 11f9552..c541c32 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -11,7 +11,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.13 2002/08/05 04:30:40 dgp Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.14 2002/11/22 23:25:19 hobbs Exp $ */ #include "tkPort.h" @@ -3347,11 +3347,17 @@ TkTextSeeCmd(textPtr, interp, argc, argv) /* * Find the chunk that contains the desired index. + * dlPtr may be NULL if the widget is not mapped. [Bug #641778] */ dlPtr = FindDLine(dInfoPtr->dLinePtr, &index); + if (dlPtr == NULL) { + return TCL_OK; + } + byteCount = index.byteIndex - dlPtr->index.byteIndex; - for (chunkPtr = dlPtr->chunkPtr; chunkPtr!=NULL ; chunkPtr = chunkPtr->nextPtr) { + for (chunkPtr = dlPtr->chunkPtr; chunkPtr != NULL ; + chunkPtr = chunkPtr->nextPtr) { if (byteCount < chunkPtr->numBytes) { break; } @@ -3361,35 +3367,40 @@ TkTextSeeCmd(textPtr, interp, argc, argv) /* * Call a chunk-specific procedure to find the horizontal range of * the character within the chunk. + * chunkPtr is NULL if trying to see in elided region. */ - if (chunkPtr!=NULL) { /* chunkPtr==NULL iff trying to see in elided region */ - (*chunkPtr->bboxProc)(chunkPtr, byteCount, dlPtr->y + dlPtr->spaceAbove, - dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, - dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width, - &height); - delta = x - dInfoPtr->curPixelOffset; - oneThird = lineWidth/3; - if (delta < 0) { - if (delta < -oneThird) { - dInfoPtr->newByteOffset = (x - lineWidth/2)/textPtr->charWidth; - } else { - dInfoPtr->newByteOffset -= ((-delta) + textPtr->charWidth - 1) - / textPtr->charWidth; - } - } else { - delta -= (lineWidth - width); - if (delta > 0) { - if (delta > oneThird) { - dInfoPtr->newByteOffset = (x - lineWidth/2)/textPtr->charWidth; + if (chunkPtr != NULL) { + (*chunkPtr->bboxProc)(chunkPtr, byteCount, + dlPtr->y + dlPtr->spaceAbove, + dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, + dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width, + &height); + delta = x - dInfoPtr->curPixelOffset; + oneThird = lineWidth/3; + if (delta < 0) { + if (delta < -oneThird) { + dInfoPtr->newByteOffset = (x - lineWidth/2) + / textPtr->charWidth; } else { - dInfoPtr->newByteOffset += (delta + textPtr->charWidth - 1) + dInfoPtr->newByteOffset -= ((-delta) + textPtr->charWidth - 1) / textPtr->charWidth; } } else { - return TCL_OK; + delta -= (lineWidth - width); + if (delta > 0) { + if (delta > oneThird) { + dInfoPtr->newByteOffset = (x - lineWidth/2) + / textPtr->charWidth; + } else { + dInfoPtr->newByteOffset += (delta + textPtr->charWidth - 1) + / textPtr->charWidth; + } + } else { + return TCL_OK; + } } - }} + } dInfoPtr->flags |= DINFO_OUT_OF_DATE; if (!(dInfoPtr->flags & REDRAW_PENDING)) { dInfoPtr->flags |= REDRAW_PENDING; diff --git a/tests/textDisp.test b/tests/textDisp.test index 4e7674f..14b3b4a 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: textDisp.test,v 1.7 2002/07/13 20:28:35 dgp Exp $ +# RCS: @(#) $Id: textDisp.test,v 1.8 2002/11/22 23:25:20 hobbs Exp $ package require tcltest 2.1 namespace import -force tcltest::configure @@ -1448,6 +1448,17 @@ test textDisp-13.9 {TkTextSeeCmd procedure} {fonts} { .t see 30.90 lappend x [.t bbox 30.90] } {{80 55 7 13} {136 55 7 13} {136 55 7 13} {80 55 7 13}} +test textDisp-13.10 {TkTextSeeCmd procedure} {} { + # SF Bug 641778 + set w .tsee + destroy $w + text $w -font {Helvetica 8 normal} -bd 16 + $w insert end Hello + $w see end + set res [$w bbox end] + destroy $w + set res +} {} wm geom . {} .t configure -wrap none |