summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogelnew1@free.fr <fvogel>2014-11-30 22:03:02 (GMT)
committerfvogelnew1@free.fr <fvogel>2014-11-30 22:03:02 (GMT)
commite152b9f9ff4f823a3d85ca3714a6a3995f0e8a5d (patch)
tree3c3ec234fc039214e724efd04b90e26d4db0f259 /generic
parentf4d10bbe697367e7378997a54415c95da773d23d (diff)
parent711fd5187b89c35d2533ccc0bed8b181baf8340c (diff)
downloadtk-e152b9f9ff4f823a3d85ca3714a6a3995f0e8a5d.zip
tk-e152b9f9ff4f823a3d85ca3714a6a3995f0e8a5d.tar.gz
tk-e152b9f9ff4f823a3d85ca3714a6a3995f0e8a5d.tar.bz2
Merged from branch bug-7703f947aa
Diffstat (limited to 'generic')
-rw-r--r--generic/tkTextDisp.c79
1 files changed, 38 insertions, 41 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 1790ca7..e6991da 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -542,7 +542,8 @@ static void DisplayDLine(TkText *textPtr, DLine *dlPtr,
static void DisplayLineBackground(TkText *textPtr, DLine *dlPtr,
DLine *prevPtr, Pixmap pixmap);
static void DisplayText(ClientData clientData);
-static DLine * FindDLine(DLine *dlPtr, CONST TkTextIndex *indexPtr);
+static DLine * FindDLine(TkText *textPtr, DLine *dlPtr,
+ CONST TkTextIndex *indexPtr);
static void FreeDLines(TkText *textPtr, DLine *firstPtr,
DLine *lastPtr, int action);
static void FreeStyle(TkText *textPtr, TextStyle *stylePtr);
@@ -1758,7 +1759,7 @@ UpdateDisplayInfo(
*/
index = textPtr->topIndex;
- dlPtr = FindDLine(dInfoPtr->dLinePtr, &index);
+ dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &index);
if ((dlPtr != NULL) && (dlPtr != dInfoPtr->dLinePtr)) {
FreeDLines(textPtr, dInfoPtr->dLinePtr, dlPtr, DLINE_UNLINK);
}
@@ -4587,11 +4588,11 @@ TextChanged(
rounded = *index1Ptr;
rounded.byteIndex = 0;
- firstPtr = FindDLine(dInfoPtr->dLinePtr, &rounded);
+ firstPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded);
if (firstPtr == NULL) {
return;
}
- lastPtr = FindDLine(dInfoPtr->dLinePtr, index2Ptr);
+ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, index2Ptr);
while ((lastPtr != NULL)
&& (lastPtr->index.linePtr == index2Ptr->linePtr)) {
lastPtr = lastPtr->nextPtr;
@@ -4775,13 +4776,13 @@ TextRedrawTag(
*/
if (curIndexPtr->byteIndex == 0) {
- dlPtr = FindDLine(dlPtr, curIndexPtr);
+ dlPtr = FindDLine(textPtr, dlPtr, curIndexPtr);
} else {
TkTextIndex tmp;
tmp = *curIndexPtr;
tmp.byteIndex -= 1;
- dlPtr = FindDLine(dlPtr, &tmp);
+ dlPtr = FindDLine(textPtr, dlPtr, &tmp);
}
if (dlPtr == NULL) {
break;
@@ -4797,7 +4798,7 @@ TextRedrawTag(
curIndexPtr = &search.curIndex;
endIndexPtr = curIndexPtr;
}
- endPtr = FindDLine(dlPtr, endIndexPtr);
+ endPtr = FindDLine(textPtr, dlPtr, endIndexPtr);
if ((endPtr != NULL)
&& (TkTextIndexCmp(&endPtr->index,endIndexPtr) < 0)) {
endPtr = endPtr->nextPtr;
@@ -5046,7 +5047,7 @@ TkTextSetYView(
if (dInfoPtr->flags & DINFO_OUT_OF_DATE) {
UpdateDisplayInfo(textPtr);
}
- dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr);
+ dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, indexPtr);
if (dlPtr != NULL) {
if ((dlPtr->y + dlPtr->height) > dInfoPtr->maxY) {
/*
@@ -5119,7 +5120,7 @@ TkTextSetYView(
MeasureUp(textPtr, indexPtr, close + lineHeight
- textPtr->charHeight/2, &tmpIndex, &overlap);
- if (FindDLine(dInfoPtr->dLinePtr, &tmpIndex) != NULL) {
+ if (FindDLine(textPtr, dInfoPtr->dLinePtr, &tmpIndex) != NULL) {
bottomY = dInfoPtr->maxY - dInfoPtr->y;
}
}
@@ -5382,7 +5383,7 @@ TkTextSeeCmd(
* the widget is not mapped. [Bug #641778]
*/
- dlPtr = FindDLine(dInfoPtr->dLinePtr, &index);
+ dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &index);
if (dlPtr == NULL) {
return TCL_OK;
}
@@ -6430,12 +6431,13 @@ AsyncUpdateYScrollbar(
static DLine *
FindDLine(
+ TkText *textPtr, /* Widget record for text widget. */
register DLine *dlPtr, /* Pointer to first in list of DLines to
* search. */
CONST TkTextIndex *indexPtr)/* Index of desired character. */
{
- TkTextLine *linePtr;
DLine *dlPtrPrev;
+ TkTextIndex indexPtr2;
if (dlPtr == NULL) {
return NULL;
@@ -6444,49 +6446,44 @@ FindDLine(
< TkBTreeLinesTo(NULL, dlPtr->index.linePtr)) {
/*
* The first display line is already past the desired line.
+ * FV: Some concern here as to whether we should rather return
+ * NULL here.
*/
return dlPtr;
}
/*
- * Find the first display line that covers the desired text line.
+ * The display line containing the desired index is such that the index
+ * of the first character of this display line is at or before the
+ * desired index, and the index onf the first character of the next
+ * display line is after the desired index.
*/
- linePtr = dlPtr->index.linePtr;
- while (linePtr != indexPtr->linePtr) {
- while (dlPtr->index.linePtr == linePtr) {
+ while (TkTextIndexCmp(&dlPtr->index,indexPtr) < 0) {
dlPtrPrev = dlPtr;
dlPtr = dlPtr->nextPtr;
if (dlPtr == NULL) {
- return NULL;
- }
- }
-
/*
- * VMD: some concern here as to whether this logic, or the caller's
- * logic will work well with partial peer widgets.
- */
-
- linePtr = TkBTreeNextLine(NULL, linePtr);
- if (linePtr == NULL) {
- Tcl_Panic("FindDLine reached end of text");
- }
- }
- if (indexPtr->linePtr != dlPtr->index.linePtr) {
- return dlPtrPrev;
- }
-
- /*
- * Now get to the right position within the text line.
- */
-
- while (indexPtr->byteIndex >= (dlPtr->index.byteIndex+dlPtr->byteCount)) {
- dlPtr = dlPtr->nextPtr;
- if ((dlPtr == NULL) || (dlPtr->index.linePtr != indexPtr->linePtr)) {
+ * We're past the last display line, either because the desired
+ * index lies past the visible text, or because the desired index
+ * is on the last display line showing the last logical line.
+ */
+ indexPtr2 = dlPtrPrev->index;
+ TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 1, NULL);
+ if (TkTextIndexCmp(&indexPtr2,indexPtr) >= 0) {
+ dlPtr = dlPtrPrev;
+ break;
+ } else {
+ return NULL;
+ }
+ }
+ if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) {
+ dlPtr = dlPtrPrev;
break;
}
}
+
return dlPtr;
}
@@ -6831,7 +6828,7 @@ TkTextIndexBbox(
* Find the display line containing the desired index.
*/
- dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr);
+ dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, indexPtr);
/*
* Two cases shall be trapped here because the logic later really
@@ -6976,7 +6973,7 @@ TkTextDLineInfo(
* Find the display line containing the desired index.
*/
- dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr);
+ dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, indexPtr);
if ((dlPtr == NULL) || (TkTextIndexCmp(&dlPtr->index, indexPtr) > 0)) {
return -1;
}