mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 14:14:17 +00:00
Pressing q quits no matter where you are
This commit is contained in:
parent
b31aba3c4e
commit
fc2f05626e
2 changed files with 24 additions and 11 deletions
|
@ -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"
|
||||
|
|
26
ui/ui.go
26
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
|
||||
|
|
Loading…
Reference in a new issue