Strip dot when width is not enough to display
This commit is contained in:
parent
66f1319170
commit
150c0ce27e
10
helper.go
10
helper.go
@ -25,6 +25,11 @@ const (
|
||||
AttrReverse
|
||||
)
|
||||
|
||||
var (
|
||||
dot = "…"
|
||||
dotw = rw.StringWidth(dot)
|
||||
)
|
||||
|
||||
/* ----------------------- End ----------------------------- */
|
||||
|
||||
func toTmAttr(x Attribute) tm.Attribute {
|
||||
@ -39,5 +44,10 @@ func trimStr2Runes(s string, w int) []rune {
|
||||
if w <= 0 {
|
||||
return []rune{}
|
||||
}
|
||||
sw := rw.StringWidth(s)
|
||||
if sw+dotw >= w {
|
||||
return []rune(rw.Truncate(s, w, ""))
|
||||
} else {
|
||||
return []rune(rw.Truncate(s, w, "…"))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user