func switchToMode(amua *Amua, g *gocui.Gui, mode Mode) error { /* highlight off */ if amua.mode.IsHighlighted() { v := modeToView(g, amua.mode) v.Highlight = false } amua.prevMode = amua.mode amua.mode = mode curview := modeToViewStr(amua.mode) var err error switch amua.mode { case MessageMode: m := amua.curMessage() m.Flags |= Seen err = m.Draw(amua, g) case MessageMimeMode: m := amua.curMessage() err = (*MessageAsMimeTree)(m).Draw(amua, g) case MaildirMode: v, _ := g.View(curview) err = amua.curMaildirView.Draw(v) case SendMailMode: v, _ := g.View(curview) err = amua.sendMailDraw(v) case CommandNewMailMode: tos := util.ConcatAddresses(amua.newMail.to) amua.newMail.to = []*mail.Address{} displayPromptWithPrefill(TO_PROMPT, tos) case CommandMailModeTo: displayPromptWithPrefill(TO_PROMPT, util.ConcatAddresses(amua.newMail.to)) case CommandMailModeCc: displayPromptWithPrefill(CC_PROMPT, util.ConcatAddresses(amua.newMail.cc)) case CommandMailModeBcc: displayPromptWithPrefill(BCC_PROMPT, util.ConcatAddresses(amua.newMail.bcc)) case CommandSearchMode: displayPrompt(SEARCH_PROMPT) } if err != nil { v, _ := g.View(curview) if v != nil { fmt.Fprintf(v, err.Error()) } /* we printed the error, fallback */ } _, err = g.SetViewOnTop(curview) if err != nil { return err } err = g.SetCurrentView(curview) if err != nil { return err } /* highlight back */ if amua.mode.IsHighlighted() { v := modeToView(g, amua.mode) v.Highlight = true } return nil }
func (amua *Amua) sendMailDraw(v *gocui.View) error { v.Clear() v.Frame = false v.Highlight = false v.Wrap = true v.SetOrigin(0, 0) tos := util.ConcatAddresses(amua.newMail.to) ccs := util.ConcatAddresses(amua.newMail.cc) bccs := util.ConcatAddresses(amua.newMail.bcc) fmt.Fprintf(v, "y: send, Ctrl+G: cancel, q: move to drafts, t: tos, c: ccs, b: bccs\n") fmt.Fprintf(v, "To: %s\n", tos) fmt.Fprintf(v, "Cc: %s\n", ccs) fmt.Fprintf(v, "Bcc: %s\n", bccs) fmt.Fprintf(v, "Subject: %s\n", amua.newMail.subject) fmt.Fprintf(v, "\n") return nil }