From c875d40e631f83507b602807480be96dae05fc85 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 1 Aug 2018 02:15:40 +0200 Subject: termui: add a view to display a bug --- termui/termui.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'termui/termui.go') diff --git a/termui/termui.go b/termui/termui.go index f4a4fb26..727b9f3d 100644 --- a/termui/termui.go +++ b/termui/termui.go @@ -11,20 +11,33 @@ import ( var errTerminateMainloop = errors.New("terminate gocui mainloop") type termUI struct { - g *gocui.Gui - gError chan error - cache cache.RepoCacher + g *gocui.Gui + gError chan error + cache cache.RepoCacher + activeWindow window bugTable *bugTable + showBug *showBug errorPopup *errorPopup } +func (tui *termUI) activateWindow(window window) error { + if err := tui.activeWindow.disable(tui.g); err != nil { + return err + } + + tui.activeWindow = window + + return nil +} + var ui *termUI type window interface { keybindings(g *gocui.Gui) error layout(g *gocui.Gui) error + disable(g *gocui.Gui) error } func Run(repo repository.Repo) error { @@ -34,6 +47,7 @@ func Run(repo repository.Repo) error { gError: make(chan error, 1), cache: c, bugTable: newBugTable(c), + showBug: newShowBug(c), errorPopup: newErrorPopup(), } @@ -107,6 +121,10 @@ func keybindings(g *gocui.Gui) error { return err } + if err := ui.showBug.keybindings(g); err != nil { + return err + } + if err := ui.errorPopup.keybindings(g); err != nil { return err } -- cgit