Codebase list golang-github-vbauerster-mpb / 3cbe3df
BarWidth Vladimir Bauer 7 years ago
1 changed file(s) with 24 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
4646 }
4747 }
4848
49 // BarWidth sets bar width independent of the container.
50 func BarWidth(width int) BarOption {
51 return func(s *bState) {
52 s.width = width
53 }
54 }
55
4956 // BarRemoveOnComplete is a flag, if set whole bar line will be removed
50 // on complete event. If both BarRemoveOnComplete and BarClearOnComplete
57 // on complete event. If both BarRemoveOnComplete and BarClearOnComplete
5158 // are set, first bar section gets cleared and then whole bar line
5259 // gets removed completely.
5360 func BarRemoveOnComplete() BarOption {
5764 }
5865
5966 // BarReplaceOnComplete is indicator for delayed bar start, after the
60 // `runningBar` is complete. To achieve bar replacement effect,
67 // `runningBar` is complete. To achieve bar replacement effect,
6168 // `runningBar` should has its `BarRemoveOnComplete` option set.
6269 func BarReplaceOnComplete(runningBar *Bar) BarOption {
6370 return func(s *bState) {
6673 }
6774
6875 // BarClearOnComplete is a flag, if set will clear bar section on
69 // complete event. If you need to remove a whole bar line, refer to
76 // complete event. If you need to remove a whole bar line, refer to
7077 // BarRemoveOnComplete.
7178 func BarClearOnComplete() BarOption {
7279 return func(s *bState) {
7481 }
7582 }
7683
77 // BarPriority sets bar's priority.
78 // Zero is highest priority, i.e. bar will be on top. If
79 // `BarReplaceOnComplete` option is supplied, this option is ignored.
84 // BarPriority sets bar's priority. Zero is highest priority, i.e. bar
85 // will be on top. If `BarReplaceOnComplete` option is supplied, this
86 // option is ignored.
8087 func BarPriority(priority int) BarOption {
8188 return func(s *bState) {
8289 s.priority = priority
8491 }
8592
8693 // BarNewLineExtend takes user defined efn, which gets called each
87 // render cycle. Any write to provided writer of efn, will appear on
94 // render cycle. Any write to provided writer of efn, will appear on
8895 // new line of respective bar.
8996 func BarNewLineExtend(efn func(io.Writer, *decor.Statistics)) BarOption {
9097 return func(s *bState) {
140147 }
141148
142149 // MakeFillerTypeSpecificBarOption makes BarOption specific to Filler's
143 // actual type. If you implement your own Filler, so most probably
144 // you'll need this. See BarStyle or SpinnerStyle for example.
150 // actual type. If you implement your own Filler, so most probably
151 // you'll need this. See BarStyle or SpinnerStyle for example.
145152 func MakeFillerTypeSpecificBarOption(
146153 typeChecker func(Filler) (interface{}, bool),
147154 cb func(interface{}),
152159 }
153160 }
154161 }
162
163 // OptionOnCondition returns option when condition evaluates to true.
164 func OptionOnCondition(option BarOption, condition func() bool) BarOption {
165 if condition() {
166 return option
167 }
168 return nil
169 }