diff --git a/_examples/suppressBar/go.mod b/_examples/suppressBar/go.mod index 705650d..c4d638a 100644 --- a/_examples/suppressBar/go.mod +++ b/_examples/suppressBar/go.mod @@ -2,4 +2,7 @@ go 1.14 -require github.com/vbauerster/mpb/v5 v5.1.0 +require ( + github.com/mattn/go-runewidth v0.0.9 + github.com/vbauerster/mpb/v5 v5.1.0 +) diff --git a/_examples/suppressBar/main.go b/_examples/suppressBar/main.go index 5dffa06..f0026e3 100644 --- a/_examples/suppressBar/main.go +++ b/_examples/suppressBar/main.go @@ -8,6 +8,7 @@ "sync" "time" + "github.com/mattn/go-runewidth" "github.com/vbauerster/mpb/v5" "github.com/vbauerster/mpb/v5/decor" ) @@ -34,8 +35,7 @@ default: } if msg != nil { - limitFmt := fmt.Sprintf("%%.%ds", st.AvailableWidth) - fmt.Fprintf(w, limitFmt, *msg) + io.WriteString(w, runewidth.Truncate(*msg, st.AvailableWidth, "…")) nextCh <- struct{}{} } else { base.Fill(w, reqWidth, st)