func (p *pager) pageUp() bool {
	_, viewHeight := termbox.Size()
	if p.scrollY > viewHeight {
		p.scrollY -= viewHeight
		return true
	} else if p.scrollY > 0 {
		p.scrollY = 0
		return true
	}
	return false
}
pageUp pans the pager's viewport up by a full page, without exceeding the
underlying cell buffer document's boundaries.
package main
import termbox "github.com/nsf/termbox-go"
type pager struct {
	scrollX int
	scrollY int
	doc     cellbuf
}
func (p pager) draw() error {
	termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
	width, height := termbox.Size()
	var centerOffset int
	for y := 0; y < height; y++ {
		for x := 0; x < p.doc.width; x++ {
			index := (y+p.scrollY)*p.doc.width + x
			if index >= len(p.doc.cells) || index <= 0 {
				continue
			}
			cell := p.doc.cells[index]
			if width > p.doc.width {
				centerOffset = (width - p.doc.width) / 2
			}
			termbox.SetCell(x+p.scrollX+centerOffset, y, cell.Ch, cell.Fg, cell.Bg)
		}
	}
	return termbox.Flush()
}
func (p *pager) scrollDown() bool {
	if p.scrollY < p.maxScrollY() {
		p.scrollY++
		return true
	}
	return false
}
func (p *pager) scrollUp() bool {
	if p.scrollY > 0 {
		p.scrollY--
		return true
	}
	return false
}
func (p *pager) scrollLeft() bool {
	if p.scrollX < 0 {
		p.scrollX++
		return true
	}
	return false
}
func (p *pager) scrollRight() bool {
	if p.scrollX > -p.maxScrollX() {
		p.scrollX--
		return true
	}
	return false
}
func (p *pager) pageDown() bool {
	_, viewHeight := termbox.Size()
	if p.scrollY < p.maxScrollY() {
		p.scrollY += viewHeight
		return true
	}
	return false
}