MainLoop runs the main loop until an error is returned. A successful finish should return ErrQuit.
()
| 712 | // MainLoop runs the main loop until an error is returned. A successful |
| 713 | // finish should return ErrQuit. |
| 714 | func (g *Gui) MainLoop() error { |
| 715 | go func() { |
| 716 | for { |
| 717 | select { |
| 718 | case <-g.stop: |
| 719 | return |
| 720 | default: |
| 721 | g.gEvents <- g.pollEvent() |
| 722 | } |
| 723 | } |
| 724 | }() |
| 725 | |
| 726 | Screen.EnableFocus() |
| 727 | Screen.EnablePaste() |
| 728 | |
| 729 | previousEnableMouse := false |
| 730 | for { |
| 731 | if g.Mouse != previousEnableMouse { |
| 732 | if g.Mouse { |
| 733 | Screen.EnableMouse() |
| 734 | } else { |
| 735 | Screen.DisableMouse() |
| 736 | } |
| 737 | |
| 738 | previousEnableMouse = g.Mouse |
| 739 | } |
| 740 | |
| 741 | err := g.processEvent() |
| 742 | if err != nil { |
| 743 | return err |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | func (g *Gui) handleError(err error) error { |
| 749 | if err != nil && !standardErrors.Is(err, ErrQuit) && g.ErrorHandler != nil { |
no test coverage detected