- allcanvs yview moveto $ytop
- } elseif {$ybot > [lindex $wnow 1]} {
- set wh [expr {[lindex $wnow 1] - $wtop}]
- set ytop [expr {$ybot - $wh}]
- if {$ytop < $wtop + $scrincr} {
- set ytop [expr {$wtop + $scrincr}]
+ } elseif {$ybot > $wbot} {
+ if {$ytop > $wbot} {
+ set newtop [expr {$y - $wh / 2.0}]
+ } else {
+ set newtop [expr {$ybot - $wh}]
+ if {$newtop < $wtop + $linespc} {
+ set newtop [expr {$wtop + $linespc}]
+ }