Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Further fixed text count -ypixels with indices in elided lines, [30d6b995dc] was not always correct |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | text-elided |
Files: | files | file ages | folders |
SHA1: |
abc40fc5530fd90253a0a84b3d7c41f8 |
User & Date: | fvogel 2014-12-28 18:00:53 |
Context
2014-12-28
| ||
20:58 | Further fixed text see with indices in elided lines, [5f352f3a71] was not always correct check-in: 5f876e86 user: fvogel tags: text-elided | |
18:00 | Further fixed text count -ypixels with indices in elided lines, [30d6b995dc] was not always correct check-in: abc40fc5 user: fvogel tags: text-elided | |
15:09 | Fixed Bad counting of the total number of vertical pixels in the text widget, resulting in small change of the Y scrollbar size. Happened because CalculateDisplayLineHeight expects an index at start of a display line, which was not always the case. check-in: dd92553e user: fvogel tags: text-elided | |
Changes
Changes to generic/tkTextDisp.c.
︙ | ︙ | |||
3599 3600 3601 3602 3603 3604 3605 3606 3607 | TkText *textPtr, /* Widget record for text widget. */ CONST TkTextIndex *indexPtr)/* The index of which we want the pixel * distance from top of logical line to top of * index. */ { int pixelHeight; TkTextIndex index; index = *indexPtr; | > > > > > > > > | > > > > > > | | | | | < > | | | > | | | > | | 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 | TkText *textPtr, /* Widget record for text widget. */ CONST TkTextIndex *indexPtr)/* The index of which we want the pixel * distance from top of logical line to top of * index. */ { int pixelHeight; TkTextIndex index; int alreadyStartOfLine = 1; /* * Find the index denoting the closest position being at the same time * the start of a logical line above indexPtr and the start of a display * line. */ index = *indexPtr; while (1) { TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL); if (index.byteIndex == 0) { break; } TkTextIndexBackBytes(textPtr, &index, 1, &index); alreadyStartOfLine = 0; } pixelHeight = TkBTreePixelsTo(textPtr, index.linePtr); /* * Shortcut to avoid layout of a superfluous display line. We know there * is nothing more to add up to the height since the index we were given * was already the start of a logical line. */ if (alreadyStartOfLine) { return pixelHeight; } /* * Iterate through display lines, starting at the logical line belonging * to index, adding up the pixel height of each such display line as we * go along, until we go past 'indexPtr'. */ while (1) { int bytes, height, compare; /* * Currently this call doesn't have many side-effects. However, if in * the future we change the code so there are side-effects (such as * adjusting linePtr->pixelHeight), then the code might not quite work * as intended, specifically the 'linePtr->pixelHeight == pixelHeight' * test below this while loop. */ height = CalculateDisplayLineHeight(textPtr, &index, &bytes, NULL); TkTextIndexForwBytes(textPtr, &index, bytes, &index); compare = TkTextIndexCmp(&index,indexPtr); if (compare > 0) { return pixelHeight; } if (height > 0) { pixelHeight += height; } if (compare == 0) { return pixelHeight; } } } /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to tests/textDisp.test.
︙ | ︙ | |||
2688 2689 2690 2691 2692 2693 2694 | [.t count -ypixels 5.2 20.60] \ [.t count -ypixels 20.60 20.70] \ [.t count -ypixels 5.0 25.0] \ [.t count -ypixels 25.0 5.0] \ [.t count -ypixels 25.4 27.50] \ [.t count -ypixels 35.0 38.0] .t yview 35.0 | < > > > > > > > > > > > > > | 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 | [.t count -ypixels 5.2 20.60] \ [.t count -ypixels 20.60 20.70] \ [.t count -ypixels 5.0 25.0] \ [.t count -ypixels 25.0 5.0] \ [.t count -ypixels 25.4 27.50] \ [.t count -ypixels 35.0 38.0] .t yview 35.0 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}]] test textDisp-19.19 {count -ypixels with indices in elided lines} { .t configure -wrap char .t delete 1.0 end for {set i 1} {$i < 25} {incr i} { .t insert end [string repeat "Line $i -" 6] .t insert end "\n" } .t tag add hidden 5.27 11.0 .t tag configure hidden -elide true .t yview 5.0 update set res [list [.t count -ypixels 5.0 11.0] [.t count -ypixels 5.0 11.20]] } [list [expr {1 * $fixedHeight}] [expr {2 * $fixedHeight}]] .t delete 1.0 end .t insert end "Line 1" for {set i 2} {$i <= 200} {incr i} { .t insert end "\nLine $i" } .t configure -wrap word .t delete 50.0 51.0 |
︙ | ︙ |