From 436eb3a261b01958120efdb6178746cfb975e62e Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 31 Jan 2019 19:14:37 -0800 Subject: [PATCH 1/3] Add list page scrolling to list example --- _examples/list.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_examples/list.go b/_examples/list.go index dbbdf75..96810d6 100644 --- a/_examples/list.go +++ b/_examples/list.go @@ -49,6 +49,12 @@ func main() { case "k", "": l.ScrollUp() ui.Render(l) + case "": + l.PageDown() + ui.Render(l) + case "": + l.PageUp() + ui.Render(l) } } } From 31540a46ad19a153d0aef24078fd0b8eb9ffe21d Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 31 Jan 2019 19:15:11 -0800 Subject: [PATCH 2/3] Fix list PageUp scrolling --- widgets/list.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/widgets/list.go b/widgets/list.go index 66274f4..5a25601 100644 --- a/widgets/list.go +++ b/widgets/list.go @@ -96,20 +96,26 @@ func (self *List) ScrollDown() { } } -func (self *List) PageUp() { // Goes up one whole page. - if int(self.SelectedRow)-self.Inner.Dy() >= 0 { - self.topRow -= uint(self.Inner.Dy()) - } else { // If at the first 'page', then go to the top and select the first item. +// PageUp scrolls up one whole page. +func (self *List) PageUp() { + // if on the first 'page' + if int(self.SelectedRow)-self.Inner.Dy() < 0 { + // go to the top self.topRow = 0 + } else { + self.topRow = uint(MaxInt(int(self.topRow)-self.Inner.Dy(), 0)) } self.SelectedRow = self.topRow } -func (self *List) PageDown() { // Down one whole page - if len(self.Rows)-int(self.topRow) > self.Inner.Dy() { +// PageDown scolls down one whole page. +func (self *List) PageDown() { + // if on last 'page' + if len(self.Rows)-int(self.topRow) <= self.Inner.Dy() { + // select last item + self.SelectedRow = uint(len(self.Rows) - 1) + } else { self.topRow += uint(self.Inner.Dy()) self.SelectedRow = self.topRow - } else { // If at last 'page', then select last item. - self.SelectedRow = uint(len(self.Rows) - 1) } } From bbe260b1c36d642bcfeff6855886b48268cc06f8 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 31 Jan 2019 22:04:50 -0800 Subject: [PATCH 3/3] Update readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 296607f..2369db0 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,10 @@ Run an example with `go run _examples/{example}.go` or run all of them consecuti ## Uses -- [cjbassi/gotop](https://github.com/cjbassi/gotop) -- [ethereum/go-ethereum/monitorcmd](https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/monitorcmd.go) -- [mikepea/go-jira-ui](https://github.com/mikepea/go-jira-ui) +- [go-ethereum/monitorcmd](https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/monitorcmd.go) +- [go-jira-ui](https://github.com/mikepea/go-jira-ui) +- [gotop](https://github.com/cjbassi/gotop) +- [termeter](https://github.com/atsaki/termeter) ## Related Works