MCPcopy
hub / github.com/charmbracelet/glow / helpView

Method helpView

ui/stashhelp.go:83–160  ·  view source on GitHub ↗

helpView returns either the mini or full help view depending on the state of the model, as well as the total height of the help view.

()

Source from the content-addressed store, hash-verified

81// helpView returns either the mini or full help view depending on the state of
82// the model, as well as the total height of the help view.
83func (m stashModel) helpView() (string, int) {
84 numDocs := len(m.getVisibleMarkdowns())
85
86 // Help for when we're filtering
87 if m.filterState == filtering {
88 var h []string
89
90 switch numDocs {
91 case 0:
92 h = []string{"enter/esc", "cancel"}
93 case 1:
94 h = []string{"enter", "open", "esc", "cancel"}
95 default:
96 h = []string{"enter", "confirm", "esc", "cancel", "ctrl+j/ctrl+k ↑/↓", "choose"}
97 }
98
99 return m.renderHelp(h)
100 }
101
102 var (
103 navHelp []string
104 filterHelp []string
105 selectionHelp []string
106 editHelp []string
107 sectionHelp []string
108 appHelp []string
109 )
110
111 if numDocs > 0 && m.showFullHelp {
112 navHelp = []string{"enter", "open", "j/k ↑/↓", "choose"}
113 }
114
115 if len(m.sections) > 1 {
116 if m.showFullHelp {
117 navHelp = append(navHelp, "tab/shift+tab", "section")
118 } else {
119 navHelp = append(navHelp, "tab", "section")
120 }
121 }
122
123 if m.paginator().TotalPages > 1 {
124 navHelp = append(navHelp, "h/l ←/→", "page")
125 }
126
127 // If we're browsing a filtered set
128 if m.filterApplied() {
129 filterHelp = []string{"/", "edit search", "esc", "clear filter"}
130 } else {
131 filterHelp = []string{"/", "find"}
132 }
133
134 // If there are errors
135 if m.err != nil {
136 appHelp = append(appHelp, "!", "errors")
137 }
138
139 appHelp = append(appHelp, "r", "refresh")
140

Callers 2

updatePaginationMethod · 0.95
viewMethod · 0.95

Calls 4

getVisibleMarkdownsMethod · 0.95
renderHelpMethod · 0.95
paginatorMethod · 0.95
filterAppliedMethod · 0.95

Tested by

no test coverage detected