diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-05 00:31:52 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | 39ae122304868a4de60659291e9220b4bab2dde1 (patch) | |
tree | 41a86ece1287aed985015a3c17949af52735945e /pkg/gui/view_helpers.go | |
parent | c34c6926d5e1f5a49b90b7a8979bbb0919f00f38 (diff) |
more refactoring
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r-- | pkg/gui/view_helpers.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 15d513509..a7d64559c 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -207,24 +207,20 @@ func (gui *Gui) setViewContent(v *gocui.View, s string) { } // renderString resets the origin of a view and sets its content -func (gui *Gui) renderString(viewName, s string) { +func (gui *Gui) renderString(view *gocui.View, s string) { gui.g.Update(func(*gocui.Gui) error { - return gui.renderStringSync(viewName, s) + return gui.renderStringSync(view, s) }) } -func (gui *Gui) renderStringSync(viewName, s string) error { - v, err := gui.g.View(viewName) - if err != nil { - return nil // return gracefully if view has been deleted - } - if err := v.SetOrigin(0, 0); err != nil { +func (gui *Gui) renderStringSync(view *gocui.View, s string) error { + if err := view.SetOrigin(0, 0); err != nil { return err } - if err := v.SetCursor(0, 0); err != nil { + if err := view.SetCursor(0, 0); err != nil { return err } - gui.setViewContent(v, s) + gui.setViewContent(view, s) return nil } @@ -238,7 +234,7 @@ func (gui *Gui) optionsMapToString(optionsMap map[string]string) string { } func (gui *Gui) renderOptionsMap(optionsMap map[string]string) { - gui.renderString("options", gui.optionsMapToString(optionsMap)) + gui.renderString(gui.Views.Options, gui.optionsMapToString(optionsMap)) } func (gui *Gui) trimmedContent(v *gocui.View) string { |