Skip to content

Commit

Permalink
rename KeyBindsHelp to HelpKeyBinds
Browse files Browse the repository at this point in the history
  • Loading branch information
ardnew committed Mar 28, 2024
1 parent d383910 commit 4db94b3
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion examples/bubbletea/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (m Model) View() string {
}
body := lipgloss.JoinHorizontal(lipgloss.Top, form, status)

keys := m.form.KeyBindsHelp(huh.FormatShort)
keys := m.form.HelpKeyBinds(huh.FormatShort)
footer := m.appBoundaryView(m.form.Help().ShortHelpView(keys))
if len(errors) > 0 {
footer = m.appErrorBoundaryView("")
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/text/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func main() {
Placeholder("What's on your mind?").
Value(&story)

// Create a form to show help.
// Create a form to show text.
form := huh.NewForm(huh.NewGroup(text))
form.Run()
}
4 changes: 2 additions & 2 deletions field_confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func (c *Confirm) KeyBinds() []key.Binding {
return []key.Binding{c.keymap.Toggle, c.keymap.Prev, c.keymap.Submit, c.keymap.Next}
}

// KeyBindsHelp returns the help keybindings for the confirm field.
func (c *Confirm) KeyBindsHelp(HelpFormat) []key.Binding {
// HelpKeyBinds returns the help keybindings for the confirm field.
func (c *Confirm) HelpKeyBinds(HelpFormat) []key.Binding {
return c.KeyBinds()
}

Expand Down
4 changes: 2 additions & 2 deletions field_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ func (i *Input) KeyBinds() []key.Binding {
return []key.Binding{i.keymap.Prev, i.keymap.Submit, i.keymap.Next}
}

// KeyBindsHelp returns the help keybindings for the input field.
func (i *Input) KeyBindsHelp(HelpFormat) []key.Binding {
// HelpKeyBinds returns the help keybindings for the input field.
func (i *Input) HelpKeyBinds(HelpFormat) []key.Binding {
return i.KeyBinds()
}

Expand Down
4 changes: 2 additions & 2 deletions field_multiselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (m *MultiSelect[T]) KeyBinds() []key.Binding {
return []key.Binding{m.keymap.Toggle, m.keymap.Up, m.keymap.Down, m.keymap.Filter, m.keymap.SetFilter, m.keymap.ClearFilter, m.keymap.Prev, m.keymap.Submit, m.keymap.Next}
}

// KeyBindsHelp returns the help keybindings for the multi-select field.
func (m *MultiSelect[T]) KeyBindsHelp(HelpFormat) []key.Binding {
// HelpKeyBinds returns the help keybindings for the multi-select field.
func (m *MultiSelect[T]) HelpKeyBinds(HelpFormat) []key.Binding {
return m.KeyBinds()
}

Expand Down
4 changes: 2 additions & 2 deletions field_note.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func (n *Note) KeyBinds() []key.Binding {
return []key.Binding{n.keymap.Prev, n.keymap.Submit, n.keymap.Next}
}

// KeyBindsHelp returns the help keybindings for the note field.
func (n *Note) KeyBindsHelp(HelpFormat) []key.Binding {
// HelpKeyBinds returns the help keybindings for the note field.
func (n *Note) HelpKeyBinds(HelpFormat) []key.Binding {
return n.KeyBinds()
}

Expand Down
4 changes: 2 additions & 2 deletions field_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ func (s *Select[T]) KeyBinds() []key.Binding {
return []key.Binding{s.keymap.Up, s.keymap.Down, s.keymap.Filter, s.keymap.SetFilter, s.keymap.ClearFilter, s.keymap.Prev, s.keymap.Next, s.keymap.Submit}
}

// KeyBindsHelp returns the help keybindings for the select field.
func (s *Select[T]) KeyBindsHelp(HelpFormat) []key.Binding {
// HelpKeyBinds returns the help keybindings for the select field.
func (s *Select[T]) HelpKeyBinds(HelpFormat) []key.Binding {
return s.KeyBinds()
}

Expand Down
4 changes: 2 additions & 2 deletions field_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ func (t *Text) KeyBinds() []key.Binding {
return []key.Binding{t.keymap.NewLine, t.keymap.Editor, t.keymap.Prev, t.keymap.Submit, t.keymap.Next}
}

// KeyBindsHelp returns the help keybindings for the text field.
func (t *Text) KeyBindsHelp(HelpFormat) []key.Binding {
// HelpKeyBinds returns the help keybindings for the text field.
func (t *Text) HelpKeyBinds(HelpFormat) []key.Binding {
return t.KeyBinds()
}

Expand Down
12 changes: 6 additions & 6 deletions form.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ type Field interface {
// KeyBinds returns all keybindings.
KeyBinds() []key.Binding

// KeyBindsHelp returns the help keybindings.
KeyBindsHelp(HelpFormat) []key.Binding
// HelpKeyBinds returns all keybindings displayed via help.
HelpKeyBinds(HelpFormat) []key.Binding

// WithTheme sets the theme on a field.
WithTheme(*Theme) Field
Expand Down Expand Up @@ -332,16 +332,16 @@ func (f *Form) Help() help.Model {
return f.groups[f.paginator.Page].help
}

// KeyBinds returns the current fields' keybinds.
// KeyBinds returns the current field's keybinds.
func (f *Form) KeyBinds() []key.Binding {
group := f.groups[f.paginator.Page]
return group.fields[group.paginator.Page].KeyBinds()
}

// KeyBindsHelp returns the current fields' help keybinds.
func (f *Form) KeyBindsHelp(format HelpFormat) []key.Binding {
// HelpKeyBinds returns the current field's keybinds displayed via help.
func (f *Form) HelpKeyBinds(format HelpFormat) []key.Binding {
group := f.groups[f.paginator.Page]
return group.fields[group.paginator.Page].KeyBindsHelp(format)
return group.fields[group.paginator.Page].HelpKeyBinds(format)
}

// Get returns a result from the form.
Expand Down
2 changes: 1 addition & 1 deletion group.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (g *Group) View() string {
g.viewport.SetContent(fields.String() + "\n")

if g.showHelp && len(errors) <= 0 {
keys := g.fields[g.paginator.Page].KeyBindsHelp(FormatShort)
keys := g.fields[g.paginator.Page].HelpKeyBinds(FormatShort)
view.WriteString(g.help.ShortHelpView(keys))
}

Expand Down

0 comments on commit 4db94b3

Please sign in to comment.