diff options
-rw-r--r-- | generic/tkText.c | 30 | ||||
-rw-r--r-- | generic/tkTextBTree.c | 20 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 5 |
3 files changed, 51 insertions, 4 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index d1032e5..2938c28 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -3284,6 +3284,14 @@ DeleteIndexRange( if (tPtr == textPtr) { if (viewUpdate) { + /* + * line cannot be before -startline of textPtr because + * this line corresponds to an index which is necessarily + * between "1.0" and "end" relative to textPtr. + * Therefore no need to clamp line to the -start/-end + * range. + */ + TkTextMakeByteIndex(sharedTextPtr->tree, textPtr, line, byteIndex, &indexTmp); TkTextSetYView(tPtr, &indexTmp, 0); @@ -3291,6 +3299,28 @@ DeleteIndexRange( } else { TkTextMakeByteIndex(sharedTextPtr->tree, tPtr, line, byteIndex, &indexTmp); + /* + * line may be before -startline of tPtr and must be + * clamped to -startline before providing it to + * TkTextSetYView otherwise lines before -startline + * would be displayed. + * There is no need to worry about -endline however, + * because the view will only be reset if the deletion + * involves the TOP line of the screen + */ + + if (tPtr->start != NULL) { + int start; + TkTextIndex indexStart; + + start = TkBTreeLinesTo(NULL, tPtr->start); + TkTextMakeByteIndex(sharedTextPtr->tree, NULL, start, + 0, &indexStart); + if (TkTextIndexCmp(&indexTmp, &indexStart) < 0) { + indexTmp = indexStart; + printf("ADJUSTED !!!!!!!!!!!!!!!!!!!!!!\n"); + } + } TkTextSetYView(tPtr, &indexTmp, 0); } } diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 7832992..1b65cbc 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -1727,6 +1727,26 @@ TkBTreeFindPixelLine( } pixels -= linePtr->pixels[2 * pixelReference]; } + + /* + * Check for any start/end offset for this text widget. + */ + + if (textPtr->start != NULL) { + int lineBoundary = TkBTreeLinesTo(NULL, textPtr->start); + + if (TkBTreeLinesTo(NULL, linePtr) < lineBoundary) { + linePtr = TkBTreeFindLine(tree, NULL, lineBoundary); + } + } + if (textPtr->end != NULL) { + int lineBoundary = TkBTreeLinesTo(NULL, textPtr->end); + + if (TkBTreeLinesTo(NULL, linePtr) > lineBoundary) { + linePtr = TkBTreeFindLine(tree, NULL, lineBoundary); + } + } + if (pixelOffset != NULL && linePtr != NULL) { *pixelOffset = pixels; } diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 814863b..a02544d 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5328,7 +5328,6 @@ TkTextRelayoutWindow( * The display will (eventually) be updated so that the position given by * "indexPtr" is visible on the screen at the position determined by * "pickPlace". - * indexPtr may be adjusted to the -startline/-endline range. * *---------------------------------------------------------------------- */ @@ -5359,8 +5358,7 @@ TkTextSetYView( /* * If the specified position is the extra line at the end of the text, - * round it back to the last real line. Also, adjust to the -starline - * and -endline limits. + * round it back to the last real line. */ lineIndex = TkBTreeLinesTo(textPtr, indexPtr->linePtr); @@ -5368,7 +5366,6 @@ TkTextSetYView( TkTextIndexBackChars(textPtr, indexPtr, 1, &rounded, COUNT_INDICES); indexPtr = &rounded; } - TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 0); if (pickPlace == TK_TEXT_NOPIXELADJUST) { if (textPtr->topIndex.linePtr == indexPtr->linePtr |