Tk Source Code

Check-in [dd92553e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | text-elided
Files: files | file ages | folders
SHA1: dd92553e654ab407c07c834cb91643a714ebfb8e
User & Date: fvogel 2014-12-28 15:09:46
References
2019-01-19
15:30 Ticket [4c595d4d] high cpu usage (100%) in tkTextDisp.c status still Open with 3 other changes artifact: 39a09f06 user: fvogel
2019-01-12
20:38 Ticket [4c595d4d]: 4 changes artifact: 25b6c04b user: fvogel
Context
2014-12-28
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
13:57
Fixed indentation in TkTextUpdateOneLine check-in: 5423e10b user: fvogel tags: text-elided
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkTextDisp.c.

3706
3707
3708
3709
3710
3711
3712














3713
3714
3715
3716
3717
3718
3719
	index.linePtr = linePtr;
	index.byteIndex = 0;
	index.textPtr = NULL;
	indexPtr = &index;
	pixelHeight = 0;
    }















    /*
     * Iterate through all display-lines corresponding to the single logical
     * line 'linePtr' (and lines merged into this line due to eol elision),
     * adding up the pixel height of each such display line as we go along.
     * The final total is, therefore, the total height of all display lines
     * made up by the logical line 'linePtr' and subsequent logical lines
     * merged into this line.







>
>
>
>
>
>
>
>
>
>
>
>
>
>







3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
	index.linePtr = linePtr;
	index.byteIndex = 0;
	index.textPtr = NULL;
	indexPtr = &index;
	pixelHeight = 0;
    }

    /*
     * CalculateDisplayLineHeight _must_ be called (below) with an index at
     * the beginning of a display line. Force this to happen. This is needed
     * when TkTextUpdateOneLine is called with a line that is merged with its
     * previous line: the number of merged logical lines in a display line is
     * calculated correctly only when CalculateDisplayLineHeight receives
     * an index at the beginning of a display line. In turn this causes the
     * merged lines to receive their correct zero pixel height in
     * TkBTreeAdjustPixelHeight.
     */

    TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL);
    linePtr = indexPtr->linePtr;

    /*
     * Iterate through all display-lines corresponding to the single logical
     * line 'linePtr' (and lines merged into this line due to eol elision),
     * adding up the pixel height of each such display line as we go along.
     * The final total is, therefore, the total height of all display lines
     * made up by the logical line 'linePtr' and subsequent logical lines
     * merged into this line.

Changes to tests/text.test.

729
730
731
732
733
734
735


















736
737
738
739
740
741
742
    .mytop.t tag add hidden 2.15 3.10
    .mytop.t configure -wrap char
    lappend res [.mytop.t count -displaylines 2.0 3.0]
    lappend res [.mytop.t count -displaylines 2.0 3.40]
} -cleanup {
    destroy .mytop
} -result {1 3}



















# Newer tags are higher priority
.t tag configure elide1 -elide 0
.t tag configure elide2 -elide 1
.t tag configure elide3 -elide 0
.t tag configure elide4 -elide 1








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
    .mytop.t tag add hidden 2.15 3.10
    .mytop.t configure -wrap char
    lappend res [.mytop.t count -displaylines 2.0 3.0]
    lappend res [.mytop.t count -displaylines 2.0 3.40]
} -cleanup {
    destroy .mytop
} -result {1 3}
test text-9.2.47 {TextWidgetCmd procedure, "count" option} -setup {
    .t delete 1.0 end
    update
    set res {}
} -body {
    for {set i 1} {$i < 25} {incr i} {
        .t insert end "Line $i\n"
    }
    .t tag configure hidden -elide true
    .t tag add hidden 5.7 11.0
    update
    set y1 [lindex [.t yview] 1]
    .t count -displaylines 5.0 11.0
    set y2 [lindex [.t yview] 1]
    .t count -displaylines 5.0 12.0
    set y3 [lindex [.t yview] 1]
    list [expr {$y1 == $y2}] [expr {$y1 == $y3}]
} -result {1 1}

# Newer tags are higher priority
.t tag configure elide1 -elide 0
.t tag configure elide2 -elide 1
.t tag configure elide3 -elide 0
.t tag configure elide4 -elide 1