commit
ed41775aa5
@ -79,9 +79,10 @@ Run an example with `go run _examples/{example}.go` or run all of them consecuti
|
|||||||
|
|
||||||
## Uses
|
## Uses
|
||||||
|
|
||||||
- [cjbassi/gotop](https://github.com/cjbassi/gotop)
|
- [go-ethereum/monitorcmd](https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/monitorcmd.go)
|
||||||
- [ethereum/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)
|
||||||
- [mikepea/go-jira-ui](https://github.com/mikepea/go-jira-ui)
|
- [gotop](https://github.com/cjbassi/gotop)
|
||||||
|
- [termeter](https://github.com/atsaki/termeter)
|
||||||
|
|
||||||
## Related Works
|
## Related Works
|
||||||
|
|
||||||
|
@ -49,6 +49,12 @@ func main() {
|
|||||||
case "k", "<Up>":
|
case "k", "<Up>":
|
||||||
l.ScrollUp()
|
l.ScrollUp()
|
||||||
ui.Render(l)
|
ui.Render(l)
|
||||||
|
case "<C-f>":
|
||||||
|
l.PageDown()
|
||||||
|
ui.Render(l)
|
||||||
|
case "<C-b>":
|
||||||
|
l.PageUp()
|
||||||
|
ui.Render(l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,20 +96,26 @@ func (self *List) ScrollDown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *List) PageUp() { // Goes up one whole page.
|
// PageUp scrolls up one whole page.
|
||||||
if int(self.SelectedRow)-self.Inner.Dy() >= 0 {
|
func (self *List) PageUp() {
|
||||||
self.topRow -= uint(self.Inner.Dy())
|
// if on the first 'page'
|
||||||
} else { // If at the first 'page', then go to the top and select the first item.
|
if int(self.SelectedRow)-self.Inner.Dy() < 0 {
|
||||||
|
// go to the top
|
||||||
self.topRow = 0
|
self.topRow = 0
|
||||||
|
} else {
|
||||||
|
self.topRow = uint(MaxInt(int(self.topRow)-self.Inner.Dy(), 0))
|
||||||
}
|
}
|
||||||
self.SelectedRow = self.topRow
|
self.SelectedRow = self.topRow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *List) PageDown() { // Down one whole page
|
// PageDown scolls down one whole page.
|
||||||
if len(self.Rows)-int(self.topRow) > self.Inner.Dy() {
|
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.topRow += uint(self.Inner.Dy())
|
||||||
self.SelectedRow = self.topRow
|
self.SelectedRow = self.topRow
|
||||||
} else { // If at last 'page', then select last item.
|
|
||||||
self.SelectedRow = uint(len(self.Rows) - 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user