Strip dot when width is not enough to display

This commit is contained in:
Yasuhiro Matsumoto 2015-03-12 16:57:14 +09:00
parent 66f1319170
commit 150c0ce27e

View File

@ -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{}
}
return []rune(rw.Truncate(s, w, "…"))
sw := rw.StringWidth(s)
if sw+dotw >= w {
return []rune(rw.Truncate(s, w, ""))
} else {
return []rune(rw.Truncate(s, w, "…"))
}
}