diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-05-18 15:29:37 +0200 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-05-20 12:58:32 +1000 |
commit | 64b2685c2dfc34a5cb7f2870e06d649339cc3ccf (patch) | |
tree | dda795b927abdd65852e0376b93cf5a3d98a9a42 /pkg | |
parent | 7d4bfb6621163244b5467ab6e6c40571726d7c81 (diff) |
Visualize the "ignore whitespace" state in the subtitle of the diff view
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/controllers/commits_files_controller.go | 5 | ||||
-rw-r--r-- | pkg/gui/controllers/files_controller.go | 15 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/diff_helper.go | 13 | ||||
-rw-r--r-- | pkg/gui/controllers/local_commits_controller.go | 5 | ||||
-rw-r--r-- | pkg/gui/controllers/stash_controller.go | 5 | ||||
-rw-r--r-- | pkg/gui/controllers/sub_commits_controller.go | 5 | ||||
-rw-r--r-- | pkg/gui/main_panels.go | 2 | ||||
-rw-r--r-- | pkg/gui/types/rendering.go | 3 | ||||
-rw-r--r-- | pkg/i18n/english.go | 2 |
9 files changed, 38 insertions, 17 deletions
diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index b7f53ec69..e4cf18ffc 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -126,8 +126,9 @@ func (self *CommitFilesController) GetOnRenderToMain() func() error { return self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: pair, Main: &types.ViewUpdateOpts{ - Title: self.c.Tr.Patch, - Task: task, + Title: self.c.Tr.Patch, + SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(), + Task: task, }, Secondary: secondaryPatchPanelUpdateOpts(self.c), }) diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 65fd16891..2876f97fb 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -174,8 +174,9 @@ func (self *FilesController) GetOnRenderToMain() func() error { return self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ - Title: self.c.Tr.DiffTitle, - Task: types.NewRenderStringTask(self.c.Tr.NoChangedFiles), + Title: self.c.Tr.DiffTitle, + SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(), + Task: types.NewRenderStringTask(self.c.Tr.NoChangedFiles), }, }) } @@ -209,8 +210,9 @@ func (self *FilesController) GetOnRenderToMain() func() error { refreshOpts := types.RefreshMainOpts{ Pair: pair, Main: &types.ViewUpdateOpts{ - Task: types.NewRunPtyTask(cmdObj.GetCmd()), - Title: title, + Task: types.NewRunPtyTask(cmdObj.GetCmd()), + SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(), + Title: title, }, } @@ -223,8 +225,9 @@ func (self *FilesController) GetOnRenderToMain() func() error { } refreshOpts.Secondary = &types.ViewUpdateOpts{ - Title: title, - Task: types.NewRunPtyTask(cmdObj.GetCmd()), + Title: title, + SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(), + Task: types.NewRunPtyTask(cmdObj.GetCmd()), } } diff --git a/pkg/gui/controllers/helpers/diff_helper.go b/pkg/gui/controllers/helpers/diff_helper.go index 701df93cd..8d18be2bf 100644 --- a/pkg/gui/controllers/helpers/diff_helper.go +++ b/pkg/gui/controllers/helpers/diff_helper.go @@ -59,8 +59,9 @@ func (self *DiffHelper) RenderDiff() error { return self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ - Title: "Diff", - Task: task, + Title: "Diff", + SubTitle: self.IgnoringWhitespaceSubTitle(), + Task: task, }, }) } @@ -112,3 +113,11 @@ func (self *DiffHelper) WithDiffModeCheck(f func() error) error { return f() } + +func (self *DiffHelper) IgnoringWhitespaceSubTitle() string { + if self.c.State().GetIgnoreWhitespaceInDiffView() { + return self.c.Tr.IgnoreWhitespaceDiffViewSubTitle + } + + return "" +} diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index d3dbff9d4..76d9afc20 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -176,8 +176,9 @@ func (self *LocalCommitsController) GetOnRenderToMain() func() error { return self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ - Title: "Patch", - Task: task, + Title: "Patch", + SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(), + Task: task, }, Secondary: secondaryPatchPanelUpdateOpts(self.c), }) diff --git a/pkg/gui/controllers/stash_controller.go b/pkg/gui/controllers/stash_controller.go index e308abade..0dac18f15 100644 --- a/pkg/gui/controllers/stash_controller.go +++ b/pkg/gui/controllers/stash_controller.go @@ -74,8 +74,9 @@ func (self *StashController) GetOnRenderToMain() func() error { return self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ - Title: "Stash", - Task: task, + Title: "Stash", + SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(), + Task: task, }, }) }) diff --git a/pkg/gui/controllers/sub_commits_controller.go b/pkg/gui/controllers/sub_commits_controller.go index e887b29d6..485d49820 100644 --- a/pkg/gui/controllers/sub_commits_controller.go +++ b/pkg/gui/controllers/sub_commits_controller.go @@ -46,8 +46,9 @@ func (self *SubCommitsController) GetOnRenderToMain() func() error { return self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ - Title: "Commit", - Task: task, + Title: "Commit", + SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(), + Task: task, }, }) }) diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index e7c87c5e5..d3418b628 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -66,6 +66,8 @@ func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Contex view.Title = opts.Title } + view.Subtitle = opts.SubTitle + if err := gui.runTaskForView(view, opts.Task); err != nil { gui.c.Log.Error(err) return nil diff --git a/pkg/gui/types/rendering.go b/pkg/gui/types/rendering.go index b4e7bedcb..7a2f698ad 100644 --- a/pkg/gui/types/rendering.go +++ b/pkg/gui/types/rendering.go @@ -21,7 +21,8 @@ type MainViewPairs struct { } type ViewUpdateOpts struct { - Title string + Title string + SubTitle string Task UpdateTask } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index c1d0b6c0c..7f79cf077 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -481,6 +481,7 @@ type TranslationSet struct { RandomTip string SelectParentCommitForMerge string ToggleWhitespaceInDiffView string + IgnoreWhitespaceDiffViewSubTitle string IgnoringWhitespaceInDiffView string ShowingWhitespaceInDiffView string IgnoreWhitespaceNotSupportedHere string @@ -1153,6 +1154,7 @@ func EnglishTranslationSet() TranslationSet { RandomTip: "Random Tip", SelectParentCommitForMerge: "Select parent commit for merge", ToggleWhitespaceInDiffView: "Toggle whether or not whitespace changes are shown in the diff view", + IgnoreWhitespaceDiffViewSubTitle: "(ignoring whitespace)", IgnoringWhitespaceInDiffView: "Whitespace will be ignored in the diff view", ShowingWhitespaceInDiffView: "Whitespace will be shown in the diff view", IgnoreWhitespaceNotSupportedHere: "Ignoring whitespace is not supported in this view", |