6618
make_secsel $id
6619
6620
if {$isnew} {
6621
- addtohistory [list selbyid $id]
6621
+ addtohistory [list selbyid $id 0] savecmitpos
6622
}
6623
6624
$sha1entry delete 0 end
6770
}
6771
}
6772
6773
-proc addtohistory {cmd} {
6773
+proc addtohistory {cmd {saveproc {}}} {
6774
global history historyindex curview
6775
6776
- set elt [list $curview $cmd]
6776
+ unset_posvars
6777
+ save_position
6778
+ set elt [list $curview $cmd $saveproc {}]
6779
if {$historyindex > 0
6780
&& [lindex $history [expr {$historyindex - 1}]] == $elt} {
6781
return
6795
.tf.bar.rightbut conf -state disabled
6796
}
6797
6798
+# save the scrolling position of the diff display pane
6799
+proc save_position {} {
6800
+ global historyindex history
6801
+
6802
+ if {$historyindex < 1} return
6803
+ set hi [expr {$historyindex - 1}]
6804
+ set fn [lindex $history $hi 2]
6805
+ if {$fn ne {}} {
6806
+ lset history $hi 3 [eval $fn]
6807
+ }
6808
+}
6809
+
6810
+proc unset_posvars {} {
6811
+ global last_posvars
6812
+
6813
+ if {[info exists last_posvars]} {
6814
+ foreach {var val} $last_posvars {
6815
+ global $var
6816
+ catch {unset $var}
6817
+ }
6818
+ unset last_posvars
6819
+ }
6820
+}
6821
+
6822
proc godo {elt} {
6797
- global curview
6823
+ global curview last_posvars
6824
6825
set view [lindex $elt 0]
6826
set cmd [lindex $elt 1]
6827
+ set pv [lindex $elt 3]
6828
if {$curview != $view} {
6829
showview $view
6830
}
6831
+ unset_posvars
6832
+ foreach {var val} $pv {
6833
+ global $var
6834
+ set $var $val
6835
+ }
6836
+ set last_posvars $pv
6837
eval $cmd
6838
}
6839
6842
focus .
6843
6844
if {$historyindex > 1} {
6845
+ save_position
6846
incr historyindex -1
6847
godo [lindex $history [expr {$historyindex - 1}]]
6848
.tf.bar.rightbut conf -state normal
6857
focus .
6858
6859
if {$historyindex < [llength $history]} {
6860
+ save_position
6861
set cmd [lindex $history $historyindex]
6862
incr historyindex
6863
godo $cmd
7224
filerun $bdf [list getblobdiffline $bdf $diffids]
7225
}
7226
7227
+proc savecmitpos {} {
7228
+ global ctext cmitmode
7229
+
7230
+ if {$cmitmode eq "tree"} {
7231
+ return {}
7232
+ }
7233
+ return [list target_scrollpos [$ctext index @0,0]]
7234
+}
7235
+
7236
+proc savectextpos {} {
7237
+ global ctext
7238
+
7239
+ return [list target_scrollpos [$ctext index @0,0]]
7240
+}
7241
+
7242
+proc maybe_scroll_ctext {ateof} {
7243
+ global ctext target_scrollpos
7244
+
7245
+ if {![info exists target_scrollpos]} return
7246
+ if {!$ateof} {
7247
+ set nlines [expr {[winfo height $ctext]
7248
+ / [font metrics textfont -linespace]}]
7249
+ if {[$ctext compare "$target_scrollpos + $nlines lines" <= end]} return
7250
+ }
7251
+ $ctext yview $target_scrollpos
7252
+ unset target_scrollpos
7253
+}
7254
+
7255
proc setinlist {var i val} {
7256
global $var
7257
7446
if {[info exists seehere]} {
7447
mark_ctext_line [lindex [split $seehere .] 0]
7448
}
7449
+ maybe_scroll_ctext [eof $bdf]
7450
$ctext conf -state disabled
7451
if {[eof $bdf]} {
7452
close $bdf
7941
}
7942
7943
if {$isnew} {
7880
- addtohistory [list lineclick $x $y $id 0]
7944
+ addtohistory [list lineclick $x $y $id 0] savectextpos
7945
}
7946
# fill the details pane with info about this line
7947
$ctext conf -state normal
7972
$ctext insert end "\n\t[mc "Date"]:\t$date\n"
7973
}
7974
}
7975
+ maybe_scroll_ctext 1
7976
$ctext conf -state disabled
7977
init_flist {}
7978
}
7986
}
7987
}
7988
7924
-proc selbyid {id} {
7989
+proc selbyid {id {isnew 1}} {
7990
global curview
7991
if {[commitinview $id $curview]} {
7927
- selectline [rowofcommit $id] 1
7992
+ selectline [rowofcommit $id] $isnew
7993
}
7994
}
7995
8039
set oldid $rowmenuid
8040
set newid [commitonrow $selectedline]
8041
}
7977
- addtohistory [list doseldiff $oldid $newid]
8042
+ addtohistory [list doseldiff $oldid $newid] savectextpos
8043
doseldiff $oldid $newid
8044
}
8045
9951
global ctext tagcontents tagids linknum tagobjid
9952
9953
if {$isnew} {
9889
- addtohistory [list showtag $tag 0]
9954
+ addtohistory [list showtag $tag 0] savectextpos
9955
}
9956
$ctext conf -state normal
9957
clear_ctext
9968
set text "[mc "Tag"]: $tag\n[mc "Id"]: $tagids($tag)"
9969
}
9970
appendwithlinks $text {}
9971
+ maybe_scroll_ctext
9972
$ctext conf -state disabled
9973
init_flist {}
9974
}