blob: e4293e17c54a3cfd0c3b597756835cfb6f1d07fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package tui
import (
"time"
"github.com/dundee/gdu/v5/internal/common"
"github.com/dundee/gdu/v5/pkg/path"
)
func (ui *UI) updateProgress() {
color := "[white:black:b]"
if ui.UseColors {
color = "[red:black:b]"
}
progressChan := ui.Analyzer.GetProgressChan()
doneChan := ui.Analyzer.GetDone()
var progress common.CurrentProgress
start := time.Now()
for {
select {
case progress = <-progressChan:
case <-doneChan:
ui.app.QueueUpdateDraw(func() {
ui.progress.SetTitle(" Finalizing... ")
ui.progress.SetText("Calculating disk usage...")
})
return
}
func(itemCount int, totalSize int64, currentItem string) {
delta := time.Since(start).Round(time.Second)
ui.app.QueueUpdateDraw(func() {
ui.progress.SetText("Total items: " +
color +
common.FormatNumber(int64(itemCount)) +
"[white:black:-], size: " +
color +
ui.formatSize(totalSize, false, false) +
"[white:black:-], elapsed time: " +
color +
delta.String() +
"[white:black:-]\nCurrent item: [white:black:b]" +
path.ShortenPath(currentItem, ui.currentItemNameMaxLen))
})
}(progress.ItemCount, progress.TotalSize, progress.CurrentItemName)
time.Sleep(100 * time.Millisecond)
}
}
|