mirror of
https://github.com/git/git
synced 2024-08-28 20:20:07 +00:00
![Junio C Hamano](/assets/img/avatar_default.png)
* git://repo.or.cz/git-gui: (96 commits) git-gui 0.9.0 git-gui: Bind Meta-T for "Stage To Commit" menu action git-gui: Allow users to set font weights to bold git-gui: Update Japanese strings (part 2) git-gui: Update Japanese strings Updated russian translation of git-gui po2msg: actually output statistics po2msg: ignore untranslated messages po2msg: ignore entries marked with "fuzzy" git-gui: Protect against bad translation strings git-gui: Make sure we get errors from git-update-index More updates and corrections to the russian translation of git-gui Updated Russian translation. git-gui: Update German translation git-gui: Add more terms to glossary. git-gui: Paper bag fix the global config parsing git-gui: Honor a config.mak in git-gui's top level git-gui: Collapse $env(HOME) to ~/ in recent repositories on Windows git-gui: Support cloning Cygwin based work-dirs git-gui: Use proper Windows shortcuts instead of bat files ...
128 lines
2.4 KiB
Tcl
128 lines
2.4 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} {
|
|
set w $path
|
|
set w_l $w.l
|
|
set w_c $w.c
|
|
|
|
frame $w \
|
|
-borderwidth 1 \
|
|
-relief sunken
|
|
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} {
|
|
set w $path
|
|
set w_l $w.l
|
|
set w_c $w.c
|
|
|
|
frame $w
|
|
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
|
|
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
|
|
}
|
|
}
|
|
|
|
}
|