| Ticket UUID: | 1630254 | |||
| Title: | problem configuring -startline in a peer | |||
| Type: | Bug | Version: | obsolete: 8.5a6 | |
| Submitter: | treectrl | Created on: | 2007-01-08 03:17:16 | |
| Subsystem: | 18. [text] | Assigned To: | fvogel | |
| Priority: | 7 High | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2013-09-23 21:41:51 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2013-09-23 21:41:51 | |||
| Description: |
Configure a peer to have -startline == -endline as below, it will show no lines. Then setting -startline to the empty string doesn't seem to have any effect on the lines displayed.
pack [text .t] -side top -pady {0 6}
.t insert end "1\n2\n3\n"
pack [.t peer create .peer -startline 2 -endline 2] -side top
Now try clearing -startline; the display should show us line 1:
.peer configure -startline {}
| |||
| User Comments: |
fvogelnew1 added on 2012-05-29 03:48:20:
allow_comments - 1 fvogelnew1 added on 2012-05-29 03:48:02: Merged in core-8-5-branch and in trunk. fvogelnew1 added on 2012-05-17 21:37:09: A bit of a analysis in the source code:
When configuring the text widget -startline and/or -endline, the ConfigureText function:
1. calls TkTextSetYView (which schedules a DisplayText which scrolls the widget) if and only if the current point (defined as the topmost visible line, i.e. topIndex) no longer is between the newly requested start and stop lines. TkTextSetYView is then called with the newly requested start line position, and the widget scrolls so that this newly requested start line becomes the topmost displayed line;
2. redraws the widget in any case (TextWorldChanged, TkTextRelayoutWindow).
This logic seems definitely correct to me. It aims at minimal scrolling of the widget when configuring -startline/-endline.
Indeed one does not expect the widget to scroll whenever -startline/-endline has been changed. For instance, say the topmost displayed line is line 5 (you don't see lines 1-4, which are "hidden above" the top of the widget). Then configure -startline 2. Would you expect the widget to jump to showing line 2 as the first displayed line? I don't think so.
The specific case of this bug report can be reproduced with the following snippet:
text .t
pack .t
for {set i 1} {$i < 10} {incr i} {
.t insert end "Line $i\n"
}
.t configure -start 5 -end 5 ;# no line displayed (OK)
.t configure -start {} ;# still nothing displayed
The first configure sets the startline to line 5, which becomes the topmost displayed line. However, this line is not actually displayed because -endline is also 5.
The second configure requests the widget to consider for display all lines from its very first line up to (but not including) line 5. Following the above described logic this does NOT require scrolling, because the widget is already supposed to display a line (line 5) that is still included in the start/end range.
So it does not scroll according to the logic explained above, and this is just fine.
However it DOES scroll when:
.t configure -start 5 -end 9
.t configure -start {} ; # now shows lines 1-8, line 1 at topmost place!
If the above explained logic was the complete explanation, it should not scroll.
The reason is that in this case, contrary to the previous case, the text widget is not empty when the test for scrolling is called, i.e. the value of textPtr->dInfoPtr->dLinePtr is not NULL in function DisplayText, which makes the for loop run in lines tkTextDisp.c:3976+
In turn, dLinePtr is not NULL because in function UpdateDisplayInfo (tkTextDisp.c:1954) one has:
* If there is extra space at the bottom of the window (because we've hit
* the end of the text), then bring in more lines at the top of the
* window, if there are any, to fill in the view.
Therefore:
.t configure -start 5 -end 9
.t configure -start {}
scrolls only if there is empty space past the last displayed line (this can easily be checked by reducing the height of the widget until it does no longer scroll).
The bug is therefore that this scrolling behaviour when there is extra space at the bottom should also happen when the text widget is empty, i.e. when:
.t configure -start 5 -end 5 ;# no line displayed (OK)
.t configure -start {} ;# lines 1-5 should be displayed
The cause for this bug is that detection of availability of lines from the text widget for display in the extra space is not correctly done in case the text widget was empty i.e. when dInfoPtr->dLinePtr == NULL (tkTextDisp.c:2002, in function UpdateDisplayInfo) but it no longer is empty.
I have provided a fix proposal in branch bug-1630254.
Please review and comment as needed.
fvogelnew1 added on 2012-01-13 20:12:29: This bug is not specific to peers. It happens for any text widget. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki