From 6cb49ef35a2ec52d999f638ff7220cc7c9e48f5a Mon Sep 17 00:00:00 2001 From: Kim Tore Jensen Date: Sun, 24 Dec 2023 12:19:40 +0100 Subject: [PATCH] Properly draw wide characters in topbar widgets (#138) --- widgets/topbar.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widgets/topbar.go b/widgets/topbar.go index 43597ef..3695610 100644 --- a/widgets/topbar.go +++ b/widgets/topbar.go @@ -6,6 +6,7 @@ import ( "github.com/ambientsound/pms/topbar" "github.com/gdamore/tcell/v2" "github.com/gdamore/tcell/v2/views" + `github.com/mattn/go-runewidth` ) // Pieces may be aligned to left, center or right. @@ -79,7 +80,7 @@ func (w *Topbar) Draw() { func (w *Topbar) drawNext(x, y int, s string, style tcell.Style) int { for _, r := range s { w.view.SetContent(x, y, r, nil, style) - x++ + x += runewidth.RuneWidth(r) } return x }