summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericm <ericm>2000-02-03 21:27:26 (GMT)
committerericm <ericm>2000-02-03 21:27:26 (GMT)
commit89c9f372d31b5e61756564807e468a9c3e1fa372 (patch)
tree5bbe3efa4585528a584178ddc5bd3eb3de508975
parent32c58211007ce985f1da733cc7426626692dedf9 (diff)
downloadtk-89c9f372d31b5e61756564807e468a9c3e1fa372.zip
tk-89c9f372d31b5e61756564807e468a9c3e1fa372.tar.gz
tk-89c9f372d31b5e61756564807e468a9c3e1fa372.tar.bz2
* tests/canvText.test: test for fix for bug #2525.
* generic/tkFont.c (Tk_ComputeTextLayout): Was erroneously setting the width of newline-only text display chunks to some arbitrary huge number, instead of 0; this was interfering with things like the canvas find enclosed feature. (bug #2525).
-rw-r--r--generic/tkFont.c6
-rw-r--r--tests/canvText.test17
2 files changed, 19 insertions, 4 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index e66a41e..913c335 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.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: tkFont.c,v 1.9 1999/12/21 23:55:11 hobbs Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.10 2000/02/03 21:27:26 ericm Exp $
*/
#include "tkPort.h"
@@ -1933,7 +1933,7 @@ Tk_ComputeTextLayout(tkfont, string, numChars, wrapLength, justify, flags,
continue;
}
} else {
- NewChunk(&layoutPtr, &maxChunks, start, 1, curX, 1000000000,
+ NewChunk(&layoutPtr, &maxChunks, start, 1, curX, curX,
baseline)->numDisplayChars = -1;
start++;
goto wrapLine;
@@ -2011,7 +2011,7 @@ Tk_ComputeTextLayout(tkfont, string, numChars, wrapLength, justify, flags,
if ((layoutPtr->numChunks > 0) && ((flags & TK_IGNORE_NEWLINES) == 0)) {
if (layoutPtr->chunks[layoutPtr->numChunks - 1].start[0] == '\n') {
chunkPtr = NewChunk(&layoutPtr, &maxChunks, start, 0, curX,
- 1000000000, baseline);
+ curX, baseline);
chunkPtr->numDisplayChars = -1;
Tcl_DStringAppend(&lineBuffer, (char *) &curX, sizeof(curX));
baseline += height;
diff --git a/tests/canvText.test b/tests/canvText.test
index abe5589..fd76894 100644
--- a/tests/canvText.test
+++ b/tests/canvText.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: canvText.test,v 1.8 1999/12/14 06:53:12 hobbs Exp $
+# RCS: @(#) $Id: canvText.test,v 1.9 2000/02/03 21:27:27 ericm Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -504,6 +504,21 @@ restore showpage
end
%%EOF
"
+
+test canvText-18.1 {bug fix 2525, find enclosed on text with newlines} {
+ catch {destroy .c}
+ canvas .c
+ pack .c
+ .c delete all
+ .c create text 100 100 -text Hello\n -anchor nw
+ set bbox [.c bbox 1]
+ set x2 [lindex $bbox 2]
+ set y2 [lindex $bbox 3]
+ incr y2
+ update
+ .c find enclosed 99 99 [expr $x2 + $i] [expr $y2 + 1]
+} 1
+
# cleanup
::tcltest::cleanupTests
return