code: func (g *Gui) MainLoop() error {
  	go func() {
  		for {
  			g.tbEvents <- termbox.PollEvent()
  		}
  	}()
  
  	inputMode := termbox.InputAlt
  	if g.InputEsc {
  		inputMode = termbox.InputEsc
  	}
  	if g.Mouse {
  		inputMode |= termbox.InputMouse
  	}
  	termbox.SetInputMode(inputMode)
  
  	if err := g.flush(); err != nil {
  		return err
  	}
  	for {
  		select {
  		case ev := <-g.tbEvents:
  			if err := g.handleEvent(&ev); err != nil {
  				return err
  			}
  		case ev := <-g.userEvents:
  			if err := ev.f(g); err != nil {
  				return err
  			}
  		}
  		if err := g.consumeevents(); err != nil {
  			return err
  		}
  		if err := g.flush(); err != nil {
  			return err
  		}
  	}
  }
docs: // MainLoop runs the main loop until an error is returned. A successful
  // finish should return ErrQuit.