Skip to content

Commit

Permalink
Add some more keybindings
Browse files Browse the repository at this point in the history
Requested here:
#107 (comment)
  • Loading branch information
walles committed Nov 28, 2022
1 parent 1b0a214 commit 56419b0
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions m/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ Miscellaneous
Moving around
-------------
* Arrow keys
* SPACE moves down a page
* 'g' for going to a specific line number
* Left / right can be used to hide / show line numbers
* CTRL-p moves to the previous line
* CTRL-n moves to the next line
* 'g' for going to a specific line number
* PageUp / 'b' and PageDown / 'f'
* SPACE moves down a page
* Home and End for start / end of the document
* < to go to the start of the document
* > / 'G' to go to the end of the document
* < / ALT-< to go to the start of the document
* > / ALT-> / 'G' to go to the end of the document
* 'h', 'l' for left and right (as in vim)
* Half page 'u'p / 'd'own, or CTRL-u / CTRL-d
* RETURN moves down one line
Expand Down Expand Up @@ -319,12 +321,16 @@ func (p *Pager) onRune(char rune) {
case '=':
p.ShowStatusBar = !p.ShowStatusBar

case 'k', 'y':
// '\x10' = CTRL-p, should scroll up one line.
// Ref: https://github.com/walles/moar/issues/107#issuecomment-1328354080
case 'k', 'y', '\x10':
// Clipping is done in _Redraw()
p.scrollPosition = p.scrollPosition.PreviousLine(1)
p.handleScrolledUp()

case 'j', 'e':
// '\x0e' = CTRL-n, should scroll down one line.
// Ref: https://github.com/walles/moar/issues/107#issuecomment-1328354080
case 'j', 'e', '\x0e':
// Clipping is done in _Redraw()
p.scrollPosition = p.scrollPosition.NextLine(1)
p.handleScrolledDown()
Expand All @@ -337,11 +343,15 @@ func (p *Pager) onRune(char rune) {
// vim left
p.moveRight(-16)

case '<':
// '≤' = ALT-< on my MacBook, should work like '<'
// Ref: https://github.com/walles/moar/issues/107#issuecomment-1328354080
case '<', '≤':
p.scrollPosition = newScrollPosition("Pager scroll position")
p.handleScrolledUp()

case '>', 'G':
// '≤' = ALT-> on my MacBook, should work like '<'
// Ref: https://github.com/walles/moar/issues/107#issuecomment-1328354080
case '>', '≥', 'G':
p.scrollToEnd()

case 'f', ' ':
Expand Down

0 comments on commit 56419b0

Please sign in to comment.