mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
8ead1bfe11
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) iQCVAwUAUH8cCGB90JXwhOSJAQI2ywP+PPdCYqxkpGzYYQkf/ZU3JFBqJqSxQE6i V4ROiW+iHaS5EqWt7GvXc0G5M8b+7M0TMtCjwozSD1ne+Ced+ZOfxqSUOgGQL2XD Vc4nHsITLNkhlSYlRP6VqXLsuW47iq+Hw/LQcSBvG79A3ooSC1QktfKV2JmtqIxr i6lfGwM7yT4= =zifn -----END PGP SIGNATURE----- Merge tag 'gitgui-0.17.0' of git://repo.or.cz/git-gui git-gui 0.17.0 * tag 'gitgui-0.17.0' of git://repo.or.cz/git-gui: git-gui 0.17 git-gui: Don't prepend the prefix if value looks like a full path git-gui: Detect full path when parsing arguments git-gui: remove .git/CHERRY_PICK_HEAD after committing git-gui: Fix a loose/lose mistake git-gui: Fix semi-working shortcuts for unstage and revert git-gui: de.po: translate "remote" as "extern" git-gui: de.po: translate "bare" as "bloß" git-gui: de.po: consistently add untranslated hook names within braces git-gui: preserve commit messages in utf-8 git-gui: open console when using --trace on windows git-gui: fix a typo in po/ files git-gui: Use PWD if it exists on Mac OS X git-gui: fix git-gui crash due to uninitialized variable
131 lines
2.5 KiB
Tcl
131 lines
2.5 KiB
Tcl
# git-gui status bar mega-widget
|
|
# Copyright (C) 2007 Shawn Pearce
|
|
|
|
class status_bar {
|
|
|
|
field w ; # our own window path
|
|
field w_l ; # text widget we draw messages into
|
|
field w_c ; # canvas we draw a progress bar into
|
|
field c_pack ; # script to pack the canvas with
|
|
field status {}; # single line of text we show
|
|
field prefix {}; # text we format into status
|
|
field units {}; # unit of progress
|
|
field meter {}; # current core git progress meter (if active)
|
|
|
|
constructor new {path} {
|
|
global use_ttk NS
|
|
set w $path
|
|
set w_l $w.l
|
|
set w_c $w.c
|
|
|
|
${NS}::frame $w
|
|
if {!$use_ttk} {
|
|
$w configure -borderwidth 1 -relief sunken
|
|
}
|
|
${NS}::label $w_l \
|
|
-textvariable @status \
|
|
-anchor w \
|
|
-justify left
|
|
pack $w_l -side left
|
|
set c_pack [cb _oneline_pack]
|
|
|
|
bind $w <Destroy> [cb _delete %W]
|
|
return $this
|
|
}
|
|
|
|
method _oneline_pack {} {
|
|
$w_c conf -width 100
|
|
pack $w_c -side right
|
|
}
|
|
|
|
constructor two_line {path} {
|
|
global NS
|
|
set w $path
|
|
set w_l $w.l
|
|
set w_c $w.c
|
|
|
|
${NS}::frame $w
|
|
${NS}::label $w_l \
|
|
-textvariable @status \
|
|
-anchor w \
|
|
-justify left
|
|
pack $w_l -anchor w -fill x
|
|
set c_pack [list pack $w_c -fill x]
|
|
|
|
bind $w <Destroy> [cb _delete %W]
|
|
return $this
|
|
}
|
|
|
|
method start {msg uds} {
|
|
if {[winfo exists $w_c]} {
|
|
$w_c coords bar 0 0 0 20
|
|
} else {
|
|
canvas $w_c \
|
|
-height [expr {int([winfo reqheight $w_l] * 0.6)}] \
|
|
-borderwidth 1 \
|
|
-relief groove \
|
|
-highlightt 0
|
|
$w_c create rectangle 0 0 0 20 -tags bar -fill navy
|
|
eval $c_pack
|
|
}
|
|
|
|
set status $msg
|
|
set prefix $msg
|
|
set units $uds
|
|
set meter {}
|
|
}
|
|
|
|
method update {have total} {
|
|
set pdone 0
|
|
set cdone 0
|
|
if {$total > 0} {
|
|
set pdone [expr {100 * $have / $total}]
|
|
set cdone [expr {[winfo width $w_c] * $have / $total}]
|
|
}
|
|
|
|
set prec [string length [format %i $total]]
|
|
set status [mc "%s ... %*i of %*i %s (%3i%%)" \
|
|
$prefix \
|
|
$prec $have \
|
|
$prec $total \
|
|
$units $pdone]
|
|
$w_c coords bar 0 0 $cdone 20
|
|
}
|
|
|
|
method update_meter {buf} {
|
|
append meter $buf
|
|
set r [string last "\r" $meter]
|
|
if {$r == -1} {
|
|
return
|
|
}
|
|
|
|
set prior [string range $meter 0 $r]
|
|
set meter [string range $meter [expr {$r + 1}] end]
|
|
set p "\\((\\d+)/(\\d+)\\)"
|
|
if {[regexp ":\\s*\\d+% $p\(?:, done.\\s*\n|\\s*\r)\$" $prior _j a b]} {
|
|
update $this $a $b
|
|
} elseif {[regexp "$p\\s+done\r\$" $prior _j a b]} {
|
|
update $this $a $b
|
|
}
|
|
}
|
|
|
|
method stop {{msg {}}} {
|
|
destroy $w_c
|
|
if {$msg ne {}} {
|
|
set status $msg
|
|
}
|
|
}
|
|
|
|
method show {msg {test {}}} {
|
|
if {$test eq {} || $status eq $test} {
|
|
set status $msg
|
|
}
|
|
}
|
|
|
|
method _delete {current} {
|
|
if {$current eq $w} {
|
|
delete_this
|
|
}
|
|
}
|
|
|
|
}
|