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 c_pack
; # script to pack the canvas with
10 field status
{}; # single line of text we show
11 field prefix
{}; # text we format into status
12 field units
{}; # unit of progress
13 field meter
{}; # current core git progress meter (if active)
15 constructor new
{path
} {
24 -textvariable @status
\
28 set c_pack
[cb _oneline_pack
]
30 bind $w <Destroy
> [cb _delete
%W
]
34 method _oneline_pack
{} {
39 constructor two_line
{path
} {
46 -textvariable @status
\
49 pack $w_l -anchor w
-fill x
50 set c_pack
[list pack $w_c -fill x
]
52 bind $w <Destroy
> [cb _delete
%W
]
56 method start
{msg uds
} {
57 if {[winfo exists
$w_c]} {
58 $w_c coords bar
0 0 0 20
61 -height [expr {int
([winfo reqheight
$w_l] * 0.6)}] \
65 $w_c create rectangle
0 0 0 20 -tags bar
-fill navy
75 method
update {have total
} {
78 set pdone
[expr {100 * $have / $total}]
79 set cdone
[expr {[winfo width
$w_c] * $have / $total}]
82 set prec
[string length
[format %i
$total]]
83 set status
[mc
"%s ... %*i of %*i %s (%3i%%)" \
88 $w_c coords bar
0 0 $cdone 20
91 method update_meter
{buf
} {
93 set r
[string last
"\r" $meter]
98 set prior
[string range
$meter 0 $r]
99 set meter
[string range
$meter [expr {$r + 1}] end
]
100 if {[regexp "\\((\\d+)/(\\d+)\\)\\s+done\r\$" $prior _j a b
]} {
105 method stop
{{msg
{}}} {
112 method show
{msg
{test
{}}} {
113 if {$test eq
{} ||
$status eq
$test} {
118 method _delete
{current
} {
119 if {$current eq
$w} {