tableview.go
func (l *TableView) EnsureRowVisible() {
	length := l.rowCount

	hgt := l.height - 3

	if length <= hgt || l.selectedRow == -1 {
		return
	}

	diff := l.selectedRow - l.topRow
	if diff >= 0 && diff < hgt {
		return
	}

	if diff < 0 {
		l.topRow = l.selectedRow
	} else {
		top := l.selectedRow - hgt + 1
		if length-top > hgt {
			l.topRow = top
		} else {
			l.topRow = length - hgt
		}
	}
}
func (l *TableView) EnsureRowVisible() {
	length := l.rowCount

	hgt := l.height - 3

	if length <= hgt || l.selectedRow == -1 {
		return
	}

	diff := l.selectedRow - l.topRow
	if diff >= 0 && diff < hgt {
		return
	}

	if diff < 0 {
		l.topRow = l.selectedRow
	} else {
		top := l.selectedRow - hgt + 1
		if length-top > hgt {
			l.topRow = top
		} else {
			l.topRow = length - hgt
		}
	}
}
func ( l * TableView ) EnsureRowVisible ( ) { length := l . rowCount hgt := l . height - 3 if length <= hgt || l . selectedRow == - 1 { return } diff := l . selectedRow - l . topRow if diff >= 0 && diff < hgt { return } if diff < 0 { l . topRow = l . selectedRow } else { top := l . selectedRow - hgt + 1 if length - top > hgt { l . topRow = top } else { l . topRow = length - hgt } } }
// EnsureRowVisible scrolls the table vertically
// to make the currently selected row visible
EnsureRowVisible scrolls the table vertically to make the currently selected row visible