aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/terminal.go61
-rw-r--r--go.mod2
-rw-r--r--go.sum5
-rw-r--r--lib/ui/context.go14
-rw-r--r--lib/ui/ui.go1
5 files changed, 22 insertions, 61 deletions
diff --git a/app/terminal.go b/app/terminal.go
index 97cd4410..c4ec374e 100644
--- a/app/terminal.go
+++ b/app/terminal.go
@@ -7,8 +7,8 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
- tcellterm "git.sr.ht/~rockorager/tcell-term"
"git.sr.ht/~rockorager/vaxis"
+ "git.sr.ht/~rockorager/vaxis/widgets/term"
"github.com/gdamore/tcell/v2"
)
@@ -23,7 +23,7 @@ type Terminal struct {
ctx *ui.Context
focus bool
visible bool
- vterm *tcellterm.VT
+ vterm *term.Model
running bool
OnClose func(err error)
@@ -35,7 +35,7 @@ type Terminal struct {
func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
term := &Terminal{
cmd: cmd,
- vterm: tcellterm.New(),
+ vterm: term.New(),
visible: true,
}
term.vterm.OSC8 = config.General.EnableOSC8
@@ -83,15 +83,6 @@ func (term *Terminal) Invalidate() {
}
func (term *Terminal) Draw(ctx *ui.Context) {
- term.vterm.SetSurface(ctx)
-
- w, h := ctx.Size()
- if !term.isClosed() && term.ctx != nil {
- ow, oh := term.ctx.Size()
- if w != ow || h != oh {
- term.vterm.Resize(w, h)
- }
- }
term.ctx = ctx
if !term.running && term.cmd != nil {
term.vterm.Attach(term.HandleEvent)
@@ -105,15 +96,7 @@ func (term *Terminal) Draw(ctx *ui.Context) {
term.OnStart()
}
}
- term.vterm.Draw()
- if term.focus {
- y, x, style, vis := term.vterm.Cursor()
- if vis && !term.isClosed() {
- ctx.SetCursor(x, y, vaxis.CursorStyle(style))
- } else {
- ctx.HideCursor()
- }
- }
+ term.vterm.Draw(ctx.Window())
}
func (term *Terminal) Show(visible bool) {
@@ -136,7 +119,7 @@ func (term *Terminal) MouseEvent(localX int, localY int, event vaxis.Event) {
return
}
e := tcell.NewEventMouse(localX, localY, ev.Buttons(), ev.Modifiers())
- term.vterm.HandleEvent(e)
+ term.vterm.Update(e)
}
func (term *Terminal) Focus(focus bool) {
@@ -144,39 +127,34 @@ func (term *Terminal) Focus(focus bool) {
return
}
term.focus = focus
- if term.ctx != nil {
- if !term.focus {
- term.ctx.HideCursor()
- } else {
- y, x, style, _ := term.vterm.Cursor()
- term.ctx.SetCursor(x, y, vaxis.CursorStyle(style))
- term.Invalidate()
- }
+ if term.focus {
+ term.vterm.Focus()
+ } else {
+ term.vterm.Blur()
}
}
// HandleEvent is used to watch the underlying terminal events
-func (term *Terminal) HandleEvent(ev tcell.Event) {
- if term.isClosed() {
+func (t *Terminal) HandleEvent(ev vaxis.Event) {
+ if t.isClosed() {
return
}
switch ev := ev.(type) {
- case *tcellterm.EventRedraw:
- if term.visible {
+ case vaxis.Redraw:
+ if t.visible {
ui.Invalidate()
}
- case *tcellterm.EventTitle:
- if term.OnTitle != nil {
- term.OnTitle(ev.Title())
+ case term.EventTitle:
+ if t.OnTitle != nil {
+ t.OnTitle(string(ev))
}
- case *tcellterm.EventClosed:
- term.Close()
+ case term.EventClosed:
+ t.Close()
ui.Invalidate()
}
}
func (term *Terminal) Event(event vaxis.Event) bool {
- event = tcell.TcellEvent(event)
if term.OnEvent != nil {
if term.OnEvent(event) {
return true
@@ -185,5 +163,6 @@ func (term *Terminal) Event(event vaxis.Event) bool {
if term.isClosed() {
return false
}
- return term.vterm.HandleEvent(event)
+ term.vterm.Update(event)
+ return true
}
diff --git a/go.mod b/go.mod
index fa05f0dd..d4cefd0c 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,6 @@ 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/tcell-term v0.10.0
git.sr.ht/~rockorager/vaxis v0.4.7
github.com/ProtonMail/go-crypto v0.0.0-20230417170513-8ee5748c52b5
github.com/arran4/golang-ical v0.0.0-20230318005454-19abf92700cc
@@ -59,6 +58,7 @@ require (
golang.org/x/text v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
+ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/go.sum b/go.sum
index baaea7b7..0460a838 100644
--- a/go.sum
+++ b/go.sum
@@ -2,8 +2,6 @@ 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/tcell-term v0.10.0 h1:BqxJjtCMmLIfS6fdIal8TSiH3qPiYTjATuIRIWNVPbo=
-git.sr.ht/~rockorager/tcell-term v0.10.0/go.mod h1:Snxh5CrziiA2CjyLOZ6tGAg5vMPlE+REMWT3rtKuyyQ=
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-tcell v0.4.7 h1:ISMSnvbz1jnG9Ppi9y3NJKaLl7Nu67qMkpEXbXwHgmg=
@@ -24,7 +22,6 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
-github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
@@ -149,7 +146,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
@@ -201,7 +197,6 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
diff --git a/lib/ui/context.go b/lib/ui/context.go
index 69361120..2ca0d310 100644
--- a/lib/ui/context.go
+++ b/lib/ui/context.go
@@ -5,7 +5,6 @@ import (
"git.sr.ht/~rjarry/aerc/lib/parse"
"git.sr.ht/~rockorager/vaxis"
- "github.com/gdamore/tcell/v2"
)
// A context allows you to draw in a sub-region of the terminal
@@ -136,19 +135,6 @@ func (ctx *Context) Popover(x, y, width, height int, d Drawable) {
})
}
-// SetContent is used to update the content of the Surface at the given
-// location.
-func (ctx *Context) SetContent(x int, y int, ch rune, comb []rune, style tcell.Style) {
- g := []rune{ch}
- g = append(g, comb...)
- ctx.window.SetCell(x, y, vaxis.Cell{
- Character: vaxis.Character{
- Grapheme: string(g),
- },
- Style: tcell.VaxisStyle(style),
- })
-}
-
func (ctx *Context) Size() (int, int) {
return ctx.window.Size()
}
diff --git a/lib/ui/ui.go b/lib/ui/ui.go
index 84c34459..a7233f49 100644
--- a/lib/ui/ui.go
+++ b/lib/ui/ui.go
@@ -125,6 +125,7 @@ func Render() {
state.vx.Window().Clear()
// reset popover for the next Draw
state.popover = nil
+ state.vx.HideCursor()
state.content.Draw(state.ctx)
if state.popover != nil {
// if the Draw resulted in a popover, draw it