summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-10-19 12:27:03 -0500
committerRobin Jarry <robin@jarry.cc>2022-10-19 21:01:55 +0200
commit847c1cd3c345a6a42cc9f7e8bef90388976e4210 (patch)
tree71b2189b2fc97b883fe8488856ab444fcc6d2edb
parentc3bb3aa2a8908eaeb201a740fb12d70968cc3bac (diff)
downloadaerc-847c1cd3c345a6a42cc9f7e8bef90388976e4210.tar.gz
aerc-847c1cd3c345a6a42cc9f7e8bef90388976e4210.zip
terminal: properly handle cursor display
The terminal widget reports if the cursor should be displayed. Properly handle this output to report cursor display back to aerc. Reported-by: staceee Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--widgets/terminal.go28
1 files changed, 13 insertions, 15 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index e0a76ca8..691b1b45 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -13,14 +13,13 @@ import (
)
type Terminal struct {
- closed bool
- cmd *exec.Cmd
- ctx *ui.Context
- cursorShown bool
- destroyed bool
- focus bool
- vterm *tcellterm.Terminal
- running bool
+ closed bool
+ cmd *exec.Cmd
+ ctx *ui.Context
+ destroyed bool
+ focus bool
+ vterm *tcellterm.Terminal
+ running bool
OnClose func(err error)
OnEvent func(event tcell.Event) bool
@@ -30,10 +29,9 @@ type Terminal struct {
func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
term := &Terminal{
- cursorShown: true,
+ cmd: cmd,
+ vterm: tcellterm.New(),
}
- term.cmd = cmd
- term.vterm = tcellterm.New()
return term, nil
}
@@ -98,12 +96,12 @@ func (term *Terminal) Draw(ctx *ui.Context) {
func (term *Terminal) draw() {
term.vterm.Draw()
if term.focus && !term.closed && term.ctx != nil {
- if !term.cursorShown {
- term.ctx.HideCursor()
- } else {
- _, x, y, style := term.vterm.GetCursor()
+ vis, x, y, style := term.vterm.GetCursor()
+ if vis {
term.ctx.SetCursor(x, y)
term.ctx.SetCursorStyle(style)
+ } else {
+ term.ctx.HideCursor()
}
}
}