gocui
gocui copied to clipboard
Troubles printing a shell to a view
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?
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
@bLuka were you able to find a workaround for this issue? thanks!
@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 :-)
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)?