Skip to content

Commit

Permalink
feat(reader): Add minimal content display in reading pane
Browse files Browse the repository at this point in the history
  • Loading branch information
bow committed Mar 5, 2024
1 parent 3e6dff7 commit 05cc10f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
10 changes: 10 additions & 0 deletions internal/reader/ui/entries_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (ep *entriesPane) refreshEntries() {
}

for _, cell := range rowf(entry) {
cell.SetReference(entry)
addCell(cell)
}

Expand All @@ -70,6 +71,15 @@ func (ep *entriesPane) refreshEntries() {

func (ep *entriesPane) initTable() {
table := tview.NewTable().SetSelectable(true, false)

table.SetSelectedFunc(
func(row, column int) {
entry, ok := table.GetCell(row, column).GetReference().(*entity.Entry)
if ok {
ep.readingPane.setEntry(entry)
}
},
)
ep.Table = *table
}

Expand Down
19 changes: 16 additions & 3 deletions internal/reader/ui/reading_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
package ui

import (
"github.com/bow/neon/internal/entity"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)

type readingPane struct {
tview.Box
*tview.TextView

theme *Theme
lang *Lang
Expand All @@ -24,8 +25,8 @@ func newReadingPane(theme *Theme, lang *Lang, narrowBranchPoint int) *readingPan

narrowBranchPoint: narrowBranchPoint,
}
box := tview.NewBox()
rp.Box = *box

rp.TextView = tview.NewTextView()

focusf, unfocusf := rp.makeDrawFuncs()
rp.SetDrawFunc(unfocusf)
Expand All @@ -35,6 +36,18 @@ func newReadingPane(theme *Theme, lang *Lang, narrowBranchPoint int) *readingPan
return &rp
}

func (rp *readingPane) setEntry(entry *entity.Entry) {
if content := entry.Content; content != nil {
rp.SetText(*content)
return
}
if url := entry.URL; url != nil {
rp.SetText(*url)
return
}
rp.SetText("<no-content>")
}

func (rp *readingPane) makeDrawFuncs() (focusf, unfocusf drawFunc) {

titleUF, titleF := fmtPaneTitle(rp.lang.readingPaneTitle)
Expand Down

0 comments on commit 05cc10f

Please sign in to comment.