forked from go-telegram/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
40 lines (34 loc) · 865 Bytes
/
options.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
package progress
type Option func(p *Progress)
// WithRenderTextFunc sets the render text function.
func WithRenderTextFunc(f RenderTextFunc) Option {
return func(p *Progress) {
p.renderTextFunc = f
}
}
// StartValue sets the start value.
func StartValue(value float64) Option {
return func(p *Progress) {
p.value = value
}
}
// OnError sets the error handler.
func OnError(f OnErrorHandler) Option {
return func(p *Progress) {
p.onError = f
}
}
// WithCancel sets the cancel function.
func WithCancel(buttonText string, deleteOnCancel bool, onCancel OnCancelFunc) Option {
return func(p *Progress) {
p.deleteOnCancel = deleteOnCancel
p.cancelText = buttonText
p.onCancel = onCancel
}
}
// WithPrefix is a keyboard option that sets a prefix for the widget
func WithPrefix(s string) Option {
return func(w *Progress) {
w.prefix = s
}
}