Skip to content
Myr

Migrate from NewModel() to New() in examples for Bubbles-related stuff

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 843b6a5 · Browse files · 15 files+15 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

15 files+15 added−15 removed

  • other:+15 added−15 removed

15 files+15 added−15 removed

modified:examples/help/main.go+1 added-1 removed
73 unmodified lines
7475func newModel() model {76 return model{77 keys: keys,78 help: help.NewModel(),78 help: help.New(),79 inputStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#FF75B7")),80 }81}82
65 unmodified lines
modified:examples/list-default/main.go+1 added-1 removed
72 unmodified lines
73 item{title: "Gaffer’s tape", desc: "Basically sticky fabric"},74 item{title: "Terrycloth", desc: "In other words, towel fabric"},75 }7677 m := model{list: list.NewModel(items, list.NewDefaultDelegate(), 0, 0)}77 m := model{list: list.New(items, list.NewDefaultDelegate(), 0, 0)}78 m.list.Title = "My Fave Things"7980 p := tea.NewProgram(m, tea.WithAltScreen())81
5 unmodified lines
modified:examples/list-fancy/main.go+1 added-1 removed
93 unmodified lines
94 }9596 // Setup list97 delegate := newItemDelegate(delegateKeys)98 groceryList := list.NewModel(items, delegate, 0, 0)98 groceryList := list.New(items, delegate, 0, 0)99 groceryList.Title = "Groceries"100 groceryList.Styles.Title = titleStyle101 groceryList.AdditionalFullHelpKeys = func() []key.Binding {102 return []key.Binding{
88 unmodified lines
modified:examples/list-simple/main.go+1 added-1 removed
109 unmodified lines
110 }111112 const defaultWidth = 20113114 l := list.NewModel(items, itemDelegate{}, defaultWidth, listHeight)114 l := list.New(items, itemDelegate{}, defaultWidth, listHeight)115 l.Title = "What do you want for dinner?"116 l.SetShowStatusBar(false)117 l.SetFilteringEnabled(false)118 l.Styles.Title = titleStyle
10 unmodified lines
modified:examples/paginator/main.go+1 added-1 removed
19 unmodified lines
20 text := fmt.Sprintf("Item %d", i)21 items = append(items, text)22 }2324 p := paginator.NewModel()24 p := paginator.New()25 p.Type = paginator.Dots26 p.PerPage = 1027 p.ActiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "235", Dark: "252"}).Render("•")28 p.InactiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "250", Dark: "238"}).Render("•")
48 unmodified lines
modified:examples/pipe/main.go+1 added-1 removed
54 unmodified lines
55 userInput textinput.Model56}5758func newModel(initialValue string) (m model) {59 i := textinput.NewModel()59 i := textinput.New()60 i.Prompt = ""61 i.CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))62 i.Width = 4863 i.SetValue(initialValue)
30 unmodified lines
modified:examples/progress-animated/main.go+1 added-1 removed
25 unmodified lines
26var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render2728func main() {29 m := model{30 progress: progress.NewModel(progress.WithDefaultGradient()),30 progress: progress.New(progress.WithDefaultGradient()),31 }3233 if err := tea.NewProgram(m).Start(); err != nil {34 fmt.Println("Oh no!", err)
59 unmodified lines
modified:examples/progress-static/main.go+1 added-1 removed
33 unmodified lines
3435var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render3637func main() {38 prog := progress.NewModel(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))38 prog := progress.New(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))3940 if err := tea.NewProgram(model{progress: prog}).Start(); err != nil {41 fmt.Println("Oh no!", err)42 os.Exit(1)
52 unmodified lines
modified:examples/realtime/main.go+1 added-1 removed
80 unmodified lines
81 rand.Seed(time.Now().UTC().UnixNano())8283 p := tea.NewProgram(model{84 sub: make(chan struct{}),85 spinner: spinner.NewModel(),85 spinner: spinner.New(),86 })8788 if p.Start() != nil {89 fmt.Println("could not start program")
3 unmodified lines
modified:examples/send-msg/main.go+1 added-1 removed
43 unmodified lines
44}4546func newModel() model {47 const numLastResults = 548 s := spinner.NewModel()48 s := spinner.New()49 s.Style = spinnerStyle50 return model{51 spinner: s,52 results: make([]resultMsg, numLastResults),
84 unmodified lines
modified:examples/spinner/main.go+1 added-1 removed
19 unmodified lines
20 err error21}2223func initialModel() model {24 s := spinner.NewModel()24 s := spinner.New()25 s.Spinner = spinner.Dot26 s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))27 return model{spinner: s}28}
47 unmodified lines
modified:examples/spinners/main.go+1 added-1 removed
78 unmodified lines
79 }80}8182func (m *model) resetSpinner() {83 m.spinner = spinner.NewModel()83 m.spinner = spinner.New()84 m.spinner.Style = spinnerStyle85 m.spinner.Spinner = spinners[m.index]86}87
13 unmodified lines
modified:examples/textinput/main.go+1 added-1 removed
26 unmodified lines
27 err error28}2930func initialModel() model {31 ti := textinput.NewModel()31 ti := textinput.New()32 ti.Placeholder = "Pikachu"33 ti.Focus()34 ti.CharLimit = 15635 ti.Width = 20
38 unmodified lines
modified:examples/textinputs/main.go+1 added-1 removed
36 unmodified lines
37 }3839 var t textinput.Model40 for i := range m.inputs {41 t = textinput.NewModel()41 t = textinput.New()42 t.CursorStyle = cursorStyle43 t.CharLimit = 324445 switch i {
131 unmodified lines
modified:examples/tui-daemon-combo/main.go+1 added-1 removed
63 unmodified lines
6465func newModel() model {66 const showLastResults = 56768 sp := spinner.NewModel()68 sp := spinner.New()69 sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("206"))7071 return model{72 spinner: sp,
67 unmodified lines