mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
standardise diffmode
This commit is contained in:
@ -24,14 +24,6 @@ func (gui *Gui) getSelectedBranch() *commands.Branch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleBranchSelect() error {
|
func (gui *Gui) handleBranchSelect() error {
|
||||||
if gui.popupPanelFocused() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
var task updateTask
|
var task updateTask
|
||||||
branch := gui.getSelectedBranch()
|
branch := gui.getSelectedBranch()
|
||||||
if branch == nil {
|
if branch == nil {
|
||||||
|
@ -16,13 +16,7 @@ func (gui *Gui) getSelectedCommitFile() *commands.CommitFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleCommitFileSelect() error {
|
func (gui *Gui) handleCommitFileSelect() error {
|
||||||
if gui.popupPanelFocused() {
|
gui.handleEscapeLineByLinePanel()
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if gui.currentViewName() == "commitFiles" {
|
|
||||||
gui.handleEscapeLineByLinePanel()
|
|
||||||
}
|
|
||||||
|
|
||||||
commitFile := gui.getSelectedCommitFile()
|
commitFile := gui.getSelectedCommitFile()
|
||||||
if commitFile == nil {
|
if commitFile == nil {
|
||||||
|
@ -20,14 +20,6 @@ func (gui *Gui) getSelectedCommit() *commands.Commit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleCommitSelect() error {
|
func (gui *Gui) handleCommitSelect() error {
|
||||||
if gui.popupPanelFocused() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
state := gui.State.Panels.Commits
|
state := gui.State.Panels.Commits
|
||||||
if state.SelectedLine > 290 && state.LimitCommits {
|
if state.SelectedLine > 290 && state.LimitCommits {
|
||||||
state.LimitCommits = false
|
state.LimitCommits = false
|
||||||
|
@ -30,10 +30,6 @@ func (gui *Gui) getSelectedFile() *commands.File {
|
|||||||
func (gui *Gui) selectFile(alreadySelected bool) error {
|
func (gui *Gui) selectFile(alreadySelected bool) error {
|
||||||
gui.getFilesView().FocusPoint(0, gui.State.Panels.Files.SelectedLine)
|
gui.getFilesView().FocusPoint(0, gui.State.Panels.Files.SelectedLine)
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
file := gui.getSelectedFile()
|
file := gui.getSelectedFile()
|
||||||
if file == nil {
|
if file == nil {
|
||||||
return gui.refreshMain(refreshMainOpts{
|
return gui.refreshMain(refreshMainOpts{
|
||||||
|
@ -13,7 +13,6 @@ type ListContext struct {
|
|||||||
GetDisplayStrings func() [][]string
|
GetDisplayStrings func() [][]string
|
||||||
OnFocus func() error
|
OnFocus func() error
|
||||||
OnFocusLost func() error
|
OnFocusLost func() error
|
||||||
OnItemSelect func() error
|
|
||||||
OnClickSelectedItem func() error
|
OnClickSelectedItem func() error
|
||||||
|
|
||||||
Gui *Gui
|
Gui *Gui
|
||||||
@ -57,7 +56,19 @@ func (lc *ListContext) HandleFocusLost() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (lc *ListContext) HandleFocus() error {
|
func (lc *ListContext) HandleFocus() error {
|
||||||
return lc.OnFocus()
|
if lc.Gui.popupPanelFocused() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if lc.Gui.inDiffMode() {
|
||||||
|
return lc.Gui.renderDiff()
|
||||||
|
}
|
||||||
|
|
||||||
|
if lc.OnFocus != nil {
|
||||||
|
return lc.OnFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *ListContext) HandleRender() error {
|
func (lc *ListContext) HandleRender() error {
|
||||||
@ -94,10 +105,7 @@ func (lc *ListContext) handleLineChange(change int) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if lc.OnItemSelect != nil {
|
return lc.HandleFocus()
|
||||||
return lc.OnItemSelect()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *ListContext) handleNextPage(g *gocui.Gui, v *gocui.View) error {
|
func (lc *ListContext) handleNextPage(g *gocui.Gui, v *gocui.View) error {
|
||||||
@ -158,18 +166,12 @@ func (lc *ListContext) handleClick(g *gocui.Gui, v *gocui.View) error {
|
|||||||
if prevSelectedLineIdx == newSelectedLineIdx && prevViewName == lc.ViewName && lc.OnClickSelectedItem != nil {
|
if prevSelectedLineIdx == newSelectedLineIdx && prevViewName == lc.ViewName && lc.OnClickSelectedItem != nil {
|
||||||
return lc.OnClickSelectedItem()
|
return lc.OnClickSelectedItem()
|
||||||
}
|
}
|
||||||
if lc.OnItemSelect != nil {
|
return lc.HandleFocus()
|
||||||
return lc.OnItemSelect()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *ListContext) onSearchSelect(selectedLineIdx int) error {
|
func (lc *ListContext) onSearchSelect(selectedLineIdx int) error {
|
||||||
*lc.GetSelectedLineIdxPtr() = selectedLineIdx
|
*lc.GetSelectedLineIdxPtr() = selectedLineIdx
|
||||||
if lc.OnItemSelect != nil {
|
return lc.HandleFocus()
|
||||||
return lc.OnItemSelect()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) menuListContext() *ListContext {
|
func (gui *Gui) menuListContext() *ListContext {
|
||||||
@ -179,7 +181,6 @@ func (gui *Gui) menuListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return gui.getMenuView().LinesHeight() },
|
GetItemsLength: func() int { return gui.getMenuView().LinesHeight() },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Menu.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Menu.SelectedLine },
|
||||||
OnFocus: gui.handleMenuSelect,
|
OnFocus: gui.handleMenuSelect,
|
||||||
OnItemSelect: gui.handleMenuSelect,
|
|
||||||
// need to add a layer of indirection here because the callback changes during runtime
|
// need to add a layer of indirection here because the callback changes during runtime
|
||||||
OnClickSelectedItem: func() error { return gui.State.Panels.Menu.OnPress(gui.g, nil) },
|
OnClickSelectedItem: func() error { return gui.State.Panels.Menu.OnPress(gui.g, nil) },
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
@ -197,7 +198,6 @@ func (gui *Gui) filesListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.Files) },
|
GetItemsLength: func() int { return len(gui.State.Files) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Files.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Files.SelectedLine },
|
||||||
OnFocus: gui.focusAndSelectFile,
|
OnFocus: gui.focusAndSelectFile,
|
||||||
OnItemSelect: gui.focusAndSelectFile,
|
|
||||||
OnClickSelectedItem: gui.handleFilePress,
|
OnClickSelectedItem: gui.handleFilePress,
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: false,
|
RendersToMainView: false,
|
||||||
@ -215,7 +215,6 @@ func (gui *Gui) branchesListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.Branches) },
|
GetItemsLength: func() int { return len(gui.State.Branches) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Branches.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Branches.SelectedLine },
|
||||||
OnFocus: gui.handleBranchSelect,
|
OnFocus: gui.handleBranchSelect,
|
||||||
OnItemSelect: gui.handleBranchSelect,
|
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
Kind: SIDE_CONTEXT,
|
Kind: SIDE_CONTEXT,
|
||||||
@ -232,7 +231,6 @@ func (gui *Gui) remotesListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.Remotes) },
|
GetItemsLength: func() int { return len(gui.State.Remotes) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Remotes.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Remotes.SelectedLine },
|
||||||
OnFocus: gui.handleRemoteSelect,
|
OnFocus: gui.handleRemoteSelect,
|
||||||
OnItemSelect: gui.handleRemoteSelect,
|
|
||||||
OnClickSelectedItem: gui.handleRemoteEnter,
|
OnClickSelectedItem: gui.handleRemoteEnter,
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
@ -250,7 +248,6 @@ func (gui *Gui) remoteBranchesListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.RemoteBranches) },
|
GetItemsLength: func() int { return len(gui.State.RemoteBranches) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.RemoteBranches.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.RemoteBranches.SelectedLine },
|
||||||
OnFocus: gui.handleRemoteBranchSelect,
|
OnFocus: gui.handleRemoteBranchSelect,
|
||||||
OnItemSelect: gui.handleRemoteBranchSelect,
|
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
Kind: SIDE_CONTEXT,
|
Kind: SIDE_CONTEXT,
|
||||||
@ -267,7 +264,6 @@ func (gui *Gui) tagsListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.Tags) },
|
GetItemsLength: func() int { return len(gui.State.Tags) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Tags.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Tags.SelectedLine },
|
||||||
OnFocus: gui.handleTagSelect,
|
OnFocus: gui.handleTagSelect,
|
||||||
OnItemSelect: gui.handleTagSelect,
|
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
Kind: SIDE_CONTEXT,
|
Kind: SIDE_CONTEXT,
|
||||||
@ -284,7 +280,6 @@ func (gui *Gui) branchCommitsListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.Commits) },
|
GetItemsLength: func() int { return len(gui.State.Commits) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Commits.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Commits.SelectedLine },
|
||||||
OnFocus: gui.handleCommitSelect,
|
OnFocus: gui.handleCommitSelect,
|
||||||
OnItemSelect: gui.handleCommitSelect,
|
|
||||||
OnClickSelectedItem: gui.handleSwitchToCommitFilesPanel,
|
OnClickSelectedItem: gui.handleSwitchToCommitFilesPanel,
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
@ -302,7 +297,6 @@ func (gui *Gui) reflogCommitsListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.FilteredReflogCommits) },
|
GetItemsLength: func() int { return len(gui.State.FilteredReflogCommits) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.ReflogCommits.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.ReflogCommits.SelectedLine },
|
||||||
OnFocus: gui.handleReflogCommitSelect,
|
OnFocus: gui.handleReflogCommitSelect,
|
||||||
OnItemSelect: gui.handleReflogCommitSelect,
|
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
Kind: SIDE_CONTEXT,
|
Kind: SIDE_CONTEXT,
|
||||||
@ -319,7 +313,6 @@ func (gui *Gui) stashListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.StashEntries) },
|
GetItemsLength: func() int { return len(gui.State.StashEntries) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Stash.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Stash.SelectedLine },
|
||||||
OnFocus: gui.handleStashEntrySelect,
|
OnFocus: gui.handleStashEntrySelect,
|
||||||
OnItemSelect: gui.handleStashEntrySelect,
|
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
Kind: SIDE_CONTEXT,
|
Kind: SIDE_CONTEXT,
|
||||||
@ -337,7 +330,6 @@ func (gui *Gui) commitFilesListContext() *ListContext {
|
|||||||
GetItemsLength: func() int { return len(gui.State.CommitFiles) },
|
GetItemsLength: func() int { return len(gui.State.CommitFiles) },
|
||||||
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.CommitFiles.SelectedLine },
|
GetSelectedLineIdxPtr: func() *int { return &gui.State.Panels.CommitFiles.SelectedLine },
|
||||||
OnFocus: gui.handleCommitFileSelect,
|
OnFocus: gui.handleCommitFileSelect,
|
||||||
OnItemSelect: gui.handleCommitFileSelect,
|
|
||||||
Gui: gui,
|
Gui: gui,
|
||||||
RendersToMainView: true,
|
RendersToMainView: true,
|
||||||
Kind: SIDE_CONTEXT,
|
Kind: SIDE_CONTEXT,
|
||||||
|
@ -18,10 +18,6 @@ func (gui *Gui) getSelectedReflogCommit() *commands.Commit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleReflogCommitSelect() error {
|
func (gui *Gui) handleReflogCommitSelect() error {
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
commit := gui.getSelectedReflogCommit()
|
commit := gui.getSelectedReflogCommit()
|
||||||
var task updateTask
|
var task updateTask
|
||||||
if commit == nil {
|
if commit == nil {
|
||||||
|
@ -19,14 +19,6 @@ func (gui *Gui) getSelectedRemoteBranch() *commands.RemoteBranch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleRemoteBranchSelect() error {
|
func (gui *Gui) handleRemoteBranchSelect() error {
|
||||||
if gui.popupPanelFocused() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
var task updateTask
|
var task updateTask
|
||||||
remoteBranch := gui.getSelectedRemoteBranch()
|
remoteBranch := gui.getSelectedRemoteBranch()
|
||||||
if remoteBranch == nil {
|
if remoteBranch == nil {
|
||||||
|
@ -22,14 +22,6 @@ func (gui *Gui) getSelectedRemote() *commands.Remote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleRemoteSelect() error {
|
func (gui *Gui) handleRemoteSelect() error {
|
||||||
if gui.popupPanelFocused() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
var task updateTask
|
var task updateTask
|
||||||
remote := gui.getSelectedRemote()
|
remote := gui.getSelectedRemote()
|
||||||
if remote == nil {
|
if remote == nil {
|
||||||
|
@ -17,14 +17,6 @@ func (gui *Gui) getSelectedStashEntry() *commands.StashEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleStashEntrySelect() error {
|
func (gui *Gui) handleStashEntrySelect() error {
|
||||||
if gui.popupPanelFocused() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
var task updateTask
|
var task updateTask
|
||||||
stashEntry := gui.getSelectedStashEntry()
|
stashEntry := gui.getSelectedStashEntry()
|
||||||
if stashEntry == nil {
|
if stashEntry == nil {
|
||||||
|
@ -61,6 +61,11 @@ func (gui *Gui) handleCheckForUpdate(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleStatusClick(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleStatusClick(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
// TODO: move into some abstraction (status is currently not a listViewContext where a lot of this code lives)
|
||||||
|
if gui.popupPanelFocused() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
currentBranch := gui.currentBranch()
|
currentBranch := gui.currentBranch()
|
||||||
|
|
||||||
if err := gui.switchContext(gui.Contexts.Status.Context); err != nil {
|
if err := gui.switchContext(gui.Contexts.Status.Context); err != nil {
|
||||||
@ -89,14 +94,11 @@ func (gui *Gui) handleStatusClick(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleStatusSelect() error {
|
func (gui *Gui) handleStatusSelect() error {
|
||||||
|
// TODO: move into some abstraction (status is currently not a listViewContext where a lot of this code lives)
|
||||||
if gui.popupPanelFocused() {
|
if gui.popupPanelFocused() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
magenta := color.New(color.FgMagenta)
|
magenta := color.New(color.FgMagenta)
|
||||||
|
|
||||||
dashboardString := strings.Join(
|
dashboardString := strings.Join(
|
||||||
|
@ -17,14 +17,6 @@ func (gui *Gui) getSelectedTag() *commands.Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleTagSelect() error {
|
func (gui *Gui) handleTagSelect() error {
|
||||||
if gui.popupPanelFocused() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if gui.inDiffMode() {
|
|
||||||
return gui.renderDiff()
|
|
||||||
}
|
|
||||||
|
|
||||||
var task updateTask
|
var task updateTask
|
||||||
tag := gui.getSelectedTag()
|
tag := gui.getSelectedTag()
|
||||||
if tag == nil {
|
if tag == nil {
|
||||||
|
Reference in New Issue
Block a user