Browse Source

Base List PageUp and PageDown on the number of items displayed

tablepad
Trevor Slocum 1 year ago
parent
commit
f269c326f6
  1. 1
      CHANGELOG
  2. 4
      go.mod
  3. 8
      go.sum
  4. 13
      list.go

1
CHANGELOG

@ -2,6 +2,7 @@ v1.4.9 (WIP)
- Add InputField.GetCursorPosition and InputField.SetCursorPosition
- Add Table.Sort, Table.SetSortFunc and Table.SetSortClicked
- Add TextView.SetReindexBuffer
- Base List PageUp and PageDown on the number of items displayed
- Upgrade tcell to v2: includes strikethrough support
v1.4.8 (2020-08-11)

4
go.mod

@ -3,10 +3,10 @@ module gitlab.com/tslocum/cview
go 1.12
require (
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200908121250-0c5e1e1720f1
github.com/lucasb-eyer/go-colorful v1.0.3
github.com/mattn/go-runewidth v0.0.9
github.com/rivo/uniseg v0.1.0
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a // indirect
golang.org/x/sys v0.0.0-20200908134130-d2e65c121b96 // indirect
)

8
go.sum

@ -1,8 +1,8 @@
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b h1:j9fvrLkgzxR1S/ZWI6fbw8hjNxU5/lxnVXBX2tuYGVA=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200908121250-0c5e1e1720f1 h1:ec/DAe6ms4fBkpSHObVDYU4N/w6Swd929zkN01g8ozY=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200908121250-0c5e1e1720f1/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
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/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
@ -15,8 +15,8 @@ gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a/go.mod h1:HfB7qAhH
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6 h1:DvY3Zkh7KabQE/kfzMvYvKirSiguP9Q/veMtkYyf0o8=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a h1:i47hUS795cOydZI4AwJQCKXOr4BvxzvikwDoDtHhP2Y=
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200908134130-d2e65c121b96 h1:gJciq3lOg0eS9fSZJcoHfv7q1BfC6cJfnmSSKL1yu3Q=
golang.org/x/sys v0.0.0-20200908134130-d2e65c121b96/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

13
list.go

@ -614,6 +614,14 @@ func (l *List) Transform(tr Transformation) {
func (l *List) transform(tr Transformation) {
var decreasing bool
pageItems := l.height
if l.showSecondaryText {
pageItems /= 2
}
if pageItems < 1 {
pageItems = 1
}
switch tr {
case TransformFirstItem:
l.currentItem = 0
@ -627,10 +635,11 @@ func (l *List) transform(tr Transformation) {
case TransformNextItem:
l.currentItem += 1
case TransformPreviousPage:
l.currentItem -= 5
l.currentItem -= pageItems
decreasing = true
case TransformNextPage:
l.currentItem += 5
l.currentItem += pageItems
l.offset += pageItems
}
for i := 0; i < len(l.items); i++ {

Loading…
Cancel
Save