summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e116013)
raw | patch | inline | side by side (parent: e116013)
author | Paul Mackerras <paulus@samba.org> | |
Sun, 23 Nov 2008 02:14:23 +0000 (13:14 +1100) | ||
committer | Paul Mackerras <paulus@samba.org> | |
Sun, 23 Nov 2008 02:14:23 +0000 (13:14 +1100) |
This arranges to save the scrolling position of the diff display pane
when we move from displaying one thing to another, and then scroll the
pane to the same position when we go back to the previous thing using
the back or forward buttons. This works if we have clicked on a commit
and are in patch display mode, or if we have clicked on a line or a tag,
or have done a diff between two commits with the context menu. It
doesn't currently restore the pane to where it was if is was displaying
a commit in tree display mode.
For future extensibility, addtohistory now takes an extra optional
argument which is a script to invoke when moving from this thing to
another. The script needs to return a list of pairs of variable name
and value. If we go back to this thing, the godo procedure will set
the named variables to the values given. At present that is just used
to store the $ctext scrolling position, but in future we will use it
to store the state of which directories are open in the file list pane.
Signed-off-by: Paul Mackerras <paulus@samba.org>
when we move from displaying one thing to another, and then scroll the
pane to the same position when we go back to the previous thing using
the back or forward buttons. This works if we have clicked on a commit
and are in patch display mode, or if we have clicked on a line or a tag,
or have done a diff between two commits with the context menu. It
doesn't currently restore the pane to where it was if is was displaying
a commit in tree display mode.
For future extensibility, addtohistory now takes an extra optional
argument which is a script to invoke when moving from this thing to
another. The script needs to return a list of pairs of variable name
and value. If we go back to this thing, the godo procedure will set
the named variables to the values given. At present that is just used
to store the $ctext scrolling position, but in future we will use it
to store the state of which directories are open in the file list pane.
Signed-off-by: Paul Mackerras <paulus@samba.org>
gitk | patch | blob | history |
index 9bdaafe40829a35928f5b615e66ac42d9247069a..08a45e1b94a26938215d962fd96e928090ff13a7 100755 (executable)
--- a/gitk
+++ b/gitk
make_secsel $id
if {$isnew} {
- addtohistory [list selbyid $id]
+ addtohistory [list selbyid $id 0] savecmitpos
}
$sha1entry delete 0 end
}
}
-proc addtohistory {cmd} {
+proc addtohistory {cmd {saveproc {}}} {
global history historyindex curview
- set elt [list $curview $cmd]
+ unset_posvars
+ save_position
+ set elt [list $curview $cmd $saveproc {}]
if {$historyindex > 0
&& [lindex $history [expr {$historyindex - 1}]] == $elt} {
return
.tf.bar.rightbut conf -state disabled
}
+# save the scrolling position of the diff display pane
+proc save_position {} {
+ global historyindex history
+
+ if {$historyindex < 1} return
+ set hi [expr {$historyindex - 1}]
+ set fn [lindex $history $hi 2]
+ if {$fn ne {}} {
+ lset history $hi 3 [eval $fn]
+ }
+}
+
+proc unset_posvars {} {
+ global last_posvars
+
+ if {[info exists last_posvars]} {
+ foreach {var val} $last_posvars {
+ global $var
+ catch {unset $var}
+ }
+ unset last_posvars
+ }
+}
+
proc godo {elt} {
- global curview
+ global curview last_posvars
set view [lindex $elt 0]
set cmd [lindex $elt 1]
+ set pv [lindex $elt 3]
if {$curview != $view} {
showview $view
}
+ unset_posvars
+ foreach {var val} $pv {
+ global $var
+ set $var $val
+ }
+ set last_posvars $pv
eval $cmd
}
focus .
if {$historyindex > 1} {
+ save_position
incr historyindex -1
godo [lindex $history [expr {$historyindex - 1}]]
.tf.bar.rightbut conf -state normal
focus .
if {$historyindex < [llength $history]} {
+ save_position
set cmd [lindex $history $historyindex]
incr historyindex
godo $cmd
filerun $bdf [list getblobdiffline $bdf $diffids]
}
+proc savecmitpos {} {
+ global ctext cmitmode
+
+ if {$cmitmode eq "tree"} {
+ return {}
+ }
+ return [list target_scrollpos [$ctext index @0,0]]
+}
+
+proc savectextpos {} {
+ global ctext
+
+ return [list target_scrollpos [$ctext index @0,0]]
+}
+
+proc maybe_scroll_ctext {ateof} {
+ global ctext target_scrollpos
+
+ if {![info exists target_scrollpos]} return
+ if {!$ateof} {
+ set nlines [expr {[winfo height $ctext]
+ / [font metrics textfont -linespace]}]
+ if {[$ctext compare "$target_scrollpos + $nlines lines" <= end]} return
+ }
+ $ctext yview $target_scrollpos
+ unset target_scrollpos
+}
+
proc setinlist {var i val} {
global $var
if {[info exists seehere]} {
mark_ctext_line [lindex [split $seehere .] 0]
}
+ maybe_scroll_ctext [eof $bdf]
$ctext conf -state disabled
if {[eof $bdf]} {
close $bdf
}
if {$isnew} {
- addtohistory [list lineclick $x $y $id 0]
+ addtohistory [list lineclick $x $y $id 0] savectextpos
}
# fill the details pane with info about this line
$ctext conf -state normal
$ctext insert end "\n\t[mc "Date"]:\t$date\n"
}
}
+ maybe_scroll_ctext 1
$ctext conf -state disabled
init_flist {}
}
}
}
-proc selbyid {id} {
+proc selbyid {id {isnew 1}} {
global curview
if {[commitinview $id $curview]} {
- selectline [rowofcommit $id] 1
+ selectline [rowofcommit $id] $isnew
}
}
set oldid $rowmenuid
set newid [commitonrow $selectedline]
}
- addtohistory [list doseldiff $oldid $newid]
+ addtohistory [list doseldiff $oldid $newid] savectextpos
doseldiff $oldid $newid
}
global ctext tagcontents tagids linknum tagobjid
if {$isnew} {
- addtohistory [list showtag $tag 0]
+ addtohistory [list showtag $tag 0] savectextpos
}
$ctext conf -state normal
clear_ctext
set text "[mc "Tag"]: $tag\n[mc "Id"]: $tagids($tag)"
}
appendwithlinks $text {}
+ maybe_scroll_ctext
$ctext conf -state disabled
init_flist {}
}