Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspending and coming back to previous screen #624

Closed
ankitpokhrel opened this issue Jun 28, 2021 · 5 comments
Closed

Suspending and coming back to previous screen #624

ankitpokhrel opened this issue Jun 28, 2021 · 5 comments

Comments

@ankitpokhrel
Copy link

Suspending and coming back to previous screen seems broken since recent update.

Given a simple program that launches vim and goes back to previous screen after exit.

package main

import (
	"os"
	"os/exec"

	"github.com/gdamore/tcell/v2"
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	form := tview.NewForm()

	form.SetInputCapture(func(ev *tcell.EventKey) *tcell.EventKey {
		if ev.Key() == tcell.KeyRune {
			if ev.Rune() == 'q' {
				app.Stop()
				os.Exit(0)
			}
		}
		return ev
	})

	form.AddButton("Edit with vim", func() {
		app.Suspend(func() {
			cmd := exec.Command("vim", "/tmp/foo")
			cmd.Stdout = os.Stdout
			cmd.Stdin = os.Stdin
			_ = cmd.Run()
		})
	})

	form.SetBorder(true).SetTitle("Launch vim & go back to main screen after exit, Press 'q' to exit")

	if err := app.SetRoot(form, true).SetFocus(form).Run(); err != nil {
		panic(err)
	}
}

The code above worked as expected before but panics since 36f5c19.

panic: EOF

goroutine 1 [running]:
main.main()
	/go/src/tview-dbg/broken/main.go:37 +0x3b7
exit status 2

The cause of the issue can be traced back to this particular change where we are stopping the app app.Stop when handling tcell.EventError in an event loop.

tview/application.go

Lines 373 to 375 in 29d673a

case *tcell.EventError:
appErr = event
a.Stop()

Is there anything I am missing?

@darkhz
Copy link

darkhz commented Aug 5, 2021

It's broken for me too. Panics with:
panic: read /dev/tty: i/o timeout

@rivo
Copy link
Owner

rivo commented Aug 22, 2021

This appears to be a problem with tcell. I opened an issue there: gdamore/tcell/issues/480

@rivo
Copy link
Owner

rivo commented Sep 4, 2021

@ankitpokhrel & @darkhz Can you please try this with the latest tcell commit and let me know if it works for you?

@darkhz
Copy link

darkhz commented Sep 4, 2021

@rivo Yes, it works well with the commit in the fix480 branch. Thank you very much.

@rivo rivo closed this as completed in 2f13f81 Sep 4, 2021
@ankitpokhrel
Copy link
Author

@rivo works fine for me too with latest tcell commit. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants