Closed rgl closed 6 years ago
I want to show the terminal width right aligned on the first line of the terminal, but when I resize the terminal, the view does not seem to be updated. Any idea why?
The "35" text should be right aligned after I resize the terminal, but it isn't:
Here's the code:
package main import ( "fmt" "log" "github.com/jroimartin/gocui" "github.com/willf/pad" ) func main() { g, err := gocui.NewGui(gocui.OutputNormal) if err != nil { log.Panicln(err) } defer g.Close() g.SetManagerFunc(layout) if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil { log.Panicln(err) } if err := g.MainLoop(); err != nil && err != gocui.ErrQuit { log.Panicln(err) } } func layout(g *gocui.Gui) error { mx, _ := g.Size() if v, err := g.SetView("title", -1, -1, mx, 1); err != nil { if err != gocui.ErrUnknownView { return err } v.Frame = false v.FgColor = gocui.ColorWhite v.BgColor = gocui.ColorBlue fmt.Fprintln(v, pad.Left(fmt.Sprintf("%d", mx), mx, " ")) } return nil } func quit(g *gocui.Gui, v *gocui.View) error { return gocui.ErrQuit }
Oh, sorry about this... just found https://github.com/jroimartin/gocui/blob/master/_examples/size.go which shed the light on my problem :-)
I want to show the terminal width right aligned on the first line of the terminal, but when I resize the terminal, the view does not seem to be updated. Any idea why?
The "35" text should be right aligned after I resize the terminal, but it isn't:
Here's the code: