MCPcopy Create free account
hub / github.com/babycommando/nightride-cli / updateForm

Method updateForm

zuse.go:577–642  ·  view source on GitHub ↗
(key tea.KeyMsg)

Source from the content-addressed store, hash-verified

575}
576
577func (m *ircModel) updateForm(key tea.KeyMsg) (tea.Model, tea.Cmd) {
578 switch key.String() {
579 case "up":
580 if m.formSel > 0 {
581 return m, m.focusFormField(m.formSel-1)
582 }
583 case "down":
584 if m.formSel < totalFields-1 {
585 return m, m.focusFormField(m.formSel+1)
586 }
587 case "enter":
588 if m.formSel < fieldSubmit {
589 return m, m.focusFormField(m.formSel+1)
590 }
591 cfg, err := m.formConfig()
592 if err != nil {
593 m.formInputs[fieldSubmit].SetValue("error: " + err.Error())
594 return m, nil
595 }
596 id := m.nextID
597 m.nextID++
598
599 s := &serverEntry{
600 id: id,
601 name: cfg.Name,
602 address: cfg.Address,
603 tls: cfg.TLS,
604 nick: cfg.Nick,
605 channels: cfg.Chans,
606 channelLogs: make(map[string][]string),
607 joined: make(map[string]bool),
608 }
609 m.servers[id] = s
610 m.injectASCIIArt(id)
611
612 var cmds []tea.Cmd
613 if len(cfg.Chans) > 0 {
614 for i := len(cfg.Chans) - 1; i >= 0; i-- {
615 ch := cfg.Chans[i]
616 copy := *s
617 copy.channel = ch
618 cmds = append(cmds, addListItemCmd(copy))
619 }
620 } else {
621 cmds = append(cmds, addListItemCmd(*s))
622 }
623
624 m.activeID = id
625 if len(cfg.Chans) > 0 {
626 m.activeChan = cfg.Chans[0]
627 } else {
628 m.activeChan = "_sys"
629 }
630 m.mode = modeChat
631 m.focusRight()
632 cmds = append(cmds, m.connectServerCmd(id), textinput.Blink)
633 return m, tea.Batch(cmds...)
634 }

Callers 1

updateRightPaneMethod · 0.95

Calls 7

focusFormFieldMethod · 0.95
formConfigMethod · 0.95
injectASCIIArtMethod · 0.95
focusRightMethod · 0.95
connectServerCmdMethod · 0.95
addListItemCmdFunction · 0.85
UpdateMethod · 0.45

Tested by

no test coverage detected