diff options
Diffstat (limited to 'pkg/gui')
79 files changed, 2394 insertions, 1917 deletions
diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index 5ab8ab5dd..89236ae5c 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -105,20 +105,13 @@ func (gui *Gui) mainSectionChildren() []*boxlayout.Box { } } - main := "main" - secondary := "secondary" - if gui.secondaryViewFocused() { - // when you think you've focused the secondary view, we've actually just swapped them around in the layout - main, secondary = secondary, main - } - return []*boxlayout.Box{ { - Window: main, + Window: "main", Weight: 1, }, { - Window: secondary, + Window: "secondary", Weight: 1, }, } diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index a8593e9f3..aa03c9880 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -12,6 +12,7 @@ func (gui *Gui) branchesRenderToMain() error { } return gui.refreshMainViews(refreshMainOpts{ + pair: gui.normalMainContextPair(), main: &viewUpdateOpts{ title: gui.c.Tr.LogTitle, task: task, diff --git a/pkg/gui/command_log_panel.go b/pkg/gui/command_log_panel.go index 409fa0023..33f410043 100644 --- a/pkg/gui/command_log_panel.go +++ b/pkg/gui/command_log_panel.go @@ -12,10 +12,10 @@ import ( ) // our UI command log looks like this: -// Stage File -// git add -- 'filename' -// Unstage File -// git reset HEAD 'filename' +// Stage File: +// git add -- 'filename' +// Unstage File: +// git reset HEAD 'filename' // // The 'Stage File' and 'Unstage File' lines are actions i.e they group up a set // of command logs (typically there's only one command under an action but there may be more). diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 5a3bb653a..213f2e2ae 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -2,14 +2,9 @@ package gui import ( "github.com/jesseduffield/lazygit/pkg/gui/controllers" + "github.com/jesseduffield/lazygit/pkg/gui/types" ) -// TODO: do we need this? -func (gui *Gui) onCommitFileFocus() error { - gui.escapeLineByLinePanel() - return nil -} - func (gui *Gui) commitFilesRenderToMain() error { node := gui.State.Contexts.CommitFiles.GetSelected() if node == nil { @@ -23,16 +18,16 @@ func (gui *Gui) commitFilesRenderToMain() error { cmdObj := gui.git.WorkingTree.ShowFileDiffCmdObj(from, to, reverse, node.GetPath(), false) task := NewRunPtyTask(cmdObj.GetCmd()) - mainContext := gui.State.Contexts.Normal + pair := gui.normalMainContextPair() if node.File != nil { - mainContext = gui.State.Contexts.PatchBuilding + pair = gui.patchBuildingMainContextPair() } return gui.refreshMainViews(refreshMainOpts{ + pair: pair, main: &viewUpdateOpts{ - title: "Patch", - task: task, - context: mainContext, + title: gui.Tr.Patch, + task: task, }, secondary: gui.secondaryPatchPanelUpdateOpts(), }) @@ -46,33 +41,11 @@ func (gui *Gui) SwitchToCommitFilesContext(opts controllers.SwitchToCommitFilesC gui.State.Contexts.CommitFiles.SetParentContext(opts.Context) gui.State.Contexts.CommitFiles.SetWindowName(opts.Context.GetWindowName()) - if err := gui.refreshCommitFilesContext(); err != nil { + if err := gui.c.Refresh(types.RefreshOptions{ + Scope: []types.RefreshableView{types.COMMIT_FILES}, + }); err != nil { return err } return gui.c.PushContext(gui.State.Contexts.CommitFiles) } - -func (gui *Gui) refreshCommitFilesContext() error { - ref := gui.State.Contexts.CommitFiles.GetRef() - to := ref.RefName() - from, reverse := gui.State.Modes.Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) - - files, err := gui.git.Loaders.CommitFiles.GetFilesInDiff(from, to, reverse) - if err != nil { - return gui.c.Error(err) - } - gui.State.Model.CommitFiles = files - gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.SetTree() - - return gui.c.PostRefreshUpdate(gui.State.Contexts.CommitFiles) -} - -func (gui *Gui) getSelectedCommitFileName() string { - node := gui.State.Contexts.CommitFiles.GetSelected() - if node == nil { - return "" - } - - return node.Path -} diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 126fac3a7..ee40b927a 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -25,8 +25,6 @@ func (gui *Gui) onCommitFocus() error { }) } - gui.escapeLineByLinePanel() - return nil } @@ -41,6 +39,7 @@ func (gui *Gui) branchCommitsRenderToMain() error { } return gui.refreshMainViews(refreshMainOpts{ + pair: gui.normalMainContextPair(), main: &viewUpdateOpts{ title: "Patch", task: task, @@ -49,6 +48,19 @@ func (gui *Gui) branchCommitsRenderToMain() error { }) } +func (gui *Gui) secondaryPatchPanelUpdateOpts() *viewUpdateOpts { + if gui.git.Patch.PatchManager.Active() { + patch := gui.git.Patch.PatchManager.RenderAggregatedPatchColored(false) + + return &viewUpdateOpts{ + task: NewRenderStringWithoutScrollTask(patch), + title: gui.Tr.CustomPatch, + } + } + + return nil +} + func (gui *Gui) refForLog() string { bisectInfo := gui.git.Bisect.GetInfo() gui.State.Model.BisectInfo = bisectInfo diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index 4177a689b..86ae41812 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/theme" @@ -221,25 +220,21 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error { bindings := []*types.Binding{ { ViewName: "confirmation", - Contexts: []string{string(context.CONFIRMATION_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.Confirm), Handler: onConfirm, }, { ViewName: "confirmation", - Contexts: []string{string(context.CONFIRMATION_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.ConfirmAlt1), Handler: onConfirm, }, { ViewName: "confirmation", - Contexts: []string{string(context.CONFIRMATION_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.Return), Handler: gui.wrappedConfirmationFunction(opts.HandleClose), }, { ViewName: "confirmation", - Contexts: []string{string(context.CONFIRMATION_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.TogglePanel), Handler: func() error { if len(gui.State.Suggestions) > 0 { @@ -250,25 +245,21 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error { }, { ViewName: "suggestions", - Contexts: []string{string(context.SUGGESTIONS_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.Confirm), Handler: onSuggestionConfirm, }, { ViewName: "suggestions", - Contexts: []string{string(context.SUGGESTIONS_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.ConfirmAlt1), Handler: onSuggestionConfirm, }, { ViewName: "suggestions", - Contexts: []string{string(context.SUGGESTIONS_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.Return), Handler: gui.wrappedConfirmationFunction(opts.HandleClose), }, { ViewName: "suggestions", - Contexts: []string{string(context.SUGGESTIONS_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.TogglePanel), Handler: func() error { return gui.replaceContext(gui.State.Contexts.Confirmation) }, }, diff --git a/pkg/gui/context.go b/pkg/gui/context.go index f08acec06..e4719ab13 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -1,8 +1,6 @@ package gui import ( - "errors" - "fmt" "sort" "strings" @@ -28,24 +26,6 @@ func (gui *Gui) popupViewNames() []string { }) } -func (gui *Gui) currentContextKeyIgnoringPopups() types.ContextKey { - gui.State.ContextManager.RLock() - defer gui.State.ContextManager.RUnlock() - - stack := gui.State.ContextManager.ContextStack - - for i := range stack { - reversedIndex := len(stack) - 1 - i - context := stack[reversedIndex] - kind := stack[reversedIndex].GetKind() - if kind != types.TEMPORARY_POPUP && kind != types.PERSISTENT_POPUP { - return context.GetKey() - } |