1
1
mirror of https://github.com/walles/moar.git synced 2024-11-27 01:05:23 +03:00

Support moving to top / bottom

This commit is contained in:
Johan Walles 2019-06-13 06:14:41 +02:00
parent 74d4d26112
commit a14ecc3168
2 changed files with 15 additions and 0 deletions

View File

@ -77,6 +77,13 @@ func (p *_Pager) _OnKey(key tcell.Key) {
case tcell.KeyDown:
// Clipping is done in _AddLines()
p.firstLineOneBased++
case tcell.KeyHome:
p.firstLineOneBased = 1
case tcell.KeyEnd:
p.firstLineOneBased = p.reader.LineCount() + 1
}
}
@ -84,6 +91,10 @@ func (p *_Pager) _OnRune(char rune) {
switch char {
case 'q':
p._Quit()
case '<', 'g':
p.firstLineOneBased = 1
case '>', 'G':
p.firstLineOneBased = p.reader.LineCount() + 1
}
}

View File

@ -52,6 +52,10 @@ func NewReaderFromFilename(filename string) (*_Reader, error) {
return NewReaderFromStream(stream)
}
func (r *_Reader) LineCount() int {
return len(r.lines)
}
func (r *_Reader) GetLines(firstLineOneBased int, wantedLineCount int) *Lines {
if firstLineOneBased < 1 {
firstLineOneBased = 1