mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-21 12:16:54 +02:00
minor cleanup
This commit is contained in:
parent
06fe726ee7
commit
1ad9c6faac
@ -8,6 +8,6 @@ type CommitFile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDisplayStrings is a function.
|
// GetDisplayStrings is a function.
|
||||||
func (f *CommitFile) GetDisplayStrings() []string {
|
func (f *CommitFile) GetDisplayStrings(isFocused bool) []string {
|
||||||
return []string{f.DisplayString}
|
return []string{f.DisplayString}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ func (gui *Gui) getSelectedCommitFile(g *gocui.Gui) *commands.CommitFile {
|
|||||||
func (gui *Gui) handleCommitFileSelect(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleCommitFileSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
commitFile := gui.getSelectedCommitFile(g)
|
commitFile := gui.getSelectedCommitFile(g)
|
||||||
if commitFile == nil {
|
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 {
|
if err := gui.focusPoint(0, gui.State.Panels.CommitFiles.SelectedLine, v); err != nil {
|
||||||
|
@ -445,7 +445,7 @@ func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) erro
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
commitfileView, err := g.View("commit files")
|
commitfileView, err := g.View("commitFiles")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
return gui.switchFocus(g, v, commitfileView)
|
||||||
}
|
}
|
||||||
|
@ -260,9 +260,18 @@ func (gui *Gui) onFocusLost(v *gocui.View) error {
|
|||||||
return nil
|
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 {
|
if err := gui.changeContext("main", "normal"); err != nil {
|
||||||
return err
|
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")
|
gui.Log.Info(v.Name() + " focus lost")
|
||||||
return nil
|
return nil
|
||||||
@ -358,7 +367,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||||||
branchesView.FgColor = gocui.ColorWhite
|
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" {
|
if err.Error() != "unknown view" {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Key: gocui.KeyEnter,
|
Key: gocui.KeyEnter,
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleSwitchToCommitFilesPanel,
|
Handler: gui.handleSwitchToCommitFilesPanel,
|
||||||
Description: gui.Tr.SLocalize("CommitFiles"),
|
Description: gui.Tr.SLocalize("viewCommitFiles"),
|
||||||
}, {
|
}, {
|
||||||
ViewName: "stash",
|
ViewName: "stash",
|
||||||
Key: gocui.KeySpace,
|
Key: gocui.KeySpace,
|
||||||
@ -448,11 +448,11 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleDonate,
|
Handler: gui.handleDonate,
|
||||||
}, {
|
}, {
|
||||||
ViewName: "commit files",
|
ViewName: "commitFiles",
|
||||||
Key: gocui.KeyEsc,
|
Key: gocui.KeyEsc,
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleSwitchToCommitsPanel,
|
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},
|
"commits": {prevLine: gui.handleCommitsPrevLine, nextLine: gui.handleCommitsNextLine, focus: gui.handleCommitSelect},
|
||||||
"stash": {prevLine: gui.handleStashPrevLine, nextLine: gui.handleStashNextLine, focus: gui.handleStashEntrySelect},
|
"stash": {prevLine: gui.handleStashPrevLine, nextLine: gui.handleStashNextLine, focus: gui.handleStashEntrySelect},
|
||||||
"status": {focus: gui.handleStatusSelect},
|
"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 {
|
for viewName, functions := range listPanelMap {
|
||||||
|
@ -95,7 +95,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.handleBranchSelect(g, v)
|
return gui.handleBranchSelect(g, v)
|
||||||
case "commits":
|
case "commits":
|
||||||
return gui.handleCommitSelect(g, v)
|
return gui.handleCommitSelect(g, v)
|
||||||
case "commit files":
|
case "commitFiles":
|
||||||
return gui.handleCommitFileSelect(g, v)
|
return gui.handleCommitFileSelect(g, v)
|
||||||
case "stash":
|
case "stash":
|
||||||
return gui.handleStashEntrySelect(g, v)
|
return gui.handleStashEntrySelect(g, v)
|
||||||
@ -285,6 +285,11 @@ func (gui *Gui) getStashView() *gocui.View {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) getCommitFilesView() *gocui.View {
|
||||||
|
v, _ := gui.g.View("commitFiles")
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) trimmedContent(v *gocui.View) string {
|
func (gui *Gui) trimmedContent(v *gocui.View) string {
|
||||||
return strings.TrimSpace(v.Buffer())
|
return strings.TrimSpace(v.Buffer())
|
||||||
}
|
}
|
||||||
|
@ -646,6 +646,12 @@ func addDutch(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "CommitFiles",
|
ID: "CommitFiles",
|
||||||
Other: "Commit files",
|
Other: "Commit files",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "viewCommitFiles",
|
||||||
|
Other: "view commit's files",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "goBack",
|
||||||
|
Other: "go back",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "NoCommiteFiles",
|
ID: "NoCommiteFiles",
|
||||||
Other: "No files for this commit",
|
Other: "No files for this commit",
|
||||||
|
@ -669,6 +669,12 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "CommitFiles",
|
ID: "CommitFiles",
|
||||||
Other: "Commit files",
|
Other: "Commit files",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "viewCommitFiles",
|
||||||
|
Other: "view commit's files",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "goBack",
|
||||||
|
Other: "go back",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "NoCommiteFiles",
|
ID: "NoCommiteFiles",
|
||||||
Other: "No files for this commit",
|
Other: "No files for this commit",
|
||||||
|
@ -629,6 +629,12 @@ func addPolish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "CommitFiles",
|
ID: "CommitFiles",
|
||||||
Other: "Commit files",
|
Other: "Commit files",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "viewCommitFiles",
|
||||||
|
Other: "view commit's files",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "goBack",
|
||||||
|
Other: "go back",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "NoCommiteFiles",
|
ID: "NoCommiteFiles",
|
||||||
Other: "No files for this commit",
|
Other: "No files for this commit",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user