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

Troubles printing a shell to a view #190

Open
bLuka opened this issue Feb 17, 2019 · 4 comments
Open

Troubles printing a shell to a view #190

bLuka opened this issue Feb 17, 2019 · 4 comments

Comments

@bLuka
Copy link

bLuka commented Feb 17, 2019

Hello,

I'm having troubles trying to run a shell inside a view.

I'm going through a pseudo-terminal (currently using kr/pty's module here: https://github.com/kr/pty).

I had an issue passing my view as the dest of my io.Copy, having the pseudo-terminal as source. I needed to rewrite io.Copy using Gui.Update on each write.

Next, I am able to print the prompt, but unable to print any other following output (like commands I'd type). It seems fmt.Fprint doesn't like forwarding my pseudo-terminal output to my view.

Everything works absolutely fine when I replace the io.Writer of my view by os.Stdout.

Would gocui be able to handle this use case?

@jesseduffield
Copy link

I too am encountering this exact same issue. Would be happy to put up a PR if somebody can point me in the right direction

@diegoacuna
Copy link

@bLuka were you able to find a workaround for this issue? thanks!

@bLuka
Copy link
Author

bLuka commented Jun 27, 2019

@diegoacuna Unfortunately I didn't found any workaround.
After some reflexion, it seems the best solution is to write another package from scratch from the ncurses library handling this scenario.

I dug a bit into the sources in a couple of hours, in order to understand the matter, but found nothing accurate.

@jroimartin Any idea? I'd still be happy to have this issue fixed :-)

@kfranqueiro
Copy link

kfranqueiro commented Dec 2, 2020

IIUC, the main loop only responds to termbox and user events. gocui.View's Write method marks the view as dirty, but won't cause a render cycle, whereas if you e.g. have key handlers hooked up, pressing a key does cause a render cycle and you'll see the output update at that time.

Would it be reasonable to have Write also cause a render cycle (or have an option for it to do so)?

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

4 participants