Codebase list golang-github-vbauerster-mpb / 784b900
meaningful vars Vladimir Bauer 6 years ago
1 changed file(s) with 8 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
127127 // FormatMsg formats final message according to WC.W and WC.C.
128128 // Should be called by any Decorator implementation.
129129 func (wc *WC) FormatMsg(msg string) string {
130 max := utf8.RuneCountInString(stripansi.Strip(msg))
130 var format string
131 runeCount := utf8.RuneCountInString(stripansi.Strip(msg))
132 ansiCount := utf8.RuneCountInString(msg) - runeCount
131133 if (wc.C & DSyncWidth) != 0 {
132 wc.wsync <- max
133 max = (utf8.RuneCountInString(msg) - max) + <-wc.wsync
134 wc.wsync <- runeCount
135 max := <-wc.wsync
134136 if (wc.C & DextraSpace) != 0 {
135137 max++
136138 }
139 format = fmt.Sprintf(wc.dynFormat, ansiCount+max)
137140 } else {
138 max = (utf8.RuneCountInString(msg) - max) + wc.W
141 format = fmt.Sprintf(wc.dynFormat, ansiCount+wc.W)
139142 }
140 return fmt.Sprintf(fmt.Sprintf(wc.dynFormat, max), msg)
143 return fmt.Sprintf(format, msg)
141144 }
142145
143146 // Init initializes width related config.