diff options
Diffstat (limited to 'termui')
-rw-r--r-- | termui/bug_table.go | 8 | ||||
-rw-r--r-- | termui/show_bug.go | 2 | ||||
-rw-r--r-- | termui/termui.go | 26 |
3 files changed, 25 insertions, 11 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go index 78778ec3..169dd7c1 100644 --- a/termui/bug_table.go +++ b/termui/bug_table.go @@ -196,16 +196,16 @@ func (bt *bugTable) keybindings(g *gocui.Gui) error { } func (bt *bugTable) disable(g *gocui.Gui) error { - if err := g.DeleteView(bugTableView); err != nil { + if err := g.DeleteView(bugTableView); err != nil && err != gocui.ErrUnknownView { return err } - if err := g.DeleteView(bugTableHeaderView); err != nil { + if err := g.DeleteView(bugTableHeaderView); err != nil && err != gocui.ErrUnknownView { return err } - if err := g.DeleteView(bugTableFooterView); err != nil { + if err := g.DeleteView(bugTableFooterView); err != nil && err != gocui.ErrUnknownView { return err } - if err := g.DeleteView(bugTableInstructionView); err != nil { + if err := g.DeleteView(bugTableInstructionView); err != nil && err != gocui.ErrUnknownView { return err } return nil diff --git a/termui/show_bug.go b/termui/show_bug.go index 799af9c7..f4f1294f 100644 --- a/termui/show_bug.go +++ b/termui/show_bug.go @@ -191,7 +191,7 @@ func (sb *showBug) keybindings(g *gocui.Gui) error { func (sb *showBug) disable(g *gocui.Gui) error { for _, view := range sb.childViews { - if err := g.DeleteView(view); err != nil { + if err := g.DeleteView(view); err != nil && err != gocui.ErrUnknownView { return err } } diff --git a/termui/termui.go b/termui/termui.go index 0d3bc56e..a2a1a835 100644 --- a/termui/termui.go +++ b/termui/termui.go @@ -56,7 +56,7 @@ func Run(repo repository.Repo) error { ui.activeWindow = ui.bugTable - initGui() + initGui(nil) err := <-ui.gError @@ -67,7 +67,7 @@ func Run(repo repository.Repo) error { return nil } -func initGui() { +func initGui(action func(ui *termUI) error) { g, err := gocui.NewGui(gocui.OutputNormal) if err != nil { @@ -88,6 +88,16 @@ func initGui() { return } + if action != nil { + err = action(ui) + if err != nil { + ui.g.Close() + ui.g = nil + ui.gError <- err + return + } + } + err = g.MainLoop() if err != nil && err != errTerminateMainloop { @@ -166,16 +176,20 @@ func newBugWithEditor(repo cache.RepoCacher) error { return err } + var b cache.BugCacher if err == input.ErrEmptyTitle { ui.msgPopup.Activate(msgPopupErrorTitle, "Empty title, aborting.") } else { - _, err := repo.NewBug(title, message) + b, err = repo.NewBug(title, message) if err != nil { return err } } - initGui() + initGui(func(ui *termUI) error { + ui.showBug.SetBug(b) + return ui.activateWindow(ui.showBug) + }) return errTerminateMainloop } @@ -208,7 +222,7 @@ func addCommentWithEditor(bug cache.BugCacher) error { } } - initGui() + initGui(nil) return errTerminateMainloop } @@ -241,7 +255,7 @@ func setTitleWithEditor(bug cache.BugCacher) error { } } - initGui() + initGui(nil) return errTerminateMainloop } |