1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

minor cleanup

This commit is contained in:
Jesse Duffield 2019-03-11 09:28:47 +11:00
parent 06fe726ee7
commit 1ad9c6faac
9 changed files with 42 additions and 10 deletions

View File

@ -8,6 +8,6 @@ type CommitFile struct {
}
// GetDisplayStrings is a function.
func (f *CommitFile) GetDisplayStrings() []string {
func (f *CommitFile) GetDisplayStrings(isFocused bool) []string {
return []string{f.DisplayString}
}

View File

@ -17,7 +17,7 @@ func (gui *Gui) getSelectedCommitFile(g *gocui.Gui) *commands.CommitFile {
func (gui *Gui) handleCommitFileSelect(g *gocui.Gui, v *gocui.View) error {
commitFile := gui.getSelectedCommitFile(g)
if commitFile == nil {
return gui.renderString(g, "commit files", gui.Tr.SLocalize("NoCommiteFiles"))
return gui.renderString(g, "commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
}
if err := gui.focusPoint(0, gui.State.Panels.CommitFiles.SelectedLine, v); err != nil {

View File

@ -445,7 +445,7 @@ func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) erro
return nil
}
commitfileView, err := g.View("commit files")
commitfileView, err := g.View("commitFiles")
if err != nil {
return err
}
@ -470,6 +470,6 @@ func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) erro
})
}
gui.renderString(g, "commit files", files)
gui.renderListPanel(gui.getCommitFilesView(), gui.State.CommitFiles)
return gui.switchFocus(g, v, commitfileView)
}

View File

@ -260,9 +260,18 @@ func (gui *Gui) onFocusLost(v *gocui.View) error {
return nil
}
// if we have lost focus to a first-class panel, we need to do some cleanup
if err := gui.changeContext("main", "normal"); err != nil {
return err
}
} else if v.Name() == "commitFiles" {
// if we have lost focus to a popup panel, that's okay
if gui.popupPanelFocused() {
return nil
}
gui.g.SetViewOnBottom(v.Name())
}
gui.Log.Info(v.Name() + " focus lost")
return nil
@ -358,7 +367,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
branchesView.FgColor = gocui.ColorWhite
}
if v, err := g.SetView("commit files", 0, commitsBranchesBoundary+panelSpacing, leftSideWidth, commitsStashBoundary, gocui.TOP|gocui.BOTTOM); err != nil {
if v, err := g.SetView("commitFiles", 0, commitsBranchesBoundary+panelSpacing, leftSideWidth, commitsStashBoundary, gocui.TOP|gocui.BOTTOM); err != nil {
if err.Error() != "unknown view" {
return err
}

View File

@ -393,7 +393,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Key: gocui.KeyEnter,
Modifier: gocui.ModNone,
Handler: gui.handleSwitchToCommitFilesPanel,
Description: gui.Tr.SLocalize("CommitFiles"),
Description: gui.Tr.SLocalize("viewCommitFiles"),
}, {
ViewName: "stash",
Key: gocui.KeySpace,
@ -448,11 +448,11 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Modifier: gocui.ModNone,
Handler: gui.handleDonate,
}, {
ViewName: "commit files",
ViewName: "commitFiles",
Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.handleSwitchToCommitsPanel,
Description: gui.Tr.SLocalize("CommitsTitle"),
Description: gui.Tr.SLocalize("goBack"),
},
}
@ -477,7 +477,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
"commits": {prevLine: gui.handleCommitsPrevLine, nextLine: gui.handleCommitsNextLine, focus: gui.handleCommitSelect},
"stash": {prevLine: gui.handleStashPrevLine, nextLine: gui.handleStashNextLine, focus: gui.handleStashEntrySelect},
"status": {focus: gui.handleStatusSelect},
"commit files": {prevLine: gui.handleCommitFilesPrevLine, nextLine: gui.handleCommitFilesNextLine},
"commitFiles": {prevLine: gui.handleCommitFilesPrevLine, nextLine: gui.handleCommitFilesNextLine, focus: gui.handleCommitFileSelect},
}
for viewName, functions := range listPanelMap {

View File

@ -95,7 +95,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
return gui.handleBranchSelect(g, v)
case "commits":
return gui.handleCommitSelect(g, v)
case "commit files":
case "commitFiles":
return gui.handleCommitFileSelect(g, v)
case "stash":
return gui.handleStashEntrySelect(g, v)
@ -285,6 +285,11 @@ func (gui *Gui) getStashView() *gocui.View {
return v
}
func (gui *Gui) getCommitFilesView() *gocui.View {
v, _ := gui.g.View("commitFiles")
return v
}
func (gui *Gui) trimmedContent(v *gocui.View) string {
return strings.TrimSpace(v.Buffer())
}

View File

@ -646,6 +646,12 @@ func addDutch(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "CommitFiles",
Other: "Commit files",
}, &i18n.Message{
ID: "viewCommitFiles",
Other: "view commit's files",
}, &i18n.Message{
ID: "goBack",
Other: "go back",
}, &i18n.Message{
ID: "NoCommiteFiles",
Other: "No files for this commit",

View File

@ -669,6 +669,12 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "CommitFiles",
Other: "Commit files",
}, &i18n.Message{
ID: "viewCommitFiles",
Other: "view commit's files",
}, &i18n.Message{
ID: "goBack",
Other: "go back",
}, &i18n.Message{
ID: "NoCommiteFiles",
Other: "No files for this commit",

View File

@ -629,6 +629,12 @@ func addPolish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "CommitFiles",
Other: "Commit files",
}, &i18n.Message{
ID: "viewCommitFiles",
Other: "view commit's files",
}, &i18n.Message{
ID: "goBack",
Other: "go back",
}, &i18n.Message{
ID: "NoCommiteFiles",
Other: "No files for this commit",