Skip to content

Commit

Permalink
refactor(reader): Move drawfunc-setting functions to newFeedsPane
Browse files Browse the repository at this point in the history
  • Loading branch information
bow committed Dec 26, 2023
1 parent d6db0e5 commit bb7b676
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 9 additions & 7 deletions internal/reader/feeds_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ func newFeedsPane(theme *Theme) *feedsPane {

fp := feedsPane{theme: theme}
fp.setupNavTree()
fp.setupDrawFunc()

focusf, unfocusf := fp.makeDrawFuncs()
fp.SetDrawFunc(unfocusf)
fp.SetFocusFunc(func() { fp.SetDrawFunc(focusf) })
fp.SetBlurFunc(func() { fp.SetDrawFunc(unfocusf) })

return &fp
}

func (fp *feedsPane) setupDrawFunc() {
func (fp *feedsPane) makeDrawFuncs() (focusf, unfocusf drawFunc) {

var titleUF, titleF string
if fp.theme.FeedsPaneTitle != "" {
Expand Down Expand Up @@ -73,12 +77,10 @@ func (fp *feedsPane) setupDrawFunc() {
}
}

focusf := drawf(true)
ufocusf := drawf(false)
focusf = drawf(true)
unfocusf = drawf(false)

fp.SetDrawFunc(ufocusf)
fp.SetFocusFunc(func() { fp.SetDrawFunc(focusf) })
fp.SetBlurFunc(func() { fp.SetDrawFunc(ufocusf) })
return focusf, unfocusf
}

func (fp *feedsPane) setupNavTree() {
Expand Down
2 changes: 2 additions & 0 deletions internal/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Reader struct {
focusStack tview.Primitive
}

type drawFunc func(screen tcell.Screen, x int, y int, w int, h int) (ix int, iy int, iw int, ih int)

type Builder struct {
ctx context.Context
addr string
Expand Down

0 comments on commit bb7b676

Please sign in to comment.