aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-09-21 22:26:07 +0200
committerRobin Jarry <robin@jarry.cc>2023-09-27 21:12:03 +0200
commit01ccccbf24a8e453e036bf08b7052ac47baa1ff7 (patch)
tree7b2617e3fb62e8afe3fbff7340259efadbba97b5
parent37d5fc691aff24e5e41d5775bb6777b7cb4818c5 (diff)
downloadaerc-01ccccbf24a8e453e036bf08b7052ac47baa1ff7.tar.gz
terminal: draw even if underlying command has died
After the command running in the terminal has exited, the tcell-term buffer still contains the last status of its virtual tty. If a virtual terminal is visible, draw it even after its command has exited. Calling tcellterm.VT.Draw() does not interact with the underlying process at all, it only accesses the screen buffer. This should fix incomplete drawing of message parts when using a pager that exits after printing contents (e.g. `less -F`). Also, it should fix redrawing of such message part contents after switching tabs back and forth. Reported-by: Julio B <julio.bacel@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Julio B <julio.bacel@gmail.com>
-rw-r--r--widgets/terminal.go35
1 files changed, 11 insertions, 24 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 47bf0e7a..96919515 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -53,7 +53,7 @@ func (term *Terminal) closeErr(err error) {
if atomic.SwapInt32(&term.closed, closed) == closed {
return
}
- if term.vterm != nil && err == nil {
+ if term.vterm != nil {
// Stop receiving events
term.vterm.Detach()
term.vterm.Close()
@@ -61,9 +61,6 @@ func (term *Terminal) closeErr(err error) {
if term.OnClose != nil {
term.OnClose(err)
}
- if term.ctx != nil {
- term.ctx.HideCursor()
- }
ui.Invalidate()
}
@@ -78,13 +75,10 @@ func (term *Terminal) Invalidate() {
}
func (term *Terminal) Draw(ctx *ui.Context) {
- if term.isClosed() {
- return
- }
term.vterm.SetSurface(ctx.View())
w, h := ctx.View().Size()
- if term.ctx != nil {
+ if !term.isClosed() && term.ctx != nil {
ow, oh := term.ctx.View().Size()
if w != ow || h != oh {
term.vterm.Resize(w, h)
@@ -103,29 +97,22 @@ func (term *Terminal) Draw(ctx *ui.Context) {
term.OnStart()
}
}
- term.draw()
-}
-
-func (term *Terminal) Show(visible bool) {
- term.visible = visible
-}
-
-func (term *Terminal) draw() {
- if term.isClosed() {
- return
- }
term.vterm.Draw()
- if term.focus && term.ctx != nil {
+ if term.focus {
y, x, style, vis := term.vterm.Cursor()
- if vis {
- term.ctx.SetCursor(x, y)
- term.ctx.SetCursorStyle(style)
+ if vis && !term.isClosed() {
+ ctx.SetCursor(x, y)
+ ctx.SetCursorStyle(style)
} else {
- term.ctx.HideCursor()
+ ctx.HideCursor()
}
}
}
+func (term *Terminal) Show(visible bool) {
+ term.visible = visible
+}
+
func (term *Terminal) MouseEvent(localX int, localY int, event tcell.Event) {
ev, ok := event.(*tcell.EventMouse)
if !ok {