mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
more stuff
This commit is contained in:
@@ -439,23 +439,22 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) onBranchesTabClick(tabIndex int) error {
|
func (gui *Gui) onViewTabClick(viewName string, tabIndex int) error {
|
||||||
branchesView := gui.getBranchesView()
|
context := gui.ViewTabContextMap[viewName][tabIndex].contexts[0]
|
||||||
branchesView.TabIndex = tabIndex
|
|
||||||
|
|
||||||
context := gui.ViewTabContextMap["branches"][tabIndex].contexts[0]
|
|
||||||
|
|
||||||
return gui.switchContext(context)
|
return gui.switchContext(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleNextBranchesTab(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleNextTab(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.onBranchesTabClick(
|
return gui.onViewTabClick(
|
||||||
|
v.Name(),
|
||||||
utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)),
|
utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handlePrevBranchesTab(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handlePrevTab(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.onBranchesTabClick(
|
return gui.onViewTabClick(
|
||||||
|
v.Name(),
|
||||||
utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)),
|
utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// list panel functions
|
// list panel functions
|
||||||
@@ -633,40 +632,10 @@ func (gui *Gui) renderBranchCommitsWithSelection() error {
|
|||||||
gui.refreshSelectedLine(&gui.State.Panels.Commits.SelectedLine, len(gui.State.Commits))
|
gui.refreshSelectedLine(&gui.State.Panels.Commits.SelectedLine, len(gui.State.Commits))
|
||||||
displayStrings := presentation.GetCommitListDisplayStrings(gui.State.Commits, gui.State.ScreenMode != SCREEN_NORMAL, gui.cherryPickedCommitShaMap(), gui.State.Diff.Ref)
|
displayStrings := presentation.GetCommitListDisplayStrings(gui.State.Commits, gui.State.ScreenMode != SCREEN_NORMAL, gui.cherryPickedCommitShaMap(), gui.State.Diff.Ref)
|
||||||
gui.renderDisplayStrings(commitsView, displayStrings)
|
gui.renderDisplayStrings(commitsView, displayStrings)
|
||||||
if gui.g.CurrentView() == commitsView && commitsView.Context == "branch-commits" {
|
|
||||||
if err := gui.handleCommitSelect(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) onCommitsTabClick(tabIndex int) error {
|
|
||||||
contexts := []string{"branch-commits", "reflog-commits"}
|
|
||||||
commitsView := gui.getCommitsView()
|
|
||||||
commitsView.TabIndex = tabIndex
|
|
||||||
|
|
||||||
return gui.switchCommitsPanelContext(contexts[tabIndex])
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) switchCommitsPanelContext(context string) error {
|
|
||||||
commitsView := gui.getCommitsView()
|
|
||||||
commitsView.Context = context
|
|
||||||
if err := gui.onSearchEscape(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
contextTabIndexMap := map[string]int{
|
|
||||||
"branch-commits": 0,
|
|
||||||
"reflog-commits": 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
commitsView.TabIndex = contextTabIndexMap[context]
|
|
||||||
|
|
||||||
return gui.refreshCommitsViewWithSelection()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) refreshCommitsViewWithSelection() error {
|
func (gui *Gui) refreshCommitsViewWithSelection() error {
|
||||||
commitsView := gui.getCommitsView()
|
commitsView := gui.getCommitsView()
|
||||||
|
|
||||||
@@ -680,18 +649,6 @@ func (gui *Gui) refreshCommitsViewWithSelection() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleNextCommitsTab(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
return gui.onCommitsTabClick(
|
|
||||||
utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) handlePrevCommitsTab(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
return gui.onCommitsTabClick(
|
|
||||||
utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) handleCreateCommitResetMenu(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleCreateCommitResetMenu(g *gocui.Gui, v *gocui.View) error {
|
||||||
commit := gui.getSelectedCommit()
|
commit := gui.getSelectedCommit()
|
||||||
if commit == nil {
|
if commit == nil {
|
||||||
|
@@ -11,18 +11,8 @@ import (
|
|||||||
|
|
||||||
// these views need to be re-rendered when the screen mode changes. The commits view,
|
// these views need to be re-rendered when the screen mode changes. The commits view,
|
||||||
// for example, will show authorship information in half and full screen mode.
|
// for example, will show authorship information in half and full screen mode.
|
||||||
func (gui *Gui) viewsWithScreenModeDependentContent() []string {
|
func (gui *Gui) rerenderViewsWithScreenModeDependentContent() error {
|
||||||
return []string{"branches", "commits"}
|
for _, viewName := range []string{"branches", "commits"} {
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) nextScreenMode(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
gui.State.ScreenMode = utils.NextIntInCycle([]int{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode)
|
|
||||||
// commits render differently depending on whether we're in fullscreen more or not
|
|
||||||
if err := gui.refreshCommitsViewWithSelection(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, viewName := range gui.viewsWithScreenModeDependentContent() {
|
|
||||||
if err := gui.rerenderView(viewName); err != nil {
|
if err := gui.rerenderView(viewName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -31,16 +21,16 @@ func (gui *Gui) nextScreenMode(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) nextScreenMode(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
gui.State.ScreenMode = utils.NextIntInCycle([]int{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode)
|
||||||
|
|
||||||
|
return gui.rerenderViewsWithScreenModeDependentContent()
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) prevScreenMode(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) prevScreenMode(g *gocui.Gui, v *gocui.View) error {
|
||||||
gui.State.ScreenMode = utils.PrevIntInCycle([]int{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode)
|
gui.State.ScreenMode = utils.PrevIntInCycle([]int{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode)
|
||||||
|
|
||||||
for _, viewName := range gui.viewsWithScreenModeDependentContent() {
|
return gui.rerenderViewsWithScreenModeDependentContent()
|
||||||
if err := gui.rerenderView(viewName); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) scrollUpView(viewName string) error {
|
func (gui *Gui) scrollUpView(viewName string) error {
|
||||||
|
@@ -593,13 +593,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
{
|
{
|
||||||
ViewName: "branches",
|
ViewName: "branches",
|
||||||
Key: gui.getKey("universal.nextTab"),
|
Key: gui.getKey("universal.nextTab"),
|
||||||
Handler: gui.handleNextBranchesTab,
|
Handler: gui.handleNextTab,
|
||||||
Description: gui.Tr.SLocalize("nextTab"),
|
Description: gui.Tr.SLocalize("nextTab"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "branches",
|
ViewName: "branches",
|
||||||
Key: gui.getKey("universal.prevTab"),
|
Key: gui.getKey("universal.prevTab"),
|
||||||
Handler: gui.handlePrevBranchesTab,
|
Handler: gui.handlePrevTab,
|
||||||
Description: gui.Tr.SLocalize("prevTab"),
|
Description: gui.Tr.SLocalize("prevTab"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -626,13 +626,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
{
|
{
|
||||||
ViewName: "commits",
|
ViewName: "commits",
|
||||||
Key: gui.getKey("universal.nextTab"),
|
Key: gui.getKey("universal.nextTab"),
|
||||||
Handler: gui.handleNextCommitsTab,
|
Handler: gui.handleNextTab,
|
||||||
Description: gui.Tr.SLocalize("nextTab"),
|
Description: gui.Tr.SLocalize("nextTab"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "commits",
|
ViewName: "commits",
|
||||||
Key: gui.getKey("universal.prevTab"),
|
Key: gui.getKey("universal.prevTab"),
|
||||||
Handler: gui.handlePrevCommitsTab,
|
Handler: gui.handlePrevTab,
|
||||||
Description: gui.Tr.SLocalize("prevTab"),
|
Description: gui.Tr.SLocalize("prevTab"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1415,8 +1415,8 @@ func (gui *Gui) keybindings(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tabClickBindings := map[string]func(int) error{
|
tabClickBindings := map[string]func(int) error{
|
||||||
"branches": gui.onBranchesTabClick,
|
"branches": func(tabIndex int) error { return gui.onViewTabClick("branches", tabIndex) },
|
||||||
"commits": gui.onCommitsTabClick,
|
"commits": func(tabIndex int) error { return gui.onViewTabClick("commits", tabIndex) },
|
||||||
}
|
}
|
||||||
|
|
||||||
for viewName, binding := range tabClickBindings {
|
for viewName, binding := range tabClickBindings {
|
||||||
|
Reference in New Issue
Block a user