You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: gui.go
    path of file: ./repos/cointop/pkg/gocui
    
    the code of the file until where you have to start completion: // Copyright 2014 The gocui Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gocui

import (
	"errors"

	"github.com/gdamore/tcell/v2"
)

var
    
func (g *Gui) flush() error {
	// termbox.Clear(termbox.Attribute(g.FgColor), termbox.Attribute(g.BgColor))
	w, h := g.screen.Size() // TODO: merge with maxX, maxY below
	for row := 0; row < h; row++ {
		for col := 0; col < w; col++ {
			g.screen.SetContent(col, row, ' ', nil, g.Style)
		}
	}

	maxX, maxY := g.screen.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
			st := g.Style
			if g.Highlight && v == g.currentView {
				st = g.SelStyle
			}

			if err := g.drawFrameEdges(v, st); err != nil {
				return err
			}
			if err := g.drawFrameCorners(v, st); err != nil {
				return err
			}
			if v.Title != "" {
				if err := g.drawTitle(v, st); err != nil {
					return err
				}
			}
		}
		if err := g.draw(v); err != nil {
			return err
		}
	}
	g.screen.Show()
	return nil
}