~chrisppy/beagles

880621c285b8eeca18abc334a79c5e25347005b3 — Chris Palmer 7 months ago 6754a4c
make content pages adhere to config keys
5 files changed, 81 insertions(+), 9 deletions(-)

M go.mod
M go.sum
M ui/actions.go
M ui/content.go
M ui/tree.go
M go.mod => go.mod +3 -2
@@ 2,6 2,8 @@ module git.sr.ht/~chrisppy/beagles

go 1.15

replace gitlab.com/tslocum/cview v1.5.3 => git.sr.ht/~chrisppy/cview v0.0.0-20210214163646-af62019ee3b4

require (
	git.sr.ht/~adnano/go-gemini v0.1.13
	git.sr.ht/~chrisppy/go-barefeed v0.1.0


@@ 10,7 12,7 @@ require (
	git.sr.ht/~sircmpwn/getopt v0.0.0-20201218204720-9961a9c6298f
	github.com/DataDrake/waterlog v1.0.5
	github.com/emersion/go-appdir v1.1.2
	github.com/gdamore/tcell/v2 v2.1.1-0.20201225194624-29bb185874fd
	github.com/gdamore/tcell/v2 v2.1.1-0.20210125004847-19e17097d8fe
	github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7
	github.com/kr/pretty v0.1.0 // indirect
	github.com/mmcdole/gofeed v1.1.0


@@ 19,6 21,5 @@ require (
	gitlab.com/tslocum/cbind v0.1.4
	gitlab.com/tslocum/cview v1.5.3
	go.etcd.io/bbolt v1.3.5
	golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
	gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
)

M go.sum => go.sum +8 -6
@@ 1,5 1,7 @@
git.sr.ht/~adnano/go-gemini v0.1.13 h1:vzKkkVrOzMpfJ1AAeE/PChg0Rw5Zf+9HrnwsgVxXUT4=
git.sr.ht/~adnano/go-gemini v0.1.13/go.mod h1:If1VxEWcZDrRt5FeAFnGTcM2Ud1E3BXs3VJ5rnZWKq0=
git.sr.ht/~chrisppy/cview v0.0.0-20210214163646-af62019ee3b4 h1:CaPuVvHlsqLrP+9+kCUJFe3TE8jPU+0wMCgGVmdlWWE=
git.sr.ht/~chrisppy/cview v0.0.0-20210214163646-af62019ee3b4/go.mod h1:lCEqP/zDhBihNbyiEn59LgOCk09ejefHaS7kNZ57Nmc=
git.sr.ht/~chrisppy/go-barefeed v0.1.0 h1:kyf1sJx4uGLesiXagd4sCP9C8+TPge+y/VxFTX6dI4E=
git.sr.ht/~chrisppy/go-barefeed v0.1.0/go.mod h1:V/4QgRdPISXxrbyn/0YNdrh1qR2PHk8hdcIJsdmJFlQ=
git.sr.ht/~chrisppy/go-opml v1.0.0 h1:Vf7UHZSXCiilzDBhfYT4RHo9ijmwiNkNxhXkyy3GLoM=


@@ 29,8 31,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.0.0-dev h1:34h4ahbtQZ7ndLnAHAdamYk6eQ5W/piK9Vm5/JiYkfQ=
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gdamore/tcell/v2 v2.1.1-0.20201225194624-29bb185874fd h1:66OLuRCaOFojnLK9eB0YTo8CU9AgHtfvBWvLsz/8r+I=
github.com/gdamore/tcell/v2 v2.1.1-0.20201225194624-29bb185874fd/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gdamore/tcell/v2 v2.1.1-0.20210125004847-19e17097d8fe h1:D4zQq/0ep0XCtgkmA+dUvQNYMoiW2+2336rdlAucr10=
github.com/gdamore/tcell/v2 v2.1.1-0.20210125004847-19e17097d8fe/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/golang/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=


@@ 46,6 48,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=


@@ 77,8 81,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
gitlab.com/tslocum/cbind v0.1.4 h1:cbZXPPcieXspk8cShoT6efz7HAT8yMNQcofYWNizis4=
gitlab.com/tslocum/cbind v0.1.4/go.mod h1:RvwYE3auSjBNlCmWeGspzn+jdLUVQ8C2QGC+0nP9ChI=
gitlab.com/tslocum/cview v1.5.3 h1:6OTCtIUp1EkfGeLqQFRHtW8ynMJ66BhoBwuW8oZ84AQ=
gitlab.com/tslocum/cview v1.5.3/go.mod h1:k/eLWRIF3B26VLDgtRRPkjLUXmcCsy+YCSPEAtNQgIY=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=


@@ 99,11 101,11 @@ golang.org/x/sys v0.0.0-20201013132646-2da7054afaeb/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f h1:QdHQnPce6K4XQewki9WNbG5KOROuDzqO3NaYjI1cXJ0=
golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=

M ui/actions.go => ui/actions.go +48 -0
@@ 137,6 137,18 @@ func (i *UI) moveUp(event *tcell.EventKey) *tcell.EventKey {

		i.sub.decrement()
		return nil
	case listContentStatus:
		i.listContent.decrement()
		return nil
	case subContentStatus:
		i.favContent.decrement()
		return nil
	case favContentStatus:
		i.favContent.decrement()
		return nil
	case helpStatus:
		i.helpContent.decrement()
		return nil
	}
	return event
}


@@ 168,6 180,18 @@ func (i *UI) moveDown(event *tcell.EventKey) *tcell.EventKey {

		i.sub.increment()
		return nil
	case listContentStatus:
		i.listContent.increment()
		return nil
	case subContentStatus:
		i.favContent.increment()
		return nil
	case favContentStatus:
		i.favContent.increment()
		return nil
	case helpStatus:
		i.helpContent.increment()
		return nil
	}
	return event
}


@@ 199,6 223,18 @@ func (i *UI) movePageUp(event *tcell.EventKey) *tcell.EventKey {

		i.sub.pageUp()
		return nil
	case listContentStatus:
		i.listContent.pageUp()
		return nil
	case subContentStatus:
		i.favContent.pageUp()
		return nil
	case favContentStatus:
		i.favContent.pageUp()
		return nil
	case helpStatus:
		i.helpContent.pageUp()
		return nil
	}
	return event
}


@@ 230,6 266,18 @@ func (i *UI) movePageDown(event *tcell.EventKey) *tcell.EventKey {

		i.sub.pageDown()
		return nil
	case listContentStatus:
		i.listContent.pageDown()
		return nil
	case subContentStatus:
		i.favContent.pageDown()
		return nil
	case favContentStatus:
		i.favContent.pageDown()
		return nil
	case helpStatus:
		i.helpContent.pageDown()
		return nil
	}
	return event
}

M ui/content.go => ui/content.go +22 -0
@@ 41,6 41,7 @@ func (i *UI) newContent() *content {
	view.SetDynamicColors(true)
	view.SetBackgroundColor(i.Config.Theme.ContentBGColor)
	view.SetTextColor(i.Config.Theme.ContentFGColor)
	view.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { return nil })

	return &content{
		Widget:   view,


@@ 48,6 49,27 @@ func (i *UI) newContent() *content {
		ErrColor: i.Config.Theme.ErrColor,
	}
}
func (w *content) increment() {
	r, c := w.Widget.GetScrollOffset()
	w.Widget.ScrollTo(r+1, c)
}

func (w *content) decrement() {
	r, c := w.Widget.GetScrollOffset()
	w.Widget.ScrollTo(r-1, c)
}

func (w *content) pageUp() {
	r, c := w.Widget.GetScrollOffset()
	s := w.Widget.GetPageSize()
	w.Widget.ScrollTo(r-s, c)
}

func (w *content) pageDown() {
	r, c := w.Widget.GetScrollOffset()
	s := w.Widget.GetPageSize()
	w.Widget.ScrollTo(r+s, c)
}

func (w *content) setDescription(text string, updated *time.Time, isHTML bool) {
	// TODO: Handle gemini content to text

M ui/tree.go => ui/tree.go +0 -1
@@ 46,7 46,6 @@ func (i *UI) newTree() *tree {

	view.SetBackgroundColor(i.Config.Theme.TreeBGColor)
	view.SetGraphicsColor(i.Config.Theme.TreeFGColor)
	view.SetInputCapture(nil)
	node := tui.NewTreeNode("subscriptions")
	node.SetColor(i.Config.Theme.TreeFGColor)