summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2014-12-03 23:25:43 (GMT)
committerfvogel <fvogelnew1@free.fr>2014-12-03 23:25:43 (GMT)
commit45fd1aa9f09798ce73c7692243123ab5494095d0 (patch)
treeb407671cfb0f9f3fcb1743696ad4ed899b76fa2d
parent5ae511b6ddb51f744323c8de59110461bc0abe93 (diff)
downloadtk-45fd1aa9f09798ce73c7692243123ab5494095d0.zip
tk-45fd1aa9f09798ce73c7692243123ab5494095d0.tar.gz
tk-45fd1aa9f09798ce73c7692243123ab5494095d0.tar.bz2
Fixed text see command for elided target indices.
-rw-r--r--generic/tkTextDisp.c95
-rw-r--r--tests/textDisp.test16
2 files changed, 66 insertions, 45 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index f17994b..3d442af 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -5056,19 +5056,20 @@ TkTextSetYView(
*/
dlPtr = NULL;
- } else if ((dlPtr->index.linePtr == indexPtr->linePtr)
- && (dlPtr->index.byteIndex <= indexPtr->byteIndex)) {
- if (dInfoPtr->dLinePtr == dlPtr && dInfoPtr->topPixelOffset != 0) {
- /*
- * It is on the top line, but that line is hanging off the top
- * of the screen. Change the top overlap to zero and update.
- */
-
- dInfoPtr->newTopPixelOffset = 0;
- goto scheduleUpdate;
- }
- return;
- }
+ } else {
+ if (TkTextIndexCmp(&dlPtr->index, indexPtr) <= 0) {
+ if (dInfoPtr->dLinePtr == dlPtr && dInfoPtr->topPixelOffset != 0) {
+ /*
+ * It is on the top line, but that line is hanging off the top
+ * of the screen. Change the top overlap to zero and update.
+ */
+
+ dInfoPtr->newTopPixelOffset = 0;
+ goto scheduleUpdate;
+ }
+ return;
+ }
+ }
}
/*
@@ -5379,8 +5380,8 @@ TkTextSeeCmd(
}
/*
- * Find the chunk that contains the desired index. dlPtr may be NULL if
- * the widget is not mapped. [Bug #641778]
+ * Find the display line containing the desired index. dlPtr may be NULL
+ * if the widget is not mapped. [Bug #641778]
*/
dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &index);
@@ -5388,7 +5389,16 @@ TkTextSeeCmd(
return TCL_OK;
}
- byteCount = index.byteIndex - dlPtr->index.byteIndex;
+ /*
+ * 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 index. Skipping is done based on a
+ * byteCount offset possibly spanning several logical lines in case
+ * they are elided.
+ */
+
+ byteCount = TkTextIndexCount(textPtr, &dlPtr->index, &index,
+ COUNT_INDICES);
for (chunkPtr = dlPtr->chunkPtr; chunkPtr != NULL ;
chunkPtr = chunkPtr->nextPtr) {
if (byteCount < chunkPtr->numBytes) {
@@ -5399,36 +5409,33 @@ TkTextSeeCmd(
/*
* Call a chunk-specific function to find the horizontal range of the
- * character within the chunk. chunkPtr is NULL if trying to see in elided
- * region.
+ * character within the chunk.
*/
- if (chunkPtr != NULL) {
- (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount,
- dlPtr->y + dlPtr->spaceAbove,
- dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
- dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
- &height);
- delta = x - dInfoPtr->curXPixelOffset;
- oneThird = lineWidth/3;
- if (delta < 0) {
- if (delta < -oneThird) {
- dInfoPtr->newXPixelOffset = (x - lineWidth/2);
- } else {
- dInfoPtr->newXPixelOffset -= ((-delta) );
- }
- } else {
- delta -= (lineWidth - width);
- if (delta > 0) {
- if (delta > oneThird) {
- dInfoPtr->newXPixelOffset = (x - lineWidth/2);
- } else {
- dInfoPtr->newXPixelOffset += (delta );
- }
- } else {
- return TCL_OK;
- }
- }
+ (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount,
+ dlPtr->y + dlPtr->spaceAbove,
+ dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
+ dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
+ &height);
+ delta = x - dInfoPtr->curXPixelOffset;
+ oneThird = lineWidth/3;
+ if (delta < 0) {
+ if (delta < -oneThird) {
+ dInfoPtr->newXPixelOffset = (x - lineWidth/2);
+ } else {
+ dInfoPtr->newXPixelOffset -= ((-delta) );
+ }
+ } else {
+ delta -= (lineWidth - width);
+ if (delta > 0) {
+ if (delta > oneThird) {
+ dInfoPtr->newXPixelOffset = (x - lineWidth/2);
+ } else {
+ dInfoPtr->newXPixelOffset += (delta );
+ }
+ } else {
+ return TCL_OK;
+ }
}
dInfoPtr->flags |= DINFO_OUT_OF_DATE;
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 3b5eca2..fff52d4 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -1473,7 +1473,21 @@ test textDisp-11.17 {TkTextSetYView, only a few lines visible} {
.top.t index @0,0
# The index 2.0 should be just visible by a couple of pixels
} {2.0}
-destroy .top
+test textDisp-11.18 {TkTextSetYView, see in elided lines} {
+ .top.t delete 1.0 end
+ for {set i 1} {$i < 20} {incr i} {
+ .top.t insert end [string repeat "Line $i" 10]
+ .top.t insert end "\n"
+ }
+ .top.t yview 4.0
+ .top.t tag add hidden 4.10 "4.10 lineend"
+ .top.t tag add hidden 5.15 10.3
+ .top.t tag configure hidden -elide true
+ update
+ .top.t see "8.0 lineend"
+ # The index "8.0 lineend" is on screen despite elided -> no scroll
+ .top.t index @0,0
+} {4.0}
.t configure -wrap word
.t delete 50.0 51.0