From bfefef92a6d4d2d9d133b70f4bf452341e9995f0 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Wed, 18 May 2022 21:09:48 +0900 Subject: [PATCH] chore(i18n): move `InitialViewTabContextMap` to `gui` package --- pkg/gui/context/context.go | 40 ------------------------------------- pkg/gui/gui.go | 41 +++++++++++++++++++++++++++++++++++++- pkg/gui/keybindings.go | 4 ++-- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go index 6de5c97b0..c2001b215 100644 --- a/pkg/gui/context/context.go +++ b/pkg/gui/context/context.go @@ -4,7 +4,6 @@ import ( "sync" "github.com/jesseduffield/lazygit/pkg/gui/types" - "github.com/jesseduffield/lazygit/pkg/i18n" ) const ( @@ -144,42 +143,3 @@ type TabContext struct { Tab string Context types.Context } - -func (tree ContextTree) InitialViewTabContextMap(tr *i18n.TranslationSet) map[string][]TabContext { - return map[string][]TabContext{ - "branches": { - { - Tab: tr.LocalBranchesTitle, - Context: tree.Branches, - }, - { - Tab: tr.RemotesTitle, - Context: tree.Remotes, - }, - { - Tab: tr.TagsTitle, - Context: tree.Tags, - }, - }, - "commits": { - { - Tab: tr.CommitsTitle, - Context: tree.LocalCommits, - }, - { - Tab: tr.ReflogCommitsTitle, - Context: tree.ReflogCommits, - }, - }, - "files": { - { - Tab: tr.FilesTitle, - Context: tree.Files, - }, - { - Tab: tr.SubmodulesTitle, - Context: tree.Submodules, - }, - }, - } -} diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index d1aaaee33..3f07fb986 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -343,7 +343,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { Diffing: diffing.New(), }, ViewContextMap: viewContextMap, - ViewTabContextMap: contextTree.InitialViewTabContextMap(gui.c.Tr), + ViewTabContextMap: gui.initialViewTabContextMap(contextTree), ScreenMode: screenMode, // TODO: put contexts in the context manager ContextManager: NewContextManager(initialContext), @@ -466,6 +466,45 @@ func (gui *Gui) initGocui() (*gocui.Gui, error) { return g, nil } +func (gui *Gui) initialViewTabContextMap(contextTree *context.ContextTree) map[string][]context.TabContext { + return map[string][]context.TabContext{ + "branches": { + { + Tab: gui.c.Tr.LocalBranchesTitle, + Context: contextTree.Branches, + }, + { + Tab: gui.c.Tr.RemotesTitle, + Context: contextTree.Remotes, + }, + { + Tab: gui.c.Tr.TagsTitle, + Context: contextTree.Tags, + }, + }, + "commits": { + { + Tab: gui.c.Tr.CommitsTitle, + Context: contextTree.LocalCommits, + }, + { + Tab: gui.c.Tr.ReflogCommitsTitle, + Context: contextTree.ReflogCommits, + }, + }, + "files": { + { + Tab: gui.c.Tr.FilesTitle, + Context: contextTree.Files, + }, + { + Tab: gui.c.Tr.SubmodulesTitle, + Context: contextTree.Submodules, + }, + }, + } +} + // Run: setup the gui with keybindings and start the mainloop func (gui *Gui) Run(filterPath string) error { g, err := gui.initGocui() diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 59d2693f2..d7910d18b 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -868,7 +868,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi } } - for viewName := range self.State.Contexts.InitialViewTabContextMap(self.c.Tr) { + for viewName := range self.initialViewTabContextMap(self.State.Contexts) { bindings = append(bindings, []*types.Binding{ { ViewName: viewName, @@ -914,7 +914,7 @@ func (gui *Gui) resetKeybindings() error { } } - for viewName := range gui.State.Contexts.InitialViewTabContextMap(gui.c.Tr) { + for viewName := range gui.initialViewTabContextMap(gui.State.Contexts) { viewName := viewName tabClickCallback := func(tabIndex int) error { return gui.onViewTabClick(viewName, tabIndex) }