diff options
author | fvogel <fvogelnew1@free.fr> | 2014-12-07 18:53:20 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2014-12-07 18:53:20 (GMT) |
commit | 61dca66aa752bd2d8698f46fb47a1ec6f88dff77 (patch) | |
tree | e8b0c35b5ea635f2b978bede0efbe2f353b0bddb | |
parent | 2143daab464ed81f9b1622f109a6f4c89d81aab2 (diff) | |
parent | dd3d363f3b94a050a48b1d41f67a6e9aaba68fe9 (diff) | |
download | tk-61dca66aa752bd2d8698f46fb47a1ec6f88dff77.zip tk-61dca66aa752bd2d8698f46fb47a1ec6f88dff77.tar.gz tk-61dca66aa752bd2d8698f46fb47a1ec6f88dff77.tar.bz2 |
Merged from branch bug-7703f947aa
-rw-r--r-- | generic/tkTextDisp.c | 24 | ||||
-rw-r--r-- | tests/textDisp.test | 47 |
2 files changed, 71 insertions, 0 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index ae5cdb2..4715864 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5287,6 +5287,18 @@ MeasureUp( distance -= dlPtr->height; if (distance <= 0) { *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). + */ + + if (TkTextIsElided(textPtr, dstPtr, NULL)) { + TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, + NULL); + } if (overlap != NULL) { *overlap = -distance; } @@ -5679,6 +5691,18 @@ YScrollByLines( offset++; if (offset == 0) { 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). + */ + + if (TkTextIsElided(textPtr, &textPtr->topIndex, NULL)) { + TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, + NULL); + } break; } } diff --git a/tests/textDisp.test b/tests/textDisp.test index 71de1ac..471a096 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2086,6 +2086,36 @@ test textDisp-16.41 {text count -xpixels with indices in elided lines} { [.t count -xpixels 20.15 20.16] \ [.t count -xpixels 20.16 20.15] } [list 0 0 0 0 0 0 0 0 $fixedWidth -$fixedWidth] +test textDisp-16.42 {TkTextYviewCmd procedure with indices in elided lines} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 100} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + .t yview 35.0 + set res {} + .t yview scroll [expr {- 15 * $fixedHeight}] pixels + update + .t index @0,0 +} {5.0} +test textDisp-16.43 {TkTextYviewCmd procedure with indices in elided lines} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 100} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + .t yview 35.0 + set res {} + .t yview scroll -15 units + update + .t index @0,0 +} {5.0} .t delete 1.0 end foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { @@ -2648,6 +2678,23 @@ test textDisp-19.17 {count -ypixels with indices in elided lines} { update lappend res [.t count -ypixels 5.0 25.0] } [list [expr {4 * $fixedHeight}] [expr {3 * $fixedHeight}] 0 0 0 0 0 0 [expr {5 * $fixedHeight}] [expr {- 5 * $fixedHeight}] [expr {2 * $fixedHeight}] [expr {3 * $fixedHeight}] [expr {5 * $fixedHeight}]] +test textDisp-19.18 {count -ypixels with indices in elided lines} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 100} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + .t yview 35.0 + set res {} + update + lappend res [.t count -ypixels 5.0 25.0] + .t yview scroll [expr {- 15 * $fixedHeight}] pixels + update + lappend res [.t count -ypixels 5.0 25.0] +} [list [expr {5 * $fixedHeight}] [expr {5 * $fixedHeight}]] .t delete 1.0 end .t insert end "Line 1" for {set i 2} {$i <= 200} {incr i} { |