Skip to content

Commit

Permalink
vaxis: update to v0.7.2 and update ansi parser
Browse files Browse the repository at this point in the history
Update Vaxis to v0.7.2 to gain performance improvements and StyledString
parsing. The Vaxis parser fully accounts for the terminal's capability
to display wide characters.

Use the Vaxis StyledString parser to parse and style ansi-encoded
strings. Remove unneeded code and tests.

Signed-off-by: Tim Culverhouse <[email protected]>
Acked-by: Robin Jarry <[email protected]>
  • Loading branch information
rockorager authored and rjarry committed Feb 12, 2024
1 parent 57020e9 commit 6314e2d
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 739 deletions.
26 changes: 16 additions & 10 deletions app/dirlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"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"
Expand Down Expand Up @@ -335,26 +334,33 @@ func (dirlist *DirectoryList) renderDir(
}
buf.Reset()

lbuf := parse.ParseANSI(left)
lbuf.ApplyAttrs(style)
lbuf := ui.StyledString(left)
ui.ApplyAttrs(lbuf, style)
lwidth := lbuf.Len()
rbuf := parse.ParseANSI(right)
rbuf.ApplyAttrs(style)
rbuf := ui.StyledString(right)
ui.ApplyAttrs(rbuf, style)
rwidth := rbuf.Len()

if lwidth+rwidth+1 > width {
if rwidth > 3*width/4 {
rwidth = 3 * width / 4
}
lwidth = width - rwidth - 1
right = rbuf.TruncateHead(rwidth, '…')
left = lbuf.Truncate(lwidth-1, '…')
ui.TruncateHead(rbuf, rwidth)
right = rbuf.Encode()
ui.Truncate(lbuf, lwidth)
left = lbuf.Encode()
} else {
for i := 0; i < (width - lwidth - rwidth - 1); i += 1 {
lbuf.Write(' ', vaxis.Style{})
lbuf.Cells = append(lbuf.Cells, vaxis.Cell{
Character: vaxis.Character{
Grapheme: " ",
Width: 1,
},
})
}
left = lbuf.String()
right = rbuf.String()
left = lbuf.Encode()
right = rbuf.Encode()
}

return left, right, style
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
git.sr.ht/~rjarry/go-opt v1.3.0
git.sr.ht/~rockorager/go-jmap v0.3.0
git.sr.ht/~rockorager/vaxis v0.4.7
git.sr.ht/~rockorager/vaxis v0.7.2
github.com/ProtonMail/go-crypto v0.0.0-20230417170513-8ee5748c52b5
github.com/arran4/golang-ical v0.0.0-20230318005454-19abf92700cc
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ git.sr.ht/~rjarry/go-opt v1.3.0 h1:9BLOcXi5OhDYVzH3Td48i2uM/byMGNqXY7YhBzvEZg8=
git.sr.ht/~rjarry/go-opt v1.3.0/go.mod h1:oEPZUTJKGn1FVye0znaLoeskE/QTuyoJw5q+fjusdM4=
git.sr.ht/~rockorager/go-jmap v0.3.0 h1:h2WuPcNyXRYFg9+W2HGf/mzIqC6ISy9EaS/BGa7Z5RY=
git.sr.ht/~rockorager/go-jmap v0.3.0/go.mod h1:aOTCtwpZSINpDDSOkLGpHU0Kbbm5lcSDMcobX3ZtOjY=
git.sr.ht/~rockorager/vaxis v0.4.7 h1:9VlkBBF9dxy62AMHnKAU8GqEs2/mUTlke/ZJ9o/6luk=
git.sr.ht/~rockorager/vaxis v0.4.7/go.mod h1:h94aKek3frIV1hJbdXjqnBqaLkbWXvV+UxAsQHg9bns=
git.sr.ht/~rockorager/vaxis v0.7.2 h1:w+vBMkBWiGLSMMuHwZTDBrTXrjjAoyBc3k681WBT1kU=
git.sr.ht/~rockorager/vaxis v0.7.2/go.mod h1:h94aKek3frIV1hJbdXjqnBqaLkbWXvV+UxAsQHg9bns=
github.com/ProtonMail/crypto v0.0.0-20200420072808-71bec3603bf3 h1:JW27/kGLQzeM1Fxg5YQhdkTEAU7HIAHMgSag35zVTnY=
github.com/ProtonMail/crypto v0.0.0-20200420072808-71bec3603bf3/go.mod h1:Pxr7w4gA2ikI4sWyYwEffm+oew1WAJHzG1SiDpQMkrI=
github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
Expand Down
Loading

0 comments on commit 6314e2d

Please sign in to comment.