(defaultName string)
| 742 | } |
| 743 | |
| 744 | func initialNameInputModel(defaultName string) nameInputModel { |
| 745 | // Setup list items |
| 746 | items := []list.Item{ |
| 747 | item{title: UseDefaultName, desc: defaultName}, |
| 748 | item{title: EnterCustomName, desc: "Add a friendly, unique name for this job"}, |
| 749 | item{title: SkipJob, desc: fmt.Sprintf("Do not monitor this %s", getJobLabel())}, |
| 750 | } |
| 751 | |
| 752 | // Setup list with height of 3 to show all items |
| 753 | l := list.New(items, list.NewDefaultDelegate(), 0, 3) |
| 754 | l.Title = "What would you like to do with this job?" |
| 755 | l.SetShowStatusBar(false) |
| 756 | l.SetFilteringEnabled(false) |
| 757 | l.Styles.Title = lipgloss.NewStyle().MarginLeft(1).Bold(false) |
| 758 | l.Styles.TitleBar = lipgloss.NewStyle().MarginLeft(2) |
| 759 | |
| 760 | // Update the style names to match the current API |
| 761 | delegate := list.NewDefaultDelegate() |
| 762 | delegate.Styles.NormalTitle = delegate.Styles.NormalTitle.MarginLeft(1) |
| 763 | delegate.Styles.SelectedTitle = delegate.Styles.SelectedTitle.MarginLeft(1) |
| 764 | delegate.Styles.NormalDesc = delegate.Styles.NormalDesc.MarginLeft(1).Italic(true) |
| 765 | delegate.Styles.SelectedDesc = delegate.Styles.SelectedDesc.MarginLeft(1).Italic(true) |
| 766 | |
| 767 | l.SetDelegate(delegate) |
| 768 | |
| 769 | // Setup text input |
| 770 | ti := textinput.New() |
| 771 | ti.Placeholder = "Enter monitor name" |
| 772 | ti.Focus() |
| 773 | ti.CharLimit = maxNameLen |
| 774 | |
| 775 | return nameInputModel{ |
| 776 | list: l, |
| 777 | textInput: ti, |
| 778 | defaultName: defaultName, |
| 779 | state: "choosing", |
| 780 | width: 80, // Default width if we don't get window size |
| 781 | } |
| 782 | } |
| 783 | |
| 784 | func (m nameInputModel) Init() tea.Cmd { |
| 785 | return nil |
no test coverage detected