* Shaun Deacon <
[email protected]>
| The obvious solution to me is to just highlight the currently visible
| lines (or a range of lines spanning the current view - say 1000 or so)
| and when the user scrolls the window, highlight the new set of lines.
| Suggestions on the best way to find the indexes for the currently
| visible lines when the widget has been scrolled would be great.
| Can someone please point me in the right direction ?
You could try 'text yview' and derive the displayed lines from that:
grid [text .t -yscrollcommand {recalc {.s set}}] -sticky ewns -row 0 -column 0
grid [scrollbar .s -command {recalc {.t yview}} -orient vertical] -sticky ns -row 0 -column 1
grid [label .l] - -sticky ewns
grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1
for {set l 1} {$l < 1000} {incr l} {
.t insert end "Line $l\n"
}
proc recalc {cmd args} {
# scroll if required
if {$cmd ne ""} {
{*}$cmd {*}$args
}
# Determine the visible range
lassign [.t yview] start end
# Get line count
set lines [lindex [split [.t index end] "."] 0]
# Get first and last line displayed.
# Here you need to determine what to do with the partially displayed lines
set first [format %.1f [expr {$start*$lines+1}]]
set last [format %.1f [expr {$end*$lines}]]
.l configure -text "visible Lines $first ... $last"
}
bind . <Configure> [list recalc ""]
HTH
R'
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)