mirror of
https://github.com/charmbracelet/gum
synced 2024-05-17 05:36:42 +02:00
feat: Make input and write textarea CharLimit configurable through options
Removes the hardcoded 400 chars CharLimit (default for textarea), and make the CharLimit configurable through an Option.
This commit is contained in:
parent
197e52a362
commit
06e8546366
|
@ -28,6 +28,7 @@ func (o Options) Run() error {
|
|||
i.Width = o.Width
|
||||
i.PromptStyle = o.PromptStyle.ToLipgloss()
|
||||
i.CursorStyle = o.CursorStyle.ToLipgloss()
|
||||
i.CharLimit = o.CharLimit
|
||||
|
||||
if o.Password {
|
||||
i.EchoMode = textinput.EchoPassword
|
||||
|
|
|
@ -10,6 +10,7 @@ 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:""`
|
||||
CharLimit int `help:"Maximum value length (0 for no limit)" default:"400"`
|
||||
Width int `help:"Input width" default:"40"`
|
||||
Password bool `help:"Mask input characters" default:"false"`
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ func (o Options) Run() error {
|
|||
a.Prompt = o.Prompt
|
||||
a.Placeholder = o.Placeholder
|
||||
a.ShowLineNumbers = o.ShowLineNumbers
|
||||
a.CharLimit = o.CharLimit
|
||||
|
||||
style := textarea.Style{
|
||||
Base: o.BaseStyle.ToLipgloss(),
|
||||
|
|
|
@ -12,6 +12,7 @@ type Options struct {
|
|||
ShowCursorLine bool `help:"Show cursor line" default:"false"`
|
||||
ShowLineNumbers bool `help:"Show line numbers" default:"false"`
|
||||
Value string `help:"Initial value (can be passed via stdin)" default:""`
|
||||
CharLimit int `help:"Maximum value length (0 for no limit)" default:"400"`
|
||||
|
||||
BaseStyle style.Styles `embed:"" prefix:"base." set:"name=base"`
|
||||
CursorLineNumberStyle style.Styles `embed:"" prefix:"cursor-line-number." set:"defaultForeground=7" set:"name=cursor line number"`
|
||||
|
|
Loading…
Reference in a new issue