@matheusbsbs / matheus-bagliano / commits / 6df7403a98
Fork 0

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>

Paul Mackerras committed May 11, 2008 at 22:13 UTC 6df7403a98737026daeb77cf5a75e2a491aeac70
1 file changed +28 -39
gitk
+28 -39
@@ -293,11 +293,10 @@ proc parseviewrevs {view revs} {
293
294 # Start off a git log process and arrange to read its output
295 proc start_rev_list {view} {
296 - global startmsecs commitidx viewcomplete
296 + global startmsecs commitidx viewcomplete curview
297 global commfd leftover tclencoding
298 global viewargs viewargscmd viewfiles vfilelimit
299 global showlocalchanges commitinterest mainheadid
300 - global progressdirn progresscoords proglastnc curview
300 global viewactive loginstance viewinstances vmergeonly
301 global pending_select mainheadid
302 global vcanopt vflags vrevs vorigargs
@@ -369,9 +368,6 @@ proc start_rev_list {view} {
368 filerun $fd [list getcommitlines $fd $i $view 0]
369 nowbusy $view [mc "Reading"]
370 if {$view == $curview} {
372 - set progressdirn 1
373 - set progresscoords {0 0}
374 - set proglastnc 0
371 set pending_select $mainheadid
372 }
373 set viewcomplete($view) 0
@@ -493,12 +489,10 @@ proc updatecommits {} {
489 proc reloadcommits {} {
490 global curview viewcomplete selectedline currentid thickerline
491 global showneartags treediffs commitinterest cached_commitrow
496 - global progresscoords targetid
492 + global targetid
493
494 if {!$viewcomplete($curview)} {
495 stop_rev_list $curview
500 - set progresscoords {0 0}
501 - adjustprogress
496 }
497 resetvarcs $curview
498 catch {unset selectedline}
@@ -1278,7 +1272,7 @@ proc getcommitlines {fd inst view updating} {
1272 if {![eof $fd]} {
1273 return 1
1274 }
1281 - global commfd viewcomplete viewactive viewname progresscoords
1275 + global commfd viewcomplete viewactive viewname
1276 global viewinstances
1277 unset commfd($inst)
1278 set i [lsearch -exact $viewinstances($view) $inst]
@@ -1311,8 +1305,6 @@ proc getcommitlines {fd inst view updating} {
1305 # appeared in the list
1306 closevarcs $view
1307 notbusy $view
1314 - set progresscoords {0 0}
1315 - adjustprogress
1308 }
1309 if {$view == $curview} {
1310 run chewcommits
@@ -1463,33 +1455,6 @@ proc getcommitlines {fd inst view updating} {
1455 foreach s $scripts {
1456 eval $s
1457 }
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 - }
1458 }
1459 return 2
1460 }
@@ -1747,7 +1712,7 @@ proc makewindow {} {
1712 global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
1713 global headctxmenu progresscanv progressitem progresscoords statusw
1714 global fprogitem fprogcoord lastprogupdate progupdatepending
1750 - global rprogitem rprogcoord
1715 + global rprogitem rprogcoord rownumsel numcommits
1716 global have_tk85
1717
1718 menu .bar
@@ -1863,6 +1828,18 @@ proc makewindow {} {
1828 -state disabled -width 26
1829 pack .tf.bar.rightbut -side left -fill y
1830
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 +
1843 # Status label and progress bar
1844 set statusw .tf.bar.status
1845 label $statusw -width 15 -relief sunken
@@ -2204,6 +2181,17 @@ proc windows_mousewheel_redirector {W X Y D} {
2181 }
2182 }
2183
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 +
2195 # mouse-2 makes all windows scan vertically, but only the one
2196 # the cursor is in scans horizontally
2197 proc canvscan {op w x y} {
@@ -9877,6 +9865,7 @@ set viewperm(0) 0
9865 set viewargs(0) {}
9866 set viewargscmd(0) {}
9867
9868 +set numcommits 0
9869 set loginstance 0
9870 set cmdlineok 0
9871 set stopped 0