diff options
author | Michael Muré <batolettre@gmail.com> | 2018-08-02 14:56:50 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-08-02 14:56:50 +0200 |
commit | e6a64b4985f5d342b8e75fecaf4d138f4f50487e (patch) | |
tree | f28a1fa4f84d9f67076711b3bf972804f3b551d1 /termui | |
parent | e5a6a71b78b0d8c5ef0d52c3eeb279d5738b9cf7 (diff) | |
download | git-bug-e6a64b4985f5d342b8e75fecaf4d138f4f50487e.tar.gz |
cache: some refactoring
Diffstat (limited to 'termui')
-rw-r--r-- | termui/error_popup.go | 15 | ||||
-rw-r--r-- | termui/termui.go | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/termui/error_popup.go b/termui/error_popup.go index 7ec6b783..e46a00e7 100644 --- a/termui/error_popup.go +++ b/termui/error_popup.go @@ -9,12 +9,12 @@ import ( const errorPopupView = "errorPopupView" type errorPopup struct { - err string + message string } func newErrorPopup() *errorPopup { return &errorPopup{ - err: "", + message: "", } } @@ -30,14 +30,14 @@ func (ep *errorPopup) keybindings(g *gocui.Gui) error { } func (ep *errorPopup) layout(g *gocui.Gui) error { - if ep.err == "" { + if ep.message == "" { return nil } maxX, maxY := g.Size() width := minInt(30, maxX) - wrapped, nblines := word_wrap(ep.err, width-2) + wrapped, nblines := word_wrap(ep.message, width-2) height := minInt(nblines+2, maxY) x0 := (maxX - width) / 2 y0 := (maxY - height) / 2 @@ -49,6 +49,7 @@ func (ep *errorPopup) layout(g *gocui.Gui) error { } v.Frame = true + v.Title = "Error" fmt.Fprintf(v, wrapped) } @@ -61,12 +62,12 @@ func (ep *errorPopup) layout(g *gocui.Gui) error { } func (ep *errorPopup) close(g *gocui.Gui, v *gocui.View) error { - ep.err = "" + ep.message = "" return g.DeleteView(errorPopupView) } -func (ep *errorPopup) isActive() bool { - return ep.err != "" +func (ep *errorPopup) activate(message string) { + ep.message = message } func word_wrap(text string, lineWidth int) (string, int) { diff --git a/termui/termui.go b/termui/termui.go index 727b9f3d..a5da4bda 100644 --- a/termui/termui.go +++ b/termui/termui.go @@ -156,7 +156,7 @@ func newBugWithEditor(g *gocui.Gui, v *gocui.View) error { } if err == input.ErrEmptyTitle { - ui.errorPopup.err = err.Error() + ui.errorPopup.activate("Empty title, aborting.") } else { _, err = ui.cache.NewBug(title, message) if err != nil { |