MCPcopy Create free account
hub / github.com/catppuccin/cli / Update

Method Update

internal/ui/installInput.go:59–114  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

57}
58
59func (m InstallModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
60 switch msg := msg.(type) {
61 case tea.KeyMsg:
62 switch msg.String() {
63 case "ctrl+c", "esc":
64 return m, tea.Quit
65
66 case "tab", "shift+tab", "enter", "up", "down":
67 s := msg.String()
68
69 if s == "enter" && m.focusIndex == len(m.inputs) {
70 LinuxLoc = m.inputs[0].Value()
71 if LinuxLoc == "" {
72 LinuxLoc = m.inputs[0].Placeholder
73 }
74 MacLoc = m.inputs[1].Value()
75 if MacLoc == "" {
76 MacLoc = m.inputs[1].Placeholder
77 }
78 WindowsLoc = m.inputs[2].Value()
79 if WindowsLoc == "" {
80 WindowsLoc = m.inputs[2].Placeholder
81 }
82 m := NewSpinnerParent()
83 return m, m.Init()
84 }
85
86 if s == "up" || s == "shift+tab" {
87 m.focusIndex--
88 } else {
89 m.focusIndex++
90 }
91 if m.focusIndex > len(m.inputs) {
92 m.focusIndex = 0
93 } else if m.focusIndex < 0 {
94 m.focusIndex = len(m.inputs)
95 }
96
97 cmds := make([]tea.Cmd, len(m.inputs))
98 for i := 0; i <= len(m.inputs)-1; i++ {
99 if i == m.focusIndex {
100 cmds[i] = m.inputs[i].Focus()
101 m.inputs[i].PromptStyle = focusedStyle
102 m.inputs[i].TextStyle = focusedStyle
103 continue
104 }
105 m.inputs[i].Blur()
106 m.inputs[i].PromptStyle = noStyle
107 m.inputs[i].TextStyle = noStyle
108 }
109 return m, tea.Batch(cmds...)
110 }
111 }
112 cmd := m.updateInputs(msg)
113 return m, cmd
114}
115
116func (m *InstallModel) updateInputs(msg tea.Msg) tea.Cmd {

Callers 1

updateInputsMethod · 0.45

Calls 3

InitMethod · 0.95
updateInputsMethod · 0.95
NewSpinnerParentFunction · 0.85

Tested by

no test coverage detected