mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
chore(i18n): move InitialViewTabContextMap
to gui
package
This commit is contained in:
@ -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,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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) }
|
||||
|
||||
|
Reference in New Issue
Block a user