-
Notifications
You must be signed in to change notification settings - Fork 1
/
frame.go
53 lines (47 loc) · 1.11 KB
/
frame.go
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 gogress
import "github.com/snakeice/gogress/format"
type FrameContext struct {
bar *Progress
Current int64
Max int64
Width int
elementNo int
usedWidth int
frameNo int64
MessagePrefix string
IsFinish bool
recalc []Decorator
}
func (f *FrameContext) Format() *format.ProgressFormat {
return &f.bar.Format
}
func (f *FrameContext) FrameNo() int64 {
return f.frameNo
}
func NewFrame(bar *Progress, current, max int64, width int, frameNo int64) *FrameContext {
return &FrameContext{
bar: bar,
Current: current,
Max: max,
Width: width,
elementNo: 0,
usedWidth: 0,
frameNo: frameNo,
MessagePrefix: bar.messagePrefix,
IsFinish: bar.isFinish,
recalc: []Decorator{},
}
}
func (f *FrameContext) Copy() *FrameContext {
return &FrameContext{
bar: f.bar,
Current: f.Current,
Max: f.Max,
Width: f.Width,
elementNo: 0,
frameNo: f.FrameNo(),
usedWidth: 0,
MessagePrefix: f.MessagePrefix,
IsFinish: f.IsFinish,
}
}