diff options
-rw-r--r-- | pkg/gui/branches_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/commit_files_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/diffing.go | 2 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/line_by_line_panel.go | 12 | ||||
-rw-r--r-- | pkg/gui/main_panels.go | 44 | ||||
-rw-r--r-- | pkg/gui/merge_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/reflog_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/remote_branches_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/remotes_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/status_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/tags_panel.go | 2 |
15 files changed, 49 insertions, 37 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 2a87d364c..d79e72b49 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -36,7 +36,7 @@ func (gui *Gui) handleBranchSelect() error { task = gui.createRunPtyTask(cmd) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Log", task: task, diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 3f4285744..5b51dc74e 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -32,7 +32,7 @@ func (gui *Gui) handleCommitFileSelect() error { ) task := gui.createRunPtyTask(cmd) - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Patch", task: task, diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 7952a7304..c98c3f504 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -42,7 +42,7 @@ func (gui *Gui) handleCommitSelect() error { task = gui.createRunPtyTask(cmd) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Patch", task: task, diff --git a/pkg/gui/diffing.go b/pkg/gui/diffing.go index b92323ad4..1da230a0d 100644 --- a/pkg/gui/diffing.go +++ b/pkg/gui/diffing.go @@ -18,7 +18,7 @@ func (gui *Gui) renderDiff() error { ) task := gui.createRunPtyTask(cmd) - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Diff", task: task, diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 1d20f54d9..f9312930c 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -32,7 +32,7 @@ func (gui *Gui) selectFile(alreadySelected bool) error { file := gui.getSelectedFile() if file == nil { - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "", task: gui.createRenderStringTask(gui.Tr.SLocalize("NoChangedFiles")), @@ -74,7 +74,7 @@ func (gui *Gui) selectFile(alreadySelected bool) error { refreshOpts.main.title = gui.Tr.SLocalize("StagedChanges") } - return gui.refreshMain(refreshOpts) + return gui.refreshMainViews(refreshOpts) } func (gui *Gui) refreshFiles() error { diff --git a/pkg/gui/line_by_line_panel.go b/pkg/gui/line_by_line_panel.go index 51adde48a..a70b2e4ff 100644 --- a/pkg/gui/line_by_line_panel.go +++ b/pkg/gui/line_by_line_panel.go @@ -73,7 +73,7 @@ func (gui *Gui) refreshLineByLinePanel(diff string, secondaryDiff string, second SecondaryFocused: secondaryFocused, } - if err := gui.refreshMainView(); err != nil { + if err := gui.refreshMainViewForLineByLine(); err != nil { return false, err } @@ -129,7 +129,7 @@ func (gui *Gui) selectNewHunk(newHunk *patch.PatchHunk) error { state.FirstLineIdx, state.LastLineIdx = state.SelectedLineIdx, state.SelectedLineIdx } - if err := gui.refreshMainView(); err != nil { + if err := gui.refreshMainViewForLineByLine(); err != nil { return err } @@ -169,7 +169,7 @@ func (gui *Gui) handleSelectNewLine(newSelectedLineIdx int) error { state.FirstLineIdx = state.SelectedLineIdx } - if err := gui.refreshMainView(); err != nil { + if err := gui.refreshMainViewForLineByLine(); err != nil { return err } @@ -228,7 +228,7 @@ func (gui *Gui) getSelectedCommitFileName() string { return gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLineIdx].Name } -func (gui *Gui) refreshMainView() error { +func (gui *Gui) refreshMainViewForLineByLine() error { state := gui.State.Panels.LineByLine var includedLineIndices []int @@ -306,7 +306,7 @@ func (gui *Gui) handleToggleSelectRange(g *gocui.Gui, v *gocui.View) error { } state.FirstLineIdx, state.LastLineIdx = state.SelectedLineIdx, state.SelectedLineIdx - return gui.refreshMainView() + return gui.refreshMainViewForLineByLine() } func (gui *Gui) handleToggleSelectHunk(g *gocui.Gui, v *gocui.View) error { @@ -321,7 +321,7 @@ func (gui *Gui) handleToggleSelectHunk(g *gocui.Gui, v *gocui.View) error { state.FirstLineIdx, state.LastLineIdx = selectedHunk.FirstLineIdx, selectedHunk.LastLineIdx() } - if err := gui.refreshMainView(); err != nil { + if err := gui.refreshMainViewForLineByLine(); err != nil { return err } diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 87072406a..d56856f6f 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -14,6 +14,11 @@ type viewUpdateOpts struct { task updateTask } +type coordinates struct { + x int + y int +} + type refreshMainOpts struct { main *viewUpdateOpts secondary *viewUpdateOpts @@ -118,30 +123,37 @@ func (gui *Gui) runTaskForView(viewName string, task updateTask) error { return nil } -func (gui *Gui) refreshMain(opts refreshMainOpts) error { - mainView := gui.getMainView() - secondaryView := gui.getSecondaryView() +func (gui *Gui) refreshMainView(opts *viewUpdateOpts, viewName string) error { + view, err := gui.g.View(viewName) + if err != nil { + gui.Log.Error(err) + return nil + } - if opts.main != nil { - mainView.Title = opts.main.title - mainView.Wrap = !opts.main.noWrap - mainView.Highlight = opts.main.highlight // TODO: see what the default should be + view.Title = opts.title + view.Wrap = !opts.noWrap + view.Highlight = opts.highlight + + if err := gui.runTaskForView("main", opts.task); err != nil { + gui.Log.Error(err) + return nil + } - if err := gui.runTaskForView("main", opts.main.task); err != nil { - gui.Log.Error(err) - return nil + return nil +} + +func (gui *Gui) refreshMainViews(opts refreshMainOpts) error { + if opts.main != nil { + if err := gui.refreshMainView(opts.main, "main"); err != nil { + return err } } gui.splitMainPanel(opts.secondary != nil) if opts.secondary != nil { - secondaryView.Title = opts.secondary.title - secondaryView.Wrap = !opts.secondary.noWrap - mainView.Highlight = opts.main.highlight // TODO: see what the default should be - if err := gui.runTaskForView("secondary", opts.secondary.task); err != nil { - gui.Log.Error(err) - return nil + if err := gui.refreshMainView(opts.secondary, "secondary"); err != nil { + return err } } diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go index bfe3536fe..c23549d39 100644 --- a/pkg/gui/merge_panel.go +++ b/pkg/gui/merge_panel.go @@ -217,7 +217,7 @@ func (gui *Gui) refreshMergePanel() error { panelState := gui.State.Panels.Merging cat, err := gui.catSelectedFile(gui.g) if err != nil { - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "", task: gui.createRenderStringTask(err.Error()), @@ -244,7 +244,7 @@ func (gui *Gui) refreshMergePanel() error { return err } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: gui.Tr.SLocalize("MergeConflictsTitle"), task: gui.createRenderStringWithoutScrollTask(content), diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go index 30d534e06..b588e713d 100644 --- a/pkg/gui/reflog_panel.go +++ b/pkg/gui/reflog_panel.go @@ -30,7 +30,7 @@ func (gui *Gui) handleReflogCommitSelect() error { task = gui.createRunPtyTask(cmd) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Reflog Entry", task: task, diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go index 55027084e..29e199cfc 100644 --- a/pkg/gui/remote_branches_panel.go +++ b/pkg/gui/remote_branches_panel.go @@ -30,7 +30,7 @@ func (gui *Gui) handleRemoteBranchSelect() error { task = gui.createRunCommandTask(cmd) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Remote Branch", task: task, diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go index 2bd3ed1e1..3f11ec47a 100644 --- a/pkg/gui/remotes_panel.go +++ b/pkg/gui/remotes_panel.go @@ -30,7 +30,7 @@ func (gui *Gui) handleRemoteSelect() error { task = gui.createRenderStringTask(fmt.Sprintf("%s\nUrls:\n%s", utils.ColoredString(remote.Name, color.FgGreen), strings.Join(remote.Urls, "\n"))) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Remote", task: task, diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go index cf991385a..1ee2ab26e 100644 --- a/pkg/gui/stash_panel.go +++ b/pkg/gui/stash_panel.go @@ -28,7 +28,7 @@ func (gui *Gui) handleStashEntrySelect() error { task = gui.createRunPtyTask(cmd) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Stash", task: task, diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index 6159907e9..2532cc96c 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -112,7 +112,7 @@ func (gui *Gui) handleStatusSelect() error { magenta.Sprint("Become a sponsor (github is matching all donations for 12 months): https://github.com/sponsors/jesseduffield"), // caffeine ain't free }, "\n\n") - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "", task: gui.createRenderStringTask(dashboardString), diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index dc98c4aed..46c45fd3a 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -30,7 +30,7 @@ func (gui *Gui) handleSubCommitSelect() error { task = gui.createRunPtyTask(cmd) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Commit", task: task, diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go index e5d9cf897..8811e400e 100644 --- a/pkg/gui/tags_panel.go +++ b/pkg/gui/tags_panel.go @@ -28,7 +28,7 @@ func (gui *Gui) handleTagSelect() error { task = gui.createRunCommandTask(cmd) } - return gui.refreshMain(refreshMainOpts{ + return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ title: "Tag", task: task, |