(msg tea.Msg)
| 786 | } |
| 787 | |
| 788 | func (m nameInputModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 789 | var cmd tea.Cmd |
| 790 | |
| 791 | switch msg := msg.(type) { |
| 792 | case tea.KeyMsg: |
| 793 | switch msg.Type { |
| 794 | case tea.KeyCtrlC: |
| 795 | // Skip this job |
| 796 | return m, tea.Quit |
| 797 | case tea.KeyCtrlD: |
| 798 | // Exit interactive sync entirely |
| 799 | m.exited = true |
| 800 | return m, tea.Quit |
| 801 | case tea.KeyEnter: |
| 802 | if m.state == "choosing" { |
| 803 | // Handle selection based on list choice |
| 804 | switch m.list.SelectedItem().(item).title { |
| 805 | case EnterCustomName: |
| 806 | m.state = "naming" |
| 807 | m.textInput.SetValue("") |
| 808 | return m, textinput.Blink |
| 809 | case UseDefaultName: |
| 810 | m.textInput.SetValue(m.defaultName) |
| 811 | m.done = true |
| 812 | return m, tea.Quit |
| 813 | case SkipJob: |
| 814 | m.done = false |
| 815 | return m, tea.Quit |
| 816 | } |
| 817 | } else if m.state == "naming" { |
| 818 | if err := validateName(m.textInput.Value()); err != nil { |
| 819 | m.err = err |
| 820 | return m, nil |
| 821 | } |
| 822 | m.done = true |
| 823 | |
| 824 | // Empty line for more legibile output |
| 825 | printLn() |
| 826 | |
| 827 | return m, tea.Quit |
| 828 | } |
| 829 | } |
| 830 | case tea.WindowSizeMsg: |
| 831 | m.width = msg.Width |
| 832 | m.textInput.Width = msg.Width - 8 // Subtract some padding for the margin |
| 833 | m.list.SetWidth(msg.Width) // Fixed: Use SetWidth method instead of direct assignment |
| 834 | } |
| 835 | |
| 836 | if m.state == "choosing" { |
| 837 | m.list, cmd = m.list.Update(msg) |
| 838 | } else { |
| 839 | m.textInput, cmd = m.textInput.Update(msg) |
| 840 | } |
| 841 | return m, cmd |
| 842 | } |
| 843 | |
| 844 | func (m nameInputModel) View() string { |
| 845 | if m.state == "choosing" { |
nothing calls this directly
no test coverage detected