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/error_popup.go | |
parent | e5a6a71b78b0d8c5ef0d52c3eeb279d5738b9cf7 (diff) | |
download | git-bug-e6a64b4985f5d342b8e75fecaf4d138f4f50487e.tar.gz |
cache: some refactoring
Diffstat (limited to 'termui/error_popup.go')
-rw-r--r-- | termui/error_popup.go | 15 |
1 files changed, 8 insertions, 7 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) { |