code: func (g *Gui) flush() error {
  	termbox.Clear(termbox.Attribute(g.FgColor), termbox.Attribute(g.BgColor))
  
  	maxX, maxY := termbox.Size()
  	// if GUI's size has changed, we need to redraw all views
  	if maxX != g.maxX || maxY != g.maxY {
  		for _, v := range g.views {
  			v.tainted = true
  		}
  	}
  	g.maxX, g.maxY = maxX, maxY
  
  	for _, m := range g.managers {
  		if err := m.Layout(g); err != nil {
  			return err
  		}
  	}
  	for _, v := range g.views {
  		if v.Frame {
  			var fgColor, bgColor Attribute
  			if g.Highlight && v == g.currentView {
  				fgColor = g.SelFgColor
  				bgColor = g.SelBgColor
  			} else {
  				fgColor = g.FgColor
  				bgColor = g.BgColor
  			}
  
  			if err := g.drawFrameEdges(v, fgColor, bgColor); err != nil {
  				return err
  			}
  			if err := g.drawFrameCorners(v, fgColor, bgColor); err != nil {
  				return err
  			}
  			if v.Title != "" {
  				if err := g.drawTitle(v, fgColor, bgColor); err != nil {
  					return err
  				}
  			}
  		}
  		if err := g.draw(v); err != nil {
  			return err
  		}
  	}
  	termbox.Flush()
  	return nil
  }
docs: // flush updates the gui, re-drawing frames and buffers.