1 # git-gui status bar mega-widget
2 # Copyright (C) 2007 Shawn Pearce
6 field w ; # our own window path
7 field w_l ; # text widget we draw messages into
8 field w_c ; # canvas we draw a progress bar into
9 field status {}; # single line of text we show
10 field prefix {}; # text we format into status
11 field units {}; # unit of progress
12 field meter {}; # current core git progress meter (if active)
14 constructor new {path} {
23 -textvariable @status \
28 bind $w <Destroy> [cb _delete %W]
32 method start {msg uds} {
33 if {[winfo exists $w_c]} {
34 $w_c coords bar 0 0 0 20
38 -height [expr {int([winfo reqheight $w_l] * 0.6)}] \
42 $w_c create rectangle 0 0 0 20 -tags bar -fill navy
52 method update {have total} {
55 set pdone [expr {100 * $have / $total}]
58 set status [format "%s ... %i of %i %s (%2i%%)" \
59 $prefix $have $total $units $pdone]
60 $w_c coords bar 0 0 $pdone 20
63 method update_meter {buf} {
65 set r [string last "\r" $meter]
70 set prior [string range $meter 0 $r]
71 set meter [string range $meter [expr {$r + 1}] end]
72 set p "\\((\\d+)/(\\d+)\\)"
73 if {[regexp ":\\s*\\d+% $p\(?:, done.\\s*\n|\\s*\r)\$" $prior _j a b]} {
75 } elseif {[regexp "$p\\s+done\r\$" $prior _j a b]} {
80 method stop {{msg {}}} {
87 method show {msg {test {}}} {
88 if {$test eq {} || $status eq $test} {
93 method _delete {current} {