@@ -3,6 +3,7 @@ package table
33import (
44 "strings"
55
6+ "github.com/charmbracelet/bubbles/help"
67 "github.com/charmbracelet/bubbles/key"
78 "github.com/charmbracelet/bubbles/viewport"
89 tea "github.com/charmbracelet/bubbletea"
@@ -13,6 +14,7 @@ import (
1314// Model defines a state for the table widget.
1415type Model struct {
1516 KeyMap KeyMap
17+ Help help.Model
1618
1719 cols []Column
1820 rows []Row
@@ -35,7 +37,7 @@ type Column struct {
3537}
3638
3739// KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which
38- // is used to render the menu.
40+ // is used to render the help menu.
3941type KeyMap struct {
4042 LineUp key.Binding
4143 LineDown key.Binding
@@ -134,6 +136,7 @@ func New(opts ...Option) Model {
134136 viewport : viewport .New (0 , 20 ),
135137
136138 KeyMap : DefaultKeyMap (),
139+ Help : help .New (),
137140 styles : DefaultStyles (),
138141 }
139142
@@ -251,6 +254,13 @@ func (m Model) View() string {
251254 return m .headersView () + "\n " + m .viewport .View ()
252255}
253256
257+ // HelpView is a helper method for rendering the help menu from the keymap.
258+ // Note that this view is not rendered by default and you must call it
259+ // manually in your application, where applicable.
260+ func (m Model ) HelpView () string {
261+ return m .Help .View (m .KeyMap )
262+ }
263+
254264// UpdateViewport updates the list content based on the previously defined
255265// columns and rows.
256266func (m * Model ) UpdateViewport () {
0 commit comments