From ee4ed1bad5c7bb2d75325b0dc73aa285640ea808 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 25 Aug 2020 19:01:22 -0400 Subject: [PATCH] Keybindings for jumping to the top and the bottom of the pager --- ui/pager.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/pager.go b/ui/pager.go index adcafa1..8a5e482 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -230,6 +230,16 @@ func pagerUpdate(msg tea.Msg, m pagerModel) (pagerModel, tea.Cmd) { m.state = pagerStateBrowse return m, nil } + case "home", "g": + m.viewport.GotoTop() + if m.viewport.HighPerformanceRendering { + cmds = append(cmds, viewport.Sync(m.viewport)) + } + case "end", "G": + m.viewport.GotoBottom() + if m.viewport.HighPerformanceRendering { + cmds = append(cmds, viewport.Sync(m.viewport)) + } case "m": isStashed := m.currentDocument.markdownType == stashedMarkdown || m.currentDocument.markdownType == convertedMarkdown @@ -455,21 +465,24 @@ func pagerSetNoteView(b *strings.Builder, m pagerModel) { func pagerHelpView(m pagerModel, width int) (s string) { col1 := [...]string{ + "g/home go to top", + "G/end go to bottom", + "", "m set memo", "esc back to files", "q quit", } if m.currentDocument.markdownType != stashedMarkdown { - col1[0] = "s stash this document" + col1[4] = "s stash this document" } s += "\n" s += "k/↑ up " + col1[0] + "\n" s += "j/↓ down " + col1[1] + "\n" s += "j/↓ down " + col1[2] + "\n" - s += "b/pgup page up\n" - s += "f/pgdn page down\n" - s += "u ½ page up\n" + s += "b/pgup page up " + col1[3] + "\n" + s += "f/pgdn page down " + col1[4] + "\n" + s += "u ½ page up " + col1[5] + "\n" s += "d ½ page down" s = indent(s, 2)