From 72d87e451304692152843e59bc412532432981b9 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 15 Sep 2022 16:51:42 +0200 Subject: [PATCH] chore: Miscellaneous minor fixes (#243) * chore: remove internal use of deprecated NewModel * chore: miscellaneous comment fixes --- list/list.go | 13 ++++++------- progress/progress.go | 11 +++++------ spinner/spinner.go | 5 ++--- textinput/textinput.go | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/list/list.go b/list/list.go index bec5e6f..0c858c8 100644 --- a/list/list.go +++ b/list/list.go @@ -183,18 +183,18 @@ type Model struct { func New(items []Item, delegate ItemDelegate, width, height int) Model { styles := DefaultStyles() - sp := spinner.NewModel() + sp := spinner.New() sp.Spinner = spinner.Line sp.Style = styles.Spinner - filterInput := textinput.NewModel() + filterInput := textinput.New() filterInput.Prompt = "Filter: " filterInput.PromptStyle = styles.FilterPrompt filterInput.CursorStyle = styles.FilterCursor filterInput.CharLimit = 64 filterInput.Focus() - p := paginator.NewModel() + p := paginator.New() p.Type = paginator.Dots p.ActiveDot = styles.ActivePaginationDot.String() p.InactiveDot = styles.InactivePaginationDot.String() @@ -221,7 +221,7 @@ func New(items []Item, delegate ItemDelegate, width, height int) Model { items: items, Paginator: p, spinner: sp, - Help: help.NewModel(), + Help: help.New(), } m.updatePagination() @@ -526,7 +526,7 @@ func (m Model) FilterValue() string { // SettingFilter returns whether or not the user is currently editing the // filter value. It's purely a convenience method for the following: // -// m.FilterState() == Filtering +// m.FilterState() == Filtering // // It's included here because it's a common thing to check for when // implementing this component. @@ -537,8 +537,7 @@ func (m Model) SettingFilter() bool { // IsFiltered returns whether or not the list is currently filtered. // It's purely a convenience method for the following: // -// m.FilterState() == FilterApplied -// +// m.FilterState() == FilterApplied func (m Model) IsFiltered() bool { return m.filterState == FilterApplied } diff --git a/progress/progress.go b/progress/progress.go index f77cb55..bacf884 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -37,13 +37,12 @@ const ( defaultDamping = 1.0 ) -// Option is used to set options in NewModel. For example: -// -// progress := NewModel( -// WithRamp("#ff0000", "#0000ff"), -// WithoutPercentage(), -// ) +// Option is used to set options in New. For example: // +// progress := New( +// WithRamp("#ff0000", "#0000ff"), +// WithoutPercentage(), +// ) type Option func(*Model) // WithDefaultGradient sets a gradient fill with default colors. diff --git a/spinner/spinner.go b/spinner/spinner.go index e034112..f206996 100644 --- a/spinner/spinner.go +++ b/spinner/spinner.go @@ -85,7 +85,7 @@ var ( } ) -// Model contains the state for the spinner. Use NewModel to create new models +// Model contains the state for the spinner. Use New to create new models // rather than using Model as a struct literal. type Model struct { // Spinner settings to use. See type Spinner. @@ -208,8 +208,7 @@ func Tick() tea.Msg { // Option is used to set options in New. For example: // -// spinner := New(WithSpinner(Dot)) -// +// spinner := New(WithSpinner(Dot)) type Option func(*Model) // WithSpinner is an option to set the spinner. diff --git a/textinput/textinput.go b/textinput/textinput.go index 0c8af73..c596910 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -169,7 +169,7 @@ func (m Model) Focused() bool { } // Focus sets the focus state on the model. When the model is in focus it can -// receive keyboard input and the cursor will be hidden. +// receive keyboard input and the cursor will be shown. func (m *Model) Focus() tea.Cmd { m.focus = true return m.Cursor.Focus()