summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2014-11-30 21:21:08 (GMT)
committerfvogel <fvogelnew1@free.fr>2014-11-30 21:21:08 (GMT)
commitbdd484f568bb6dfd8d9e05d5ab8b9d8470f83cf6 (patch)
treebe258203cbffcb3296c7d03babd9d74b645dc71f
parent34b765f14f011c5b1d1f836997b5bfbcf89b6b1e (diff)
downloadtk-bdd484f568bb6dfd8d9e05d5ab8b9d8470f83cf6.zip
tk-bdd484f568bb6dfd8d9e05d5ab8b9d8470f83cf6.tar.gz
tk-bdd484f568bb6dfd8d9e05d5ab8b9d8470f83cf6.tar.bz2
Fixed bbox caller of FindDLine, see case 'B' in bug [7703f947aa]
-rw-r--r--generic/tkTextDisp.c18
-rw-r--r--tests/textDisp.test23
2 files changed, 39 insertions, 2 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 2b88ad6..c1b477c 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -6826,15 +6826,29 @@ TkTextIndexBbox(
*/
dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr);
+
+ /*
+ * Two cases shall be trapped here because the logic later really
+ * needs dlPtr to be the display line containing indexPtr:
+ * 1. if no display line contains the desired index (NULL dlPtr)
+ * 2. if indexPtr is before the first display line, in which case
+ * dlPtr currently points to the first display line
+ */
+
if ((dlPtr == NULL) || (TkTextIndexCmp(&dlPtr->index, indexPtr) > 0)) {
return -1;
}
/*
- * Find the chunk within the line that contains the desired index.
+ * Find the chunk within the display line that contains the desired
+ * index. The chunks making the display line are skipped up to but not
+ * including the one crossing indexPtr. Skipping is done based on
+ * a byteIndex offset possibly spanning several logical lines in case
+ * they are elided.
*/
- byteIndex = indexPtr->byteIndex - dlPtr->index.byteIndex;
+ byteIndex = TkTextIndexCount(textPtr, &dlPtr->index, indexPtr,
+ COUNT_INDICES);
for (chunkPtr = dlPtr->chunkPtr; ; chunkPtr = chunkPtr->nextPtr) {
if (chunkPtr == NULL) {
return -1;
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 4b5c8c1..3add847 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -2754,6 +2754,29 @@ test textDisp-22.9 {TkTextCharBbox, handling of spacing} {textfonts} {
[.t bbox 1.1] [.t bbox 2.9]
} [list [list 24 11 10 4] [list 55 [expr {$fixedDiff/2 + 15}] 10 4] [list 10 [expr {2*$fixedDiff + 43}] 10 4] [list 76 [expr {2*$fixedDiff + 40}] 10 4] [list 10 11 7 $fixedHeight] [list 69 [expr {$fixedDiff + 34}] 7 $fixedHeight]]
.t tag delete spacing
+test textDisp-22.10 {TkTextCharBbox, handling of elided lines} {textfonts} {
+ .t configure -wrap char
+ .t delete 1.0 end
+ for {set i 1} {$i < 10} {incr i} {
+ .t insert end "Line $i - Line [format %c [expr 64+$i]]\n"
+ }
+ .t tag add hidden 2.8 2.13
+ .t tag add hidden 6.8 7.13
+ .t tag configure hidden -elide true
+ update
+ list \
+ [expr {[lindex [.t bbox 2.9] 0] - [lindex [.t bbox 2.8] 0]}] \
+ [expr {[lindex [.t bbox 2.10] 0] - [lindex [.t bbox 2.8] 0]}] \
+ [expr {[lindex [.t bbox 2.13] 0] - [lindex [.t bbox 2.8] 0]}] \
+ [expr {[lindex [.t bbox 6.9] 0] - [lindex [.t bbox 6.8] 0]}] \
+ [expr {[lindex [.t bbox 6.10] 0] - [lindex [.t bbox 6.8] 0]}] \
+ [expr {[lindex [.t bbox 6.13] 0] - [lindex [.t bbox 6.8] 0]}] \
+ [expr {[lindex [.t bbox 6.14] 0] - [lindex [.t bbox 6.8] 0]}] \
+ [expr {[lindex [.t bbox 6.15] 0] - [lindex [.t bbox 6.8] 0]}] \
+ [expr {[lindex [.t bbox 7.0] 0] - [lindex [.t bbox 6.8] 0]}] \
+ [expr {[lindex [.t bbox 7.1] 0] - [lindex [.t bbox 6.8] 0]}] \
+ [expr {[lindex [.t bbox 7.12] 0] - [lindex [.t bbox 6.8] 0]}]
+} [list 0 0 0 0 0 0 0 0 0 0 0]
.t delete 1.0 end
.t insert end "Line 1"