Skip to content

Commit 6df7403

Browse files
committed
gitk: Show current row number and total number of rows
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>
1 parent e8a0c69 commit 6df7403

File tree

1 file changed

+28
-39
lines changed

1 file changed

+28
-39
lines changed

gitk

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,10 @@ proc parseviewrevs {view revs} {
293293

294294
# Start off a git log process and arrange to read its output
295295
proc start_rev_list {view} {
296-
global startmsecs commitidx viewcomplete
296+
global startmsecs commitidx viewcomplete curview
297297
global commfd leftover tclencoding
298298
global viewargs viewargscmd viewfiles vfilelimit
299299
global showlocalchanges commitinterest mainheadid
300-
global progressdirn progresscoords proglastnc curview
301300
global viewactive loginstance viewinstances vmergeonly
302301
global pending_select mainheadid
303302
global vcanopt vflags vrevs vorigargs
@@ -369,9 +368,6 @@ proc start_rev_list {view} {
369368
filerun $fd [list getcommitlines $fd $i $view 0]
370369
nowbusy $view [mc "Reading"]
371370
if {$view == $curview} {
372-
set progressdirn 1
373-
set progresscoords {0 0}
374-
set proglastnc 0
375371
set pending_select $mainheadid
376372
}
377373
set viewcomplete($view) 0
@@ -493,12 +489,10 @@ proc updatecommits {} {
493489
proc reloadcommits {} {
494490
global curview viewcomplete selectedline currentid thickerline
495491
global showneartags treediffs commitinterest cached_commitrow
496-
global progresscoords targetid
492+
global targetid
497493

498494
if {!$viewcomplete($curview)} {
499495
stop_rev_list $curview
500-
set progresscoords {0 0}
501-
adjustprogress
502496
}
503497
resetvarcs $curview
504498
catch {unset selectedline}
@@ -1278,7 +1272,7 @@ proc getcommitlines {fd inst view updating} {
12781272
if {![eof $fd]} {
12791273
return 1
12801274
}
1281-
global commfd viewcomplete viewactive viewname progresscoords
1275+
global commfd viewcomplete viewactive viewname
12821276
global viewinstances
12831277
unset commfd($inst)
12841278
set i [lsearch -exact $viewinstances($view) $inst]
@@ -1311,8 +1305,6 @@ proc getcommitlines {fd inst view updating} {
13111305
# appeared in the list
13121306
closevarcs $view
13131307
notbusy $view
1314-
set progresscoords {0 0}
1315-
adjustprogress
13161308
}
13171309
if {$view == $curview} {
13181310
run chewcommits
@@ -1463,33 +1455,6 @@ proc getcommitlines {fd inst view updating} {
14631455
foreach s $scripts {
14641456
eval $s
14651457
}
1466-
if {$view == $curview} {
1467-
# update progress bar
1468-
global progressdirn progresscoords proglastnc
1469-
set inc [expr {($commitidx($view) - $proglastnc) * 0.0002}]
1470-
set proglastnc $commitidx($view)
1471-
set l [lindex $progresscoords 0]
1472-
set r [lindex $progresscoords 1]
1473-
if {$progressdirn} {
1474-
set r [expr {$r + $inc}]
1475-
if {$r >= 1.0} {
1476-
set r 1.0
1477-
set progressdirn 0
1478-
}
1479-
if {$r > 0.2} {
1480-
set l [expr {$r - 0.2}]
1481-
}
1482-
} else {
1483-
set l [expr {$l - $inc}]
1484-
if {$l <= 0.0} {
1485-
set l 0.0
1486-
set progressdirn 1
1487-
}
1488-
set r [expr {$l + 0.2}]
1489-
}
1490-
set progresscoords [list $l $r]
1491-
adjustprogress
1492-
}
14931458
}
14941459
return 2
14951460
}
@@ -1747,7 +1712,7 @@ proc makewindow {} {
17471712
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
17481713
global headctxmenu progresscanv progressitem progresscoords statusw
17491714
global fprogitem fprogcoord lastprogupdate progupdatepending
1750-
global rprogitem rprogcoord
1715+
global rprogitem rprogcoord rownumsel numcommits
17511716
global have_tk85
17521717

17531718
menu .bar
@@ -1863,6 +1828,18 @@ proc makewindow {} {
18631828
-state disabled -width 26
18641829
pack .tf.bar.rightbut -side left -fill y
18651830

1831+
label .tf.bar.rowlabel -text [mc "Row"]
1832+
set rownumsel {}
1833+
label .tf.bar.rownum -width 7 -font textfont -textvariable rownumsel \
1834+
-relief sunken -anchor e
1835+
label .tf.bar.rowlabel2 -text "/"
1836+
label .tf.bar.numcommits -width 7 -font textfont -textvariable numcommits \
1837+
-relief sunken -anchor e
1838+
pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
1839+
-side left
1840+
global selectedline
1841+
trace add variable selectedline {write unset} selectedline_change
1842+
18661843
# Status label and progress bar
18671844
set statusw .tf.bar.status
18681845
label $statusw -width 15 -relief sunken
@@ -2204,6 +2181,17 @@ proc windows_mousewheel_redirector {W X Y D} {
22042181
}
22052182
}
22062183

2184+
# Update row number label when selectedline changes
2185+
proc selectedline_change {n1 n2 op} {
2186+
global selectedline rownumsel
2187+
2188+
if {$op eq "unset"} {
2189+
set rownumsel {}
2190+
} else {
2191+
set rownumsel [expr {$selectedline + 1}]
2192+
}
2193+
}
2194+
22072195
# mouse-2 makes all windows scan vertically, but only the one
22082196
# the cursor is in scans horizontally
22092197
proc canvscan {op w x y} {
@@ -9877,6 +9865,7 @@ set viewperm(0) 0
98779865
set viewargs(0) {}
98789866
set viewargscmd(0) {}
98799867

9868+
set numcommits 0
98809869
set loginstance 0
98819870
set cmdlineok 0
98829871
set stopped 0

0 commit comments

Comments
 (0)