MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / handleEditInput

Method handleEditInput

internal/tui/auth_tab.go:330–368  ·  view source on GitHub ↗
(msg tea.KeyMsg)

Source from the content-addressed store, hash-verified

328}
329
330func (m authTabModel) handleEditInput(msg tea.KeyMsg) (authTabModel, tea.Cmd) {
331 switch msg.String() {
332 case "enter":
333 value := m.editInput.Value()
334 fieldKey := authEditableFields[m.editField].key
335 fileName := m.editFileName
336 m.editing = false
337 m.editInput.Blur()
338 fields := map[string]any{}
339 if fieldKey == "priority" {
340 p, err := strconv.Atoi(value)
341 if err != nil {
342 return m, func() tea.Msg {
343 return authActionMsg{err: fmt.Errorf("%s: %s", T("invalid_int"), value)}
344 }
345 }
346 fields[fieldKey] = p
347 } else {
348 fields[fieldKey] = value
349 }
350 return m, func() tea.Msg {
351 err := m.client.PatchAuthFileFields(fileName, fields)
352 if err != nil {
353 return authActionMsg{err: err}
354 }
355 return authActionMsg{action: fmt.Sprintf(T("updated_field"), fieldKey, fileName)}
356 }
357 case "esc":
358 m.editing = false
359 m.editInput.Blur()
360 m.viewport.SetContent(m.renderContent())
361 return m, nil
362 default:
363 var cmd tea.Cmd
364 m.editInput, cmd = m.editInput.Update(msg)
365 m.viewport.SetContent(m.renderContent())
366 return m, cmd
367 }
368}
369
370func (m authTabModel) handleConfirmInput(msg tea.KeyMsg) (authTabModel, tea.Cmd) {
371 switch msg.String() {

Callers 1

UpdateMethod · 0.95

Calls 5

renderContentMethod · 0.95
TFunction · 0.85
StringMethod · 0.45
PatchAuthFileFieldsMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected