gocui icon indicating copy to clipboard operation
gocui copied to clipboard

Troubles printing a shell to a view

Open bLuka opened this issue 6 years ago • 4 comments

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?

bLuka avatar Feb 17 '19 18:02 bLuka

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

jesseduffield avatar May 19 '19 03:05 jesseduffield

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

diegoacuna avatar Jun 27 '19 03:06 diegoacuna

@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 :-)

bLuka avatar Jun 27 '19 06:06 bLuka

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)?

kfranqueiro avatar Dec 02 '20 17:12 kfranqueiro