awesome-gocui / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
344 stars 39 forks source link

[BUG] Unable to Fprintf to view #92

Closed Rudi9719 closed 3 years ago

Rudi9719 commented 3 years ago

Describe the bug When trying to use Fprintf() on a view using the following code, nothing appears. It seems as if the view is rendering outside of the actual frame?

func printToView(viewName string, message string) {
    g.Update(func(g *gocui.Gui) error {
        updatingView, err := g.View(viewName)
        if err != nil {
            return err
        }

        if config.Basics.UnicodeEmojis {
            message = emojiUnicodeConvert(message)
        }
        fmt.Fprintf(updatingView, "%s\n", message)
        return nil
    })
}

To Reproduce Steps to reproduce the behavior:

  1. Run https://github.com/rudi9719/kbtui (which was recently updated to catch up to gocui)
  2. Trigger printToView() which calls fmt.Fprintf on a view
  3. Profit

Expected behavior The printed string would appear inside of the view being updated

Environment (please complete the following information):

Additional context Not sure if this is due to recent changes or not; there were 3 code changes I had to make in order to get the code to build with the updated version of gocui. Seems like if I output enough to Fprintf() it'll EVENTUALLY show what I originally printed, but there's a hidden buffer of things I've printed waiting to actually render.

mjarkk commented 3 years ago

Bit late but create a PR #93 to fix your issue hopefully

dankox commented 3 years ago

@Rudi9719 sorry for the delay, but it should be fixed. Let us know if the latest master resolved your problem. Thanks.

Rudi9719 commented 3 years ago

Take all the time you need! This library saves me so much time lol I can confirm, the problem is indeed fixed in master!