-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
44 lines (36 loc) · 1.02 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package prompt
import (
"github.com/aschey/bubbleprompt/renderer"
"github.com/aschey/bubbleprompt/suggestion"
)
type Option[T any] func(model *Model[T])
func WithFormatters[T any](formatters suggestion.Formatters) Option[T] {
return func(model *Model[T]) {
model.suggestionManager.SetFormatters(formatters)
}
}
func WithUnmanagedRenderer[T any](opts ...renderer.Option) Option[T] {
return func(model *Model[T]) {
model.renderer = renderer.NewUnmanagedRenderer(opts...)
}
}
func WithViewportRenderer[T any](opts ...renderer.Option) Option[T] {
return func(model *Model[T]) {
model.renderer = renderer.NewViewportRenderer(opts...)
}
}
func WithRenderer[T any](r renderer.Renderer) Option[T] {
return func(model *Model[T]) {
model.renderer = r
}
}
func WithSuggestionManager[T any](manager suggestion.Manager[T]) Option[T] {
return func(model *Model[T]) {
model.suggestionManager = manager
}
}
func WithFocusOnStart[T any](focusOnStart bool) Option[T] {
return func(model *Model[T]) {
model.focus = focusOnStart
}
}