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

Colors change when creating a new screen #397

Closed
Bios-Marcel opened this issue Oct 17, 2020 · 4 comments
Closed

Colors change when creating a new screen #397

Bios-Marcel opened this issue Oct 17, 2020 · 4 comments
Labels

Comments

@Bios-Marcel
Copy link
Contributor

Hey,

so I've found a very weird behaviour when creating a new screen. Seemingly, the initially created screen honours the terminal colours, while the second screen doesn't. I've written a little demo to show this:

package main

import "github.com/gdamore/tcell"

var style = tcell.StyleDefault.Background(tcell.ColorBlack).Foreground(tcell.ColorRed)

func main() {
	screenShow()
}

func screenShow() {
	screenA, err := tcell.NewScreen()
	if err != nil {
		panic(err)
	}
	err = screenA.Init()
	if err != nil {
		panic(err)
	}

	screenA.Fill('A', style)
	screenA.Show()

	//Wait one event
LOOP:
	for {

		switch event := screenA.PollEvent().(type) {
		case *tcell.EventKey:
			if event.Key() == tcell.KeyESC || event.Key() == tcell.KeyCtrlC {
				break LOOP
			}
			if event.Key() == tcell.KeyEnter {
				screenA.Fini()
				screenShow()
			}
		default:
			continue
		}
	}

	screenA.Fini()
}

Simply run it an hit enter. I am currently running termite, in case that matters.

Here's a gif, in case it doesn't work for you:

record

@gdamore
Copy link
Owner

gdamore commented Oct 17, 2020

Yeah I think recalling Init and Fini is problematic. These were never designed for this kind of usage. I will need to investigate making this more robust.

@Bios-Marcel
Copy link
Contributor Author

Yeah, the easy way to workaround this, is trying to reuse screen I guess, but I thought I'd report this either way. Maybe something that can be fixed at some point in v2 🤷 It's not really that problematic.

@gdamore
Copy link
Owner

gdamore commented Feb 20, 2021

Please see master, which now has Suspend() and Resume() APIs. Hopefully that will be superior to using Init and Fini for this purpose.

@gdamore
Copy link
Owner

gdamore commented May 16, 2021

I'm going to close this now.

@gdamore gdamore closed this as completed May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants