代码拉取完成,页面将自动刷新
package s
import "fmt"
var (
BAR = Dict[Str, int]{}
)
func (self Str) BarPrint(tag Str) Str {
rw.Lock()
line, ok := BAR[tag]
if !ok {
line = BAR.Len() + 1
BAR[tag] = BAR.Len() + 1
}
rw.Unlock()
// fmt.Println("row :", line)
Str("").ANSISave().ANSICursor(line, 0).ANSIClearThisLine().A(self.Strip()).ANSIRestore().Print()
return self
}
/* BarShowSize
use {key} {speed} {size}
example : Str("[{key}] : speed : {speed} | size : {size} "
*/
func (self Str) BarShowSize(tag Str, usedSec float64, size int64, finish bool, allSize ...int64) Str {
c := "B"
cp := "B"
cf := float64(size)
speedSize := cf / usedSec
if size > 1024*1024*1024 {
c = "GB"
cf = cf / (1024 * 1024 * 1024)
// fmt.Println(c, cf)
} else if size > 1024*1024 {
c = "MB"
cf = cf / (1024 * 1024)
// fmt.Println(c, cf)
} else if size > 1024 {
c = "KB"
cf = cf / 1024
// fmt.Println(c, cf)
}
if speedSize > 1024*1024*1024 {
cp = "GB"
speedSize = speedSize / (1024 * 1024 * 1024)
// fmt.Println(c, cf)
} else if speedSize > 1024*1024 {
cp = "MB"
speedSize = speedSize / (1024 * 1024)
// fmt.Println(c, cf)
} else if speedSize > 1024 {
cp = "KB"
speedSize = speedSize / 1024
// fmt.Println(c, cf)
}
SizeStr := fmt.Sprintf("%.2f%s", cf, c)
speedStr := fmt.Sprintf("%.2f%s/sec", speedSize, cp)
// self.Strip().ANSISelected() + Str(
if !self.Has("{") {
self = Str("[{key}]").ANSIBold()
self += Str("| speed: {speed} | size: {size} ").ANSIGreen().ANSIItalic()
self += Str("| used: {time}s ").ANSIYellow().ANSIUnderline()
}
if self.Has("{key}") {
self = self.Format(Dict[Str, any]{
"key": tag,
})
}
if self.Has("{speed}") {
self = self.Format(Dict[Str, any]{
"speed": speedStr,
})
}
if self.Has("{size}") {
self = self.Format(Dict[Str, any]{
"size": SizeStr,
})
}
if self.Has("{time}") {
self = self.Format(Dict[Str, any]{
"time": fmt.Sprintf("%.2f", usedSec),
})
}
if allSize != nil && size > 0 {
per := float64(size*100) / float64(allSize[0])
self = Sprintf("(%%%.2f) - ", per).ANSIGreen() + self
}
if finish {
self = Str("(finish) - ").ANSIGreen().ANSIBold().ANSIItalic().ANSIBlink() + self
}
return self.BarPrint(tag)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。