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:
parent
74d4d26112
commit
a14ecc3168
11
m/pager.go
11
m/pager.go
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user