Skip to content

Commit

Permalink
Don't show stash/memo info in pager help for news
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Oct 19, 2020
1 parent 3b06ccb commit 186d07d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ui/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,11 @@ func (m pagerModel) setNoteView(b *strings.Builder) {

func (m pagerModel) helpView() (s string) {
memoOrStash := "m set memo"
log.Println(m.currentDocument.markdownType)
if m.authStatus == authOK && m.currentDocument.markdownType == localMarkdown {
memoOrStash = "s stash this document"
}

col1 := [...]string{
col1 := []string{
"g/home go to top",
"G/end go to bottom",
"",
Expand All @@ -474,13 +473,21 @@ func (m pagerModel) helpView() (s string) {
"q quit",
}

if m.currentDocument.markdownType == newsMarkdown {
deleteFromStringSlice(col1, 3)
}

s += "\n"
s += "k/↑ up " + col1[0] + "\n"
s += "j/↓ down " + col1[1] + "\n"
s += "b/pgup page up " + col1[2] + "\n"
s += "f/pgdn page down " + col1[3] + "\n"
s += "u ½ page up " + col1[4] + "\n"
s += "d ½ page down " + col1[5]
s += "d ½ page down "

if len(col1) > 5 {
s += col1[5]
}

s = indent(s, 2)

Expand Down Expand Up @@ -557,3 +564,12 @@ func glamourRender(m pagerModel, markdown string) (string, error) {

return content, nil
}

// ETC

// Note: this runs in linear time; O(n).
func deleteFromStringSlice(a []string, i int) []string {
copy(a[i:], a[i+1:])
a[len(a)-1] = ""
return a[:len(a)-1]
}

0 comments on commit 186d07d

Please sign in to comment.