Skip to content

Commit

Permalink
gitk: Show current row number and total number of rows
Browse files Browse the repository at this point in the history
This adds a couple of fields in the bar just below the upper panes
that show the row number of the currently selected commit, and how
many rows are displayed in total.  The latter increments as commits
are read in, and thus functions to show that progress is being made.
This therefore also removes the code that showed progress using a
green oscillating bar in the progress bar window (which some people
disliked).

Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
paulusmack committed May 11, 2008
1 parent e8a0c69 commit 6df7403
Showing 1 changed file with 28 additions and 39 deletions.
67 changes: 28 additions & 39 deletions gitk
Expand Up @@ -293,11 +293,10 @@ proc parseviewrevs {view revs} {

# Start off a git log process and arrange to read its output
proc start_rev_list {view} {
global startmsecs commitidx viewcomplete
global startmsecs commitidx viewcomplete curview
global commfd leftover tclencoding
global viewargs viewargscmd viewfiles vfilelimit
global showlocalchanges commitinterest mainheadid
global progressdirn progresscoords proglastnc curview
global viewactive loginstance viewinstances vmergeonly
global pending_select mainheadid
global vcanopt vflags vrevs vorigargs
Expand Down Expand Up @@ -369,9 +368,6 @@ proc start_rev_list {view} {
filerun $fd [list getcommitlines $fd $i $view 0]
nowbusy $view [mc "Reading"]
if {$view == $curview} {
set progressdirn 1
set progresscoords {0 0}
set proglastnc 0
set pending_select $mainheadid
}
set viewcomplete($view) 0
Expand Down Expand Up @@ -493,12 +489,10 @@ proc updatecommits {} {
proc reloadcommits {} {
global curview viewcomplete selectedline currentid thickerline
global showneartags treediffs commitinterest cached_commitrow
global progresscoords targetid
global targetid

if {!$viewcomplete($curview)} {
stop_rev_list $curview
set progresscoords {0 0}
adjustprogress
}
resetvarcs $curview
catch {unset selectedline}
Expand Down Expand Up @@ -1278,7 +1272,7 @@ proc getcommitlines {fd inst view updating} {
if {![eof $fd]} {
return 1
}
global commfd viewcomplete viewactive viewname progresscoords
global commfd viewcomplete viewactive viewname
global viewinstances
unset commfd($inst)
set i [lsearch -exact $viewinstances($view) $inst]
Expand Down Expand Up @@ -1311,8 +1305,6 @@ proc getcommitlines {fd inst view updating} {
# appeared in the list
closevarcs $view
notbusy $view
set progresscoords {0 0}
adjustprogress
}
if {$view == $curview} {
run chewcommits
Expand Down Expand Up @@ -1463,33 +1455,6 @@ proc getcommitlines {fd inst view updating} {
foreach s $scripts {
eval $s
}
if {$view == $curview} {
# update progress bar
global progressdirn progresscoords proglastnc
set inc [expr {($commitidx($view) - $proglastnc) * 0.0002}]
set proglastnc $commitidx($view)
set l [lindex $progresscoords 0]
set r [lindex $progresscoords 1]
if {$progressdirn} {
set r [expr {$r + $inc}]
if {$r >= 1.0} {
set r 1.0
set progressdirn 0
}
if {$r > 0.2} {
set l [expr {$r - 0.2}]
}
} else {
set l [expr {$l - $inc}]
if {$l <= 0.0} {
set l 0.0
set progressdirn 1
}
set r [expr {$l + 0.2}]
}
set progresscoords [list $l $r]
adjustprogress
}
}
return 2
}
Expand Down Expand Up @@ -1747,7 +1712,7 @@ proc makewindow {} {
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
global headctxmenu progresscanv progressitem progresscoords statusw
global fprogitem fprogcoord lastprogupdate progupdatepending
global rprogitem rprogcoord
global rprogitem rprogcoord rownumsel numcommits
global have_tk85

menu .bar
Expand Down Expand Up @@ -1863,6 +1828,18 @@ proc makewindow {} {
-state disabled -width 26
pack .tf.bar.rightbut -side left -fill y

label .tf.bar.rowlabel -text [mc "Row"]
set rownumsel {}
label .tf.bar.rownum -width 7 -font textfont -textvariable rownumsel \
-relief sunken -anchor e
label .tf.bar.rowlabel2 -text "/"
label .tf.bar.numcommits -width 7 -font textfont -textvariable numcommits \
-relief sunken -anchor e
pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
-side left
global selectedline
trace add variable selectedline {write unset} selectedline_change

# Status label and progress bar
set statusw .tf.bar.status
label $statusw -width 15 -relief sunken
Expand Down Expand Up @@ -2204,6 +2181,17 @@ proc windows_mousewheel_redirector {W X Y D} {
}
}

# Update row number label when selectedline changes
proc selectedline_change {n1 n2 op} {
global selectedline rownumsel

if {$op eq "unset"} {
set rownumsel {}
} else {
set rownumsel [expr {$selectedline + 1}]
}
}

# mouse-2 makes all windows scan vertically, but only the one
# the cursor is in scans horizontally
proc canvscan {op w x y} {
Expand Down Expand Up @@ -9877,6 +9865,7 @@ set viewperm(0) 0
set viewargs(0) {}
set viewargscmd(0) {}

set numcommits 0
set loginstance 0
set cmdlineok 0
set stopped 0
Expand Down

0 comments on commit 6df7403

Please sign in to comment.