MCPcopy
hub / github.com/mathaou/termdbms / NewModel

Function NewModel

list/list.go:153–197  ·  view source on GitHub ↗

NewModel returns a new model with sensible defaults.

(items []Item, delegate ItemDelegate, width, height int)

Source from the content-addressed store, hash-verified

151
152// NewModel returns a new model with sensible defaults.
153func NewModel(items []Item, delegate ItemDelegate, width, height int) Model {
154 styles := DefaultStyles()
155
156 sp := spinner.NewModel()
157 sp.Spinner = spinner.Line
158 sp.Style = styles.Spinner
159
160 filterInput := textinput.NewModel()
161 filterInput.Prompt = "Filter: "
162 filterInput.PromptStyle = styles.FilterPrompt
163 filterInput.CursorStyle = styles.FilterCursor
164 filterInput.CharLimit = 64
165 filterInput.Focus()
166
167 p := paginator.NewModel()
168 p.Type = paginator.Dots
169 p.ActiveDot = styles.ActivePaginationDot.String()
170 p.InactiveDot = styles.InactivePaginationDot.String()
171
172 m := Model{
173 showTitle: true,
174 showFilter: true,
175 showStatusBar: true,
176 showPagination: true,
177 showHelp: true,
178 filteringEnabled: true,
179 KeyMap: DefaultKeyMap(),
180 Styles: styles,
181 Title: "List",
182 FilterInput: filterInput,
183 StatusMessageLifetime: time.Second,
184
185 width: width,
186 height: height,
187 delegate: delegate,
188 items: items,
189 Paginator: p,
190 spinner: sp,
191 Help: help.NewModel(),
192 }
193
194 m.updatePagination()
195 m.updateKeybindings()
196 return m
197}
198
199// SetFilteringEnabled enables or disables filtering. Note that this is different
200// from ShowFilter, which merely hides or shows the input view.

Callers 1

GetNewModelFunction · 0.92

Calls 5

updatePaginationMethod · 0.95
updateKeybindingsMethod · 0.95
DefaultStylesFunction · 0.85
DefaultKeyMapFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected