startEdit activates inline editing for a field on the currently selected auth file.
(fieldIdx int)
| 125 | |
| 126 | // startEdit activates inline editing for a field on the currently selected auth file. |
| 127 | func (m *authTabModel) startEdit(fieldIdx int) tea.Cmd { |
| 128 | if m.cursor >= len(m.files) { |
| 129 | return nil |
| 130 | } |
| 131 | f := m.files[m.cursor] |
| 132 | m.editFileName = getString(f, "name") |
| 133 | m.editField = fieldIdx |
| 134 | m.editing = true |
| 135 | |
| 136 | // Pre-populate with current value |
| 137 | key := authEditableFields[fieldIdx].key |
| 138 | currentVal := getAnyString(f, key) |
| 139 | m.editInput.SetValue(currentVal) |
| 140 | m.editInput.Focus() |
| 141 | m.editInput.Prompt = fmt.Sprintf(" %s: ", authEditableFields[fieldIdx].label) |
| 142 | m.viewport.SetContent(m.renderContent()) |
| 143 | return textinput.Blink |
| 144 | } |
| 145 | |
| 146 | func (m *authTabModel) SetSize(w, h int) { |
| 147 | m.width = w |
no test coverage detected