diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2024-02-12 06:26:13 -0600 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-02-12 13:47:18 +0100 |
commit | 0ef4717b2a0fad1ee0a6426efa77325affaf566b (patch) | |
tree | 64b665be71bbb8a43ab62b48a4bfbbcfc15f31c6 | |
parent | 6eff242090dc75d2cc466b023bcbebd78d3d47cb (diff) | |
download | aerc-0ef4717b2a0fad1ee0a6426efa77325affaf566b.tar.gz |
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-- | lib/ui/context.go | 13 |
1 files changed, 11 insertions, 2 deletions
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) { |