diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 09:46:28 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 14:29:18 +1000 |
commit | 0dd2c869a8808e937c69f8ce0ba04015e5a9075e (patch) | |
tree | 24cbbe2466752c0510705384f196347b46373888 /pkg/gui/main_panels.go | |
parent | ed85ea69bd74d2914b8224c83d481e43179e7699 (diff) |
minor refactor
Diffstat (limited to 'pkg/gui/main_panels.go')
-rw-r--r-- | pkg/gui/main_panels.go | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 87072406a..d56856f6f 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -14,6 +14,11 @@ type viewUpdateOpts struct { task updateTask } +type coordinates struct { + x int + y int +} + type refreshMainOpts struct { main *viewUpdateOpts secondary *viewUpdateOpts @@ -118,30 +123,37 @@ func (gui *Gui) runTaskForView(viewName string, task updateTask) error { return nil } -func (gui *Gui) refreshMain(opts refreshMainOpts) error { - mainView := gui.getMainView() - secondaryView := gui.getSecondaryView() +func (gui *Gui) refreshMainView(opts *viewUpdateOpts, viewName string) error { + view, err := gui.g.View(viewName) + if err != nil { + gui.Log.Error(err) + return nil + } - if opts.main != nil { - mainView.Title = opts.main.title - mainView.Wrap = !opts.main.noWrap - mainView.Highlight = opts.main.highlight // TODO: see what the default should be + view.Title = opts.title + view.Wrap = !opts.noWrap + view.Highlight = opts.highlight + + if err := gui.runTaskForView("main", opts.task); err != nil { + gui.Log.Error(err) + return nil + } - if err := gui.runTaskForView("main", opts.main.task); err != nil { - gui.Log.Error(err) - return nil + return nil +} + +func (gui *Gui) refreshMainViews(opts refreshMainOpts) error { + if opts.main != nil { + if err := gui.refreshMainView(opts.main, "main"); err != nil { + return err } } gui.splitMainPanel(opts.secondary != nil) if opts.secondary != nil { - secondaryView.Title = opts.secondary.title - secondaryView.Wrap = !opts.secondary.noWrap - mainView.Highlight = opts.main.highlight // TODO: see what the default should be - if err := gui.runTaskForView("secondary", opts.secondary.task); err != nil { - gui.Log.Error(err) - return nil + if err := gui.refreshMainView(opts.secondary, "secondary"); err != nil { + return err } } |