aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/dirlist.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/dirlist.go')
-rw-r--r--widgets/dirlist.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 1e1a8a61..986bd662 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -10,11 +10,10 @@ import (
"time"
"github.com/gdamore/tcell/v2"
- "github.com/mattn/go-runewidth"
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
- "git.sr.ht/~rjarry/aerc/lib/format"
+ "git.sr.ht/~rjarry/aerc/lib/parse"
"git.sr.ht/~rjarry/aerc/lib/state"
"git.sr.ht/~rjarry/aerc/lib/templates"
"git.sr.ht/~rjarry/aerc/lib/ui"
@@ -299,20 +298,26 @@ func (dirlist *DirectoryList) renderDir(
}
buf.Reset()
- lwidth := runewidth.StringWidth(left)
- rwidth := runewidth.StringWidth(right)
+ lbuf := parse.ParseANSI(left)
+ lbuf.ApplyAttrs(style)
+ lwidth := lbuf.Len()
+ rbuf := parse.ParseANSI(right)
+ rbuf.ApplyAttrs(style)
+ rwidth := rbuf.Len()
if lwidth+rwidth+1 > width {
if rwidth > 3*width/4 {
rwidth = 3 * width / 4
}
lwidth = width - rwidth - 1
- right = runewidth.FillLeft(right, rwidth)
- right = format.TruncateHead(right, rwidth, "…")
- left = runewidth.FillRight(left, lwidth)
- left = runewidth.Truncate(left, lwidth, "…")
+ right = rbuf.TruncateHead(rwidth, '…')
+ left = lbuf.Truncate(lwidth-1, '…')
} else {
- left = runewidth.FillRight(left, width-rwidth-1)
+ for i := 0; i < (width - lwidth - rwidth - 1); i += 1 {
+ lbuf.Write(' ', tcell.StyleDefault)
+ }
+ left = lbuf.String()
+ right = rbuf.String()
}
return left, right, style