mirror of https://github.com/mum4k/termdash.git
Make axes labels length finder compatible with unicode runes
Signed-off-by: Xabier Larrakoetxea <slok69@gmail.com>
This commit is contained in:
parent
c1bf776dba
commit
36f116d9fc
|
@ -18,6 +18,8 @@ package axes
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
|
"github.com/mum4k/termdash/internal/runewidth"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -128,7 +130,7 @@ func NewYDetails(cvsAr image.Rectangle, yp *YProperties) (*YDetails, error) {
|
||||||
func longestLabel(labels []*Label) int {
|
func longestLabel(labels []*Label) int {
|
||||||
var widest int
|
var widest int
|
||||||
for _, label := range labels {
|
for _, label := range labels {
|
||||||
if l := len(label.Value.Text()); l > widest {
|
if l := runewidth.StringWidth(label.Value.Text()); l > widest {
|
||||||
widest = l
|
widest = l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue