From f876d8fdc82235f75a11a5807f05b4d8b469d521 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 23 Aug 2020 10:31:19 +1000 Subject: [PATCH] use constants --- pkg/gui/context.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/gui/context.go b/pkg/gui/context.go index a1f0ae251..3bfbab089 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -591,20 +591,20 @@ func (gui *Gui) onViewFocusLost(v *gocui.View, newView *gocui.View) error { // which currently just means a context that affects both the main and secondary views // other views can have their context changed directly but this function helps // keep the main and secondary views in sync -func (gui *Gui) changeMainViewsContext(context string) { - if gui.State.MainContext == context { +func (gui *Gui) changeMainViewsContext(contextKey string) { + if gui.State.MainContext == contextKey { return } - switch context { - case "normal", "patchBuilding", "staging", "merging": - gui.getMainView().Context = context - gui.getSecondaryView().Context = context + switch contextKey { + case MAIN_NORMAL_CONTEXT_KEY, MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY, MAIN_MERGING_CONTEXT_KEY: + gui.getMainView().Context = contextKey + gui.getSecondaryView().Context = contextKey default: - panic(fmt.Sprintf("unknown context for main: %s", context)) + panic(fmt.Sprintf("unknown context for main: %s", contextKey)) } - gui.State.MainContext = context + gui.State.MainContext = contextKey } func (gui *Gui) viewTabNames(viewName string) []string {