use go-runewidth
Vladimir Bauer
6 years ago
| 1 | 1 |
|
| 2 | 2 |
go 1.14
|
| 3 | 3 |
|
| 4 | |
require github.com/vbauerster/mpb/v5 v5.1.0
|
|
4 |
require (
|
|
5 |
github.com/mattn/go-runewidth v0.0.9
|
|
6 |
github.com/vbauerster/mpb/v5 v5.1.0
|
|
7 |
)
|
| 7 | 7 |
"sync"
|
| 8 | 8 |
"time"
|
| 9 | 9 |
|
|
10 |
"github.com/mattn/go-runewidth"
|
| 10 | 11 |
"github.com/vbauerster/mpb/v5"
|
| 11 | 12 |
"github.com/vbauerster/mpb/v5/decor"
|
| 12 | 13 |
)
|
|
| 33 | 34 |
default:
|
| 34 | 35 |
}
|
| 35 | 36 |
if msg != nil {
|
| 36 | |
limitFmt := fmt.Sprintf("%%.%ds", st.AvailableWidth)
|
| 37 | |
fmt.Fprintf(w, limitFmt, *msg)
|
|
37 |
io.WriteString(w, runewidth.Truncate(*msg, st.AvailableWidth, "…"))
|
| 38 | 38 |
nextCh <- struct{}{}
|
| 39 | 39 |
} else {
|
| 40 | 40 |
base.Fill(w, reqWidth, st)
|