diff options
author | fvogelnew1@free.fr <fvogel> | 2015-01-16 22:07:54 (GMT) |
---|---|---|
committer | fvogelnew1@free.fr <fvogel> | 2015-01-16 22:07:54 (GMT) |
commit | c320b51ca710d690037560ed5a0b53211e06ec53 (patch) | |
tree | 16c4390e14eaf827e0e1b4da8191101bd32f367d | |
parent | f816244547589106633225aeb07f4b71b01749b5 (diff) | |
download | tk-c320b51ca710d690037560ed5a0b53211e06ec53.zip tk-c320b51ca710d690037560ed5a0b53211e06ec53.tar.gz tk-c320b51ca710d690037560ed5a0b53211e06ec53.tar.bz2 |
Factorized the code a bit more, making use of function IsStartOfNotMergedLine. Also, tried to better explain in comments.
-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; } } |