aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ui/context.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2024-02-12 06:26:27 -0600
committerRobin Jarry <robin@jarry.cc>2024-02-12 13:49:14 +0100
commit6314e2dc67418141b12081bde846091e5e160702 (patch)
treef21798e32c9d43a9d7fc4d08b5f80c1da0ca9848 /lib/ui/context.go
parent57020e98b9ca22eaf2be73722abb79547674cd67 (diff)
downloadaerc-6314e2dc67418141b12081bde846091e5e160702.tar.gz
vaxis: update to v0.7.2 and update ansi parser
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 <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/ui/context.go')
-rw-r--r--lib/ui/context.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/ui/context.go b/lib/ui/context.go
index 2ca0d310..8544abdb 100644
--- a/lib/ui/context.go
+++ b/lib/ui/context.go
@@ -3,7 +3,6 @@ package ui
import (
"fmt"
- "git.sr.ht/~rjarry/aerc/lib/parse"
"git.sr.ht/~rockorager/vaxis"
)
@@ -68,8 +67,8 @@ func (ctx *Context) Printf(x, y int, style vaxis.Style,
str := fmt.Sprintf(format, a...)
- buf := parse.ParseANSI(str)
- buf.ApplyStyle(style)
+ buf := StyledString(str)
+ ApplyAttrs(buf, style)
old_x := x
@@ -78,22 +77,16 @@ func (ctx *Context) Printf(x, y int, style vaxis.Style,
y++
return y < height
}
- for _, sr := range buf.Runes() {
- switch sr.Value {
- case '\n':
+ for _, sr := range buf.Cells {
+ switch sr.Grapheme {
+ case "\n":
if !newline() {
return buf.Len()
}
- case '\r':
+ case "\r":
x = old_x
default:
- ctx.window.SetCell(x, y, vaxis.Cell{
- Character: vaxis.Character{
- Grapheme: string(sr.Value),
- Width: sr.Width,
- },
- Style: sr.Style,
- })
+ ctx.window.SetCell(x, y, sr)
x += sr.Width
if x == old_x+width {
if !newline() {