diff --git a/m/pager.go b/m/pager.go index a5a1cd4..a8a47b8 100644 --- a/m/pager.go +++ b/m/pager.go @@ -25,7 +25,7 @@ func NewPager(r _Reader) *_Pager { func (p *_Pager) _AddFooter() { _, height := p.screen.Size() - for pos, char := range "Press ESC / Return to exit" { + for pos, char := range "Press ESC / Return / q to exit" { p.screen.SetContent(pos, height-1, char, nil, tcell.StyleDefault) } } @@ -50,6 +50,13 @@ func (p *_Pager) _OnKey(key tcell.Key) { } } +func (p *_Pager) _OnRune(char rune) { + switch char { + case 'q': + p._Quit() + } +} + // StartPaging brings up the pager on screen func (p *_Pager) StartPaging() { // This function initially inspired by @@ -77,7 +84,11 @@ func (p *_Pager) StartPaging() { ev := s.PollEvent() switch ev := ev.(type) { case *tcell.EventKey: - p._OnKey(ev.Key()) + if ev.Key() == tcell.KeyRune { + p._OnRune(ev.Rune()) + } else { + p._OnKey(ev.Key()) + } case *tcell.EventResize: // We'll be implicitly redrawn just by taking another lap in the loop