Codebase list golang-github-vbauerster-mpb / 35821d0
Better doc for Merge wrapper Vladimir Bauer 6 years ago
1 changed file(s) with 9 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
44 "unicode/utf8"
55 )
66
7 // Merge helper func, provides a way to synchronize width of single
8 // decorator with adjacent decorators of different bar, like so:
9 // +--------+---------+
10 // | MERGE(D) |
11 // +--------+---------+
12 // | D1 | D2 |
13 // +--------+---------+
7 // Merge wraps its decorator argument with intention to sync width
8 // with several decorators of another bar. Visual example:
9 //
10 // +----+--------+---------+--------+
11 // | B1 | MERGE(D, P1, Pn) |
12 // +----+--------+---------+--------+
13 // | B2 | D0 | D1 | Dn |
14 // +----+--------+---------+--------+
1415 //
1516 func Merge(decorator Decorator, placeholders ...WC) Decorator {
1617 if _, ok := decorator.Sync(); !ok || len(placeholders) == 0 {
3738 placeHolders []*placeHolderDecorator
3839 }
3940
40 func (d *mergeDecorator) CompoundDecorators() []Decorator {
41 func (d *mergeDecorator) MergeUnwrap() []Decorator {
4142 decorators := make([]Decorator, len(d.placeHolders)+1)
4243 decorators[0] = d.Decorator
4344 for i, ph := range d.placeHolders {