truncate bar if double width style used
Vladimir Bauer
6 years ago
| 0 | 0 | package mpb |
| 1 | 1 | |
| 2 | 2 | import ( |
| 3 | "bytes" | |
| 3 | 4 | "io" |
| 4 | 5 | "unicode/utf8" |
| 5 | 6 | |
| 151 | 152 | index++ |
| 152 | 153 | } |
| 153 | 154 | |
| 155 | if index != len(bb) { | |
| 156 | buf := new(bytes.Buffer) | |
| 157 | s.flush(buf, space, bb[:index]) | |
| 158 | io.WriteString(w, runewidth.Truncate(buf.String(), width, "!")) | |
| 159 | return | |
| 160 | } | |
| 161 | ||
| 154 | 162 | s.flush(w, space, bb) |
| 155 | 163 | } |
| 156 | 164 | |