(msg tea.KeyMsg)
| 103 | } |
| 104 | |
| 105 | func (m configTabModel) handleNormalKey(msg tea.KeyMsg) (configTabModel, tea.Cmd) { |
| 106 | switch msg.String() { |
| 107 | case "r": |
| 108 | m.message = "" |
| 109 | return m, m.fetchConfig |
| 110 | case "up", "k": |
| 111 | if m.cursor > 0 { |
| 112 | m.cursor-- |
| 113 | m.viewport.SetContent(m.renderContent()) |
| 114 | // Ensure cursor is visible |
| 115 | m.ensureCursorVisible() |
| 116 | } |
| 117 | return m, nil |
| 118 | case "down", "j": |
| 119 | if m.cursor < len(m.fields)-1 { |
| 120 | m.cursor++ |
| 121 | m.viewport.SetContent(m.renderContent()) |
| 122 | m.ensureCursorVisible() |
| 123 | } |
| 124 | return m, nil |
| 125 | case "enter", " ": |
| 126 | if m.cursor >= 0 && m.cursor < len(m.fields) { |
| 127 | f := m.fields[m.cursor] |
| 128 | if f.kind == "readonly" { |
| 129 | return m, nil |
| 130 | } |
| 131 | if f.kind == "bool" { |
| 132 | // Toggle directly |
| 133 | return m, m.toggleBool(m.cursor) |
| 134 | } |
| 135 | // Start editing for int/string |
| 136 | m.editing = true |
| 137 | m.textInput.SetValue(configFieldEditValue(f)) |
| 138 | m.textInput.Focus() |
| 139 | m.viewport.SetContent(m.renderContent()) |
| 140 | return m, textinput.Blink |
| 141 | } |
| 142 | return m, nil |
| 143 | } |
| 144 | |
| 145 | var cmd tea.Cmd |
| 146 | m.viewport, cmd = m.viewport.Update(msg) |
| 147 | return m, cmd |
| 148 | } |
| 149 | |
| 150 | func (m configTabModel) handleEditingKey(msg tea.KeyMsg) (configTabModel, tea.Cmd) { |
| 151 | switch msg.String() { |
no test coverage detected