diff --git a/ui/pager.go b/ui/pager.go index 5bab71a..6e5366c 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -304,18 +304,21 @@ func pagerSetNoteView(b *strings.Builder, m pagerModel) { } func pagerHelpView(m pagerModel, width int) (s string) { - col1 := [2]string{ + col1 := [...]string{ "m set memo", - "esc/q back to stash", + "esc back to files", + "q quit", } if m.currentDocument != nil && m.currentDocument.markdownType != stashedMarkdown { col1[0] = col1[1] - col1[1] = "" + col1[1] = col1[2] + col1[2] = "" } 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" diff --git a/ui/ui.go b/ui/ui.go index 4337366..d47a817 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -187,18 +187,28 @@ func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) { // Special cases for the pager case stateShowDocument: - var batch []tea.Cmd - if m.pager.state == pagerStateBrowse { - // If the user is just browing a document, exit the pager. - batch = m.unloadDocument() - } else { - // Otherwise send these key messages through to pager for - // processing + switch m.pager.state { + + // If browsing, these keys have special cases + case pagerStateBrowse: + switch msg.String() { + case "q": + return m, tea.Quit + case "esc": + var batch []tea.Cmd + batch = m.unloadDocument() + return m, tea.Batch(batch...) + } + + // If setting a note send all keys straight through + case pagerStateSetNote: + var batch []tea.Cmd newPagerModel, cmd := pagerUpdate(msg, m.pager) m.pager = newPagerModel batch = append(batch, cmd) + return m, tea.Batch(batch...) } - return m, tea.Batch(batch...) + } return m, tea.Quit