diff options
author | fvogel <fvogelnew1@free.fr> | 2015-01-16 22:07:54 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2015-01-16 22:07:54 (GMT) |
commit | 2a1df1da7fd04bf2163249f588314d1ae33d12f5 (patch) | |
tree | 16c4390e14eaf827e0e1b4da8191101bd32f367d /generic/tkTextDisp.c | |
parent | c53adc17235c7785f077fc52f7a16d762ce8710c (diff) | |
download | tk-2a1df1da7fd04bf2163249f588314d1ae33d12f5.zip tk-2a1df1da7fd04bf2163249f588314d1ae33d12f5.tar.gz tk-2a1df1da7fd04bf2163249f588314d1ae33d12f5.tar.bz2 |
Factorized the code a bit more, making use of function IsStartOfNotMergedLine. Also, tried to better explain in comments.
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r-- | generic/tkTextDisp.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index be3c7d9..a6ab13c 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5418,21 +5418,21 @@ MeasureUp( for (dlPtr = lowestPtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { distance -= dlPtr->height; if (distance <= 0) { - TkTextIndex tmpIndex = dlPtr->index; *dstPtr = dlPtr->index; /* - * Adjust index to the start of the display line. This is - * needed because the start of a logical line is not always - * the start of a display line (this is however true if the - * eol is not elided). + * dstPtr is the start of a display line that is or is not + * the start of a logical line. If it is the start of a + * logical line, we must check whether this line is merged + * with the previous logical line, and if so we must adjust + * dstPtr to the start of the display line since a display + * line start needs to be returned. */ - - TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); - if (TkTextIsElided(textPtr, &tmpIndex, NULL)) { + if (!IsStartOfNotMergedLine(textPtr, dstPtr)) { TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, NULL); } - if (overlap != NULL) { + + if (overlap != NULL) { *overlap = -distance; } break; @@ -5823,22 +5823,26 @@ YScrollByLines( for (dlPtr = lowestPtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { offset++; if (offset == 0) { - TkTextIndex tmpIndex = dlPtr->index; textPtr->topIndex = dlPtr->index; /* - * Adjust index to the start of the display line. This is - * needed because the start of a logical line is not - * always the start of a display line (this is however - * true if the eol is not elided). + * topIndex is the start of a logical line. However, if + * the eol of the previous logical line is elided, then + * topIndex may be elsewhere than the first character of + * a display line, which is unwanted. Adjust to the start + * of the display line, if needed. + * topIndex is the start of a display line that is or is + * not the start of a logical line. If it is the start of + * a logical line, we must check whether this line is + * merged with the previous logical line, and if so we + * must adjust topIndex to the start of the display line. */ - - TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); - if (TkTextIsElided(textPtr, &tmpIndex, NULL)) { - TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, - NULL); + if (!IsStartOfNotMergedLine(textPtr, &textPtr->topIndex)) { + TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, + 0, NULL); } - break; + + break; } } |