summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2021-04-17 12:31:16 (GMT)
committerfvogel <fvogelnew1@free.fr>2021-04-17 12:31:16 (GMT)
commitff1d4e80428df056e3929f7b9829308353c45ebf (patch)
tree89f6255cc7d5afb9504e3f45ed7c93f2622d5574 /generic
parent5c58251166dbac72b79ab9f699d6a3a27978f220 (diff)
downloadtk-ff1d4e80428df056e3929f7b9829308353c45ebf.zip
tk-ff1d4e80428df056e3929f7b9829308353c45ebf.tar.gz
tk-ff1d4e80428df056e3929f7b9829308353c45ebf.tar.bz2
Backout the first three commits of the present branch, and implement a better fix. It's not the business of TkTextSetYView() to adjust the index it's receiving, it shall rather receive an index that is already within the -starline/-endline limits.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkText.c30
-rw-r--r--generic/tkTextBTree.c20
-rw-r--r--generic/tkTextDisp.c5
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