mirror of
https://github.com/charmbracelet/gum
synced 2024-06-01 13:22:26 +02:00
feat: Allow setting initial value for input
and write
This commit is contained in:
parent
46ddc28ae5
commit
593cf711be
|
@ -15,6 +15,7 @@ func (o Options) Run() {
|
||||||
i := textinput.New()
|
i := textinput.New()
|
||||||
i.Focus()
|
i.Focus()
|
||||||
|
|
||||||
|
i.SetValue(o.Value)
|
||||||
i.Prompt = o.Prompt
|
i.Prompt = o.Prompt
|
||||||
i.Placeholder = o.Placeholder
|
i.Placeholder = o.Placeholder
|
||||||
i.Width = o.Width
|
i.Width = o.Width
|
||||||
|
|
|
@ -6,5 +6,6 @@ type Options struct {
|
||||||
Placeholder string `help:"Placeholder value" default:"Type something..."`
|
Placeholder string `help:"Placeholder value" default:"Type something..."`
|
||||||
Prompt string `help:"Prompt to display" default:"> "`
|
Prompt string `help:"Prompt to display" default:"> "`
|
||||||
PromptColor string `help:"Color of prompt" default:"7"`
|
PromptColor string `help:"Color of prompt" default:"7"`
|
||||||
|
Value string `help:"Initial value" default:""`
|
||||||
Width int `help:"Input width" default:"20"`
|
Width int `help:"Input width" default:"20"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ func (o Options) Run() {
|
||||||
|
|
||||||
a.SetWidth(o.Width)
|
a.SetWidth(o.Width)
|
||||||
a.SetHeight(o.Height)
|
a.SetHeight(o.Height)
|
||||||
|
a.SetValue(o.Value)
|
||||||
|
|
||||||
p := tea.NewProgram(model{a}, tea.WithOutput(os.Stderr))
|
p := tea.NewProgram(model{a}, tea.WithOutput(os.Stderr))
|
||||||
m, _ := p.StartReturningModel()
|
m, _ := p.StartReturningModel()
|
||||||
|
|
|
@ -9,5 +9,6 @@ type Options struct {
|
||||||
PromptColor string `help:"Prompt color" default:"238"`
|
PromptColor string `help:"Prompt color" default:"238"`
|
||||||
ShowCursorLine bool `help:"Show cursor line" default:"false"`
|
ShowCursorLine bool `help:"Show cursor line" default:"false"`
|
||||||
ShowLineNumbers bool `help:"Show line numbers" default:"false"`
|
ShowLineNumbers bool `help:"Show line numbers" default:"false"`
|
||||||
|
Value string `help:"Initial value" default:""`
|
||||||
Width int `help:"Text area width" default:"50"`
|
Width int `help:"Text area width" default:"50"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue