~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH aerc] terminal: draw even if underlying command has died

Details
Message ID
<20230924205247.712448-2-robin@jarry.cc>
DKIM signature
missing
Download raw message
Patch: +12 -25
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>
---
 widgets/terminal.go | 37 ++++++++++++-------------------------
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/widgets/terminal.go b/widgets/terminal.go
index 47bf0e7a83e5..969195151471 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()
	term.vterm.Draw()
	if term.focus {
		y, x, style, vis := term.vterm.Cursor()
		if vis && !term.isClosed() {
			ctx.SetCursor(x, y)
			ctx.SetCursorStyle(style)
		} else {
			ctx.HideCursor()
		}
	}
}

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 {
		y, x, style, vis := term.vterm.Cursor()
		if vis {
			term.ctx.SetCursor(x, y)
			term.ctx.SetCursorStyle(style)
		} else {
			term.ctx.HideCursor()
		}
	}
}

func (term *Terminal) MouseEvent(localX int, localY int, event tcell.Event) {
	ev, ok := event.(*tcell.EventMouse)
	if !ok {
-- 
2.41.0

[aerc/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CVRG66X2KMW2.12KN6TO876UT@cirno2>
In-Reply-To
<20230924205247.712448-2-robin@jarry.cc> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: SUCCESS in 4m51s

[terminal: draw even if underlying command has died][0] from [Robin Jarry][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/44995
[1]: robin@jarry.cc

✓ #1062500 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/1062500
✓ #1062499 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/1062499
Details
Message ID
<CVRGW7RLMJPW.3KSUUWJFUC403@gmail.com>
In-Reply-To
<20230924205247.712448-2-robin@jarry.cc> (view parent)
DKIM signature
missing
Download raw message
Thank you so much for fixing this! I can confirm that it is working
without problems.

Tested-by: Julio B <julio.bacel@gmail.com>
Details
Message ID
<CVTZW7VUETPV.1HTMHQLFEN3BD@ringo>
In-Reply-To
<CVRGW7RLMJPW.3KSUUWJFUC403@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Julio B, Sep 24, 2023 at 23:39:
> Thank you so much for fixing this! I can confirm that it is working
> without problems.
>
> Tested-by: Julio B <julio.bacel@gmail.com>

Applied. Thanks!
Reply to thread Export thread (mbox)