Tk Source Code

Check-in [5f876e86]
Login

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

Overview
Comment:Further fixed text see with indices in elided lines, [5f352f3a71] was not always correct
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | text-elided
Files: files | file ages | folders
SHA1: 5f876e86914a8d95350f951657f51e76ffde0c3d
User & Date: fvogel 2014-12-28 20:58:10
Original Comment: Further fixed text see with indices in elided lines, was not always correct
Context
2014-12-29
16:27
CalculateDisplayLineHeight checks, in debug mode, that the index it receives really is at the beginning of a display line. check-in: 3d28ac07 user: fvogel tags: text-elided
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkTextDisp.c.

5177
5178
5179
5180
5181
5182
5183


5184
5185
5186
5187
5188
5189
5190
5191
     * The desired line isn't already on-screen. Figure out what it means to
     * be "close" to the top or bottom of the screen. Close means within 1/3
     * of the screen height or within three lines, whichever is greater.
     *
     * If the line is not close, place it in the center of the window.
     */



    lineHeight = CalculateDisplayLineHeight(textPtr, indexPtr, NULL, NULL);

    /*
     * It would be better if 'bottomY' were calculated using the actual height
     * of the given line, not 'textPtr->charHeight'.
     */

    bottomY = (dInfoPtr->y + dInfoPtr->maxY + lineHeight)/2;







>
>
|







5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
     * The desired line isn't already on-screen. Figure out what it means to
     * be "close" to the top or bottom of the screen. Close means within 1/3
     * of the screen height or within three lines, whichever is greater.
     *
     * If the line is not close, place it in the center of the window.
     */

    tmpIndex = *indexPtr;
    TkTextFindDisplayLineEnd(textPtr, &tmpIndex, 0, NULL);
    lineHeight = CalculateDisplayLineHeight(textPtr, &tmpIndex, NULL, NULL);

    /*
     * It would be better if 'bottomY' were calculated using the actual height
     * of the given line, not 'textPtr->charHeight'.
     */

    bottomY = (dInfoPtr->y + dInfoPtr->maxY + lineHeight)/2;

Changes to tests/textDisp.test.

1488
1489
1490
1491
1492
1493
1494































1495
1496
1497
1498
1499
1500
1501
    .top.t tag add hidden 5.15 10.3
    .top.t tag configure hidden -elide true
    update
    .top.t see "8.0 lineend"
    # The index "8.0 lineend" is on screen despite elided -> no scroll
    .top.t index @0,0
} {4.0}
































.t configure -wrap word
.t delete 50.0 51.0
.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
test textDisp-12.1 {MeasureUp} {
    .t yview 100.0
    update







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







1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
    .top.t tag add hidden 5.15 10.3
    .top.t tag configure hidden -elide true
    update
    .top.t see "8.0 lineend"
    # The index "8.0 lineend" is on screen despite elided -> no scroll
    .top.t index @0,0
} {4.0}
test textDisp-11.19 {TkTextSetYView, see in elided lines} {
    .top.t delete 1.0 end
    for {set i 1} {$i < 50} {incr i} {
        .top.t insert end "Line $i\n"
    }
    # button just for having a line with a larger height
    button .top.t.b -text "Test" -bd 2 -highlightthickness 2
    .top.t window create 21.0 -window .top.t.b
    .top.t tag add hidden 15.36 21.0
    .top.t tag configure hidden -elide true
    .top.t configure -height 15
    wm geometry .top 300x200+0+0
    # Indices 21.0, 17.0 and 15.0 are all on the same display line
    # therefore index @0,0 shall be the same for all of them
    .top.t see end
    update
    .top.t see 21.0
    update
    set ind1 [.top.t index @0,0]
    .top.t see end
    update
    .top.t see 17.0
    update
    set ind2 [.top.t index @0,0]
    .top.t see end
    update
    .top.t see 15.0
    update
    set ind3 [.top.t index @0,0]
    list [expr {$ind1 == $ind2}] [expr {$ind1 == $ind3}]
} {1 1}

.t configure -wrap word
.t delete 50.0 51.0
.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
test textDisp-12.1 {MeasureUp} {
    .t yview 100.0
    update