aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2023-10-26 12:09:12 -0500
committerRobin Jarry <robin@jarry.cc>2023-10-30 23:24:43 +0100
commit9a429365419991dee4fa474dd992ce35a69cc4b4 (patch)
tree469d0080f44e30549cff1c1ff32744924b36d059
parent9a071ba3532bc4c4b530ac145a2b7916d9baf23f (diff)
downloadaerc-9a429365419991dee4fa474dd992ce35a69cc4b4.tar.gz
aerc-9a429365419991dee4fa474dd992ce35a69cc4b4.zip
ui: create and expose vaxis Window with Context
Create and expose a vaxis.Window object with each Context. vaxis.Windows are used for creating local coordinates (similar to the views.View API that tcell provides). Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--go.mod2
-rw-r--r--lib/ui/context.go13
2 files changed, 12 insertions, 3 deletions
diff --git a/go.mod b/go.mod
index 43945dfb..2803868a 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ require (
git.sr.ht/~rjarry/go-opt v1.2.0
git.sr.ht/~rockorager/go-jmap v0.3.0
git.sr.ht/~rockorager/tcell-term v0.8.0
+ git.sr.ht/~rockorager/vaxis v0.2.5
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
@@ -38,7 +39,6 @@ require (
)
require (
- git.sr.ht/~rockorager/vaxis v0.2.5 // indirect
github.com/cloudflare/circl v1.3.2 // indirect
github.com/creack/pty v1.1.18 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
diff --git a/lib/ui/context.go b/lib/ui/context.go
index 9ca7cc9d..39933fa3 100644
--- a/lib/ui/context.go
+++ b/lib/ui/context.go
@@ -4,6 +4,7 @@ import (
"fmt"
"git.sr.ht/~rjarry/aerc/lib/parse"
+ "git.sr.ht/~rockorager/vaxis"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v2/views"
)
@@ -12,6 +13,7 @@ import (
type Context struct {
screen tcell.Screen
viewport *views.ViewPort
+ window vaxis.Window
x, y int
onPopover func(*Popover)
}
@@ -36,9 +38,15 @@ func (ctx *Context) Height() int {
return height
}
+// returns the vaxis Window for this context
+func (ctx *Context) Window() vaxis.Window {
+ return ctx.window
+}
+
func NewContext(width, height int, screen tcell.Screen, p func(*Popover)) *Context {
vp := views.NewViewPort(screen, 0, 0, width, height)
- return &Context{screen, vp, 0, 0, p}
+ win := screen.Vaxis().Window()
+ return &Context{screen, vp, win, 0, 0, p}
}
func (ctx *Context) Subcontext(x, y, width, height int) *Context {
@@ -50,7 +58,8 @@ func (ctx *Context) Subcontext(x, y, width, height int) *Context {
panic(fmt.Errorf("Attempted to create context larger than parent"))
}
vp := views.NewViewPort(ctx.viewport, x, y, width, height)
- return &Context{ctx.screen, vp, ctx.x + x, ctx.y + y, ctx.onPopover}
+ win := ctx.window.New(x, y, width, height)
+ return &Context{ctx.screen, vp, win, ctx.x + x, ctx.y + y, ctx.onPopover}
}
func (ctx *Context) SetCell(x, y int, ch rune, style tcell.Style) {