diff --git a/input/command.go b/input/command.go index 01be0ad..ec529b8 100644 --- a/input/command.go +++ b/input/command.go @@ -31,10 +31,7 @@ func (o Options) Run() error { i.PromptStyle = o.PromptStyle.ToLipgloss() i.CursorStyle = o.CursorStyle.ToLipgloss() - p := tea.NewProgram(model{ - textinput: i, - autosize: o.Width == 0, - }, tea.WithOutput(os.Stderr)) + p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr)) m, err := p.StartReturningModel() fmt.Println(m.(model).textinput.Value()) return err diff --git a/input/input.go b/input/input.go index 8663a6c..294bfa9 100644 --- a/input/input.go +++ b/input/input.go @@ -11,24 +11,14 @@ package input import ( "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/lipgloss" ) -type model struct { - textinput textinput.Model - autosize bool -} +type model struct{ textinput textinput.Model } func (m model) Init() tea.Cmd { return textinput.Blink } func (m model) View() string { return m.textinput.View() } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { - case tea.WindowSizeMsg: - if !m.autosize { - return m, nil - } - m.textinput.Width = msg.Width - (lipgloss.Width(m.textinput.Prompt) + 1) - return m, nil case tea.KeyMsg: switch msg.Type { case tea.KeyEscape, tea.KeyCtrlC, tea.KeyEnter: diff --git a/input/options.go b/input/options.go index b45ef61..9881124 100644 --- a/input/options.go +++ b/input/options.go @@ -9,5 +9,5 @@ type Options struct { PromptStyle style.Styles `embed:"" prefix:"prompt." set:"name=prompt"` CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=cursor"` Value string `help:"Initial value (can also be passed via stdin)" default:""` - Width int `help:"Input width" default:"0"` + Width int `help:"Input width" default:"40"` }