Skip to content

Commit

Permalink
Cleanup: remove isFocused parameter from GetContentToRender and relat…
Browse files Browse the repository at this point in the history
…ed methods

It became unused in f3eb180.
  • Loading branch information
stefanhaller committed Oct 18, 2024
1 parent 8f3e59b commit f08b3e9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
22 changes: 11 additions & 11 deletions pkg/gui/context/patch_explorer_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewPatchExplorerContext(
func(selectedLineIdx int) error {
ctx.GetMutex().Lock()
defer ctx.GetMutex().Unlock()
ctx.NavigateTo(ctx.c.Context().IsCurrent(ctx), selectedLineIdx)
ctx.NavigateTo(selectedLineIdx)
return nil
}),
)
Expand All @@ -79,15 +79,15 @@ func (self *PatchExplorerContext) GetIncludedLineIndices() []int {
return self.getIncludedLineIndices()
}

func (self *PatchExplorerContext) RenderAndFocus(isFocused bool) {
self.setContent(isFocused)
func (self *PatchExplorerContext) RenderAndFocus() {
self.setContent()

self.FocusSelection()
self.c.Render()
}

func (self *PatchExplorerContext) Render(isFocused bool) {
self.setContent(isFocused)
func (self *PatchExplorerContext) Render() {
self.setContent()

self.c.Render()
}
Expand All @@ -97,8 +97,8 @@ func (self *PatchExplorerContext) Focus() {
self.c.Render()
}

func (self *PatchExplorerContext) setContent(isFocused bool) {
self.GetView().SetContent(self.GetContentToRender(isFocused))
func (self *PatchExplorerContext) setContent() {
self.GetView().SetContent(self.GetContentToRender())
}

func (self *PatchExplorerContext) FocusSelection() {
Expand All @@ -119,19 +119,19 @@ func (self *PatchExplorerContext) FocusSelection() {
view.SetCursorY(endIdx - newOriginY)
}

func (self *PatchExplorerContext) GetContentToRender(isFocused bool) string {
func (self *PatchExplorerContext) GetContentToRender() string {
if self.GetState() == nil {
return ""
}

return self.GetState().RenderForLineIndices(isFocused, self.GetIncludedLineIndices())
return self.GetState().RenderForLineIndices(self.GetIncludedLineIndices())
}

func (self *PatchExplorerContext) NavigateTo(isFocused bool, selectedLineIdx int) {
func (self *PatchExplorerContext) NavigateTo(selectedLineIdx int) {
self.GetState().SetLineSelectMode()
self.GetState().SelectLine(selectedLineIdx)

self.RenderAndFocus(isFocused)
self.RenderAndFocus()
}

func (self *PatchExplorerContext) GetMutex() *deadlock.Mutex {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/controllers/helpers/patch_building_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt
return
}

mainContent := context.GetContentToRender(true)
mainContent := context.GetContentToRender()

self.c.Contexts().CustomPatchBuilder.FocusSelection()

Expand Down
4 changes: 2 additions & 2 deletions pkg/gui/controllers/helpers/staging_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) {
mainState := mainContext.GetState()
secondaryState := secondaryContext.GetState()

mainContent := mainContext.GetContentToRender(!secondaryFocused)
secondaryContent := secondaryContext.GetContentToRender(secondaryFocused)
mainContent := mainContext.GetContentToRender()
secondaryContent := secondaryContext.GetContentToRender()

mainContext.GetMutex().Unlock()
secondaryContext.GetMutex().Unlock()
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/controllers/patch_explorer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (self *PatchExplorerController) withRenderAndFocus(f func() error) func() e
return err
}

self.context.RenderAndFocus(self.isFocused())
self.context.RenderAndFocus()
return nil
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/patch_exploring/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (s *State) AdjustSelectedLineIdx(change int) {
s.SelectLine(s.selectedLineIdx + change)
}

func (s *State) RenderForLineIndices(isFocused bool, includedLineIndices []int) string {
func (s *State) RenderForLineIndices(includedLineIndices []int) string {
includedLineIndicesSet := set.NewFromSlice(includedLineIndices)
return s.patch.FormatView(patch.FormatViewOpts{
IncLineIndices: includedLineIndicesSet,
Expand Down
8 changes: 4 additions & 4 deletions pkg/gui/types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ type IPatchExplorerContext interface {
GetState() *patch_exploring.State
SetState(*patch_exploring.State)
GetIncludedLineIndices() []int
RenderAndFocus(isFocused bool)
Render(isFocused bool)
RenderAndFocus()
Render()
Focus()
GetContentToRender(isFocused bool) string
NavigateTo(isFocused bool, selectedLineIdx int)
GetContentToRender() string
NavigateTo(selectedLineIdx int)
GetMutex() *deadlock.Mutex
IsPatchExplorerContext() // used for type switch
}
Expand Down

0 comments on commit f08b3e9

Please sign in to comment.