Skip to content
Myr

chore: minor UX edits to autocomplete example (#807)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by GitHub · parent 1ad1277 · Browse files · 1 file+5 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−2 removed

  • other:+5 added−2 removed

1 file+5 added−2 removed

modified:examples/autocomplete/main.go+5 added-2 removed
7 unmodified lines
8 "net/http"910 "github.com/charmbracelet/bubbles/textinput"11 tea "github.com/charmbracelet/bubbletea"12 "github.com/charmbracelet/lipgloss"13)1415func main() {16 p := tea.NewProgram(initialModel())
46 unmodified lines
63}6465func initialModel() model {66 ti := textinput.New()66 ti.Placeholder = "Bubbletea"67 ti.Prompt = "charmbracelet/"68 ti.Placeholder = "repo..."69 ti.Cursor.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))70 ti.Focus()71 ti.CharLimit = 5072 ti.Width = 2073 ti.ShowSuggestions = true
27 unmodified lines
101func (m model) View() string {102 return fmt.Sprintf(103 "What’s your favorite Charm repository?\n\n%s\n\n%s\n",104 m.textInput.View(),102 "(esc to quit)",105 "(tab to complete, ctrl+n/ctrl+p to cycle through suggestions, esc to quit)",106 )107}