pager
minimal pager in Go that can be used with any data type
Summary
| Latest Version | Unknown |
|---|---|
| License | Unknown |
| CI Status | Failing |
| Stars | 1 |
| Forks | 0 |
| Open Issues | 0 |
| Last Commit | 2018-10-30 |
| Downloads | 0 |
| Last Indexed | 2026-08-04 04:53 |
Installation
nimble install pager
choosenim install pager
git clone https://gitlab.com/metakeule/pager
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| pager | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://gitlab.com/metakeule/pager |
|---|---|
| Homepage | https://gitlab.com/metakeule/pager |
| Registry Source | gitlab |
README
pager
pager provides a simple data neutral paging solution for Go.
- This package does not depend on external packages.
- All versions of Go are supported.
Status
Stable
Usage
package main
import (
"fmt"
"github.com/metakeule/pager"
)
var data = []string{"one", "two", "three", "four", "five", "six"}
func print(pg pager.Pager) {
from, to, selected := pg.Indexes()
// we got data
if from > -1 {
for i, line := range data[from:to] {
prefix := " "
if i == selected {
prefix = "> "
}
fmt.Println(prefix + line)
}
}
}
func main() {
pg := pager.New(3, len(data), pager.PreSelect(5))
// do the paging stuff here
// when height or data changes, create a new pager
pg.Prev()
// print the paged data
print(pg)
// Output:
// four
// > five
// six
}
There are three display variants available: - FixPage (default) - Top - Bottom
Documentation
see http://godoc.org/github.com/metakeule/pager
Benchmarks
BenchmarkFixPage-4 26.7 ns/op 0 B/op 0 allocs/op
BenchmarkTop-4 9.08 ns/op 0 B/op 0 allocs/op
BenchmarkBottom-4 8.17 ns/op 0 B/op 0 allocs/op
BenchmarkNext-4 4.04 ns/op 0 B/op 0 allocs/op
BenchmarkPrev-4 4.54 ns/op 0 B/op 0 allocs/op
BenchmarkPageDown-4 20.6 ns/op 0 B/op 0 allocs/op
BenchmarkPageUp-4 21.3 ns/op 0 B/op 0 allocs/op
