⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compose.c

📁 mutt-1.5.12 源代码。linux 下邮件接受的工具。
💻 C
📖 第 1 页 / 共 3 页
字号:
    case 'a': /* total number of attachments */	snprintf (fmt, sizeof (fmt), "%%%sd", prefix);	snprintf (buf, buflen, fmt, menu->max);      break;    case 'h':  /* hostname */      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);      snprintf (buf, buflen, fmt, NONULL(Hostname));      break;    case 'l': /* approx length of current message in bytes */	snprintf (fmt, sizeof (fmt), "%%%ss", prefix);	mutt_pretty_size (tmp, sizeof (tmp), menu ? cum_attachs_size(menu) : 0);	snprintf (buf, buflen, fmt, tmp);      break;    case 'v':      snprintf (fmt, sizeof (fmt), "Mutt %%s");      snprintf (buf, buflen, fmt, MUTT_VERSION);      break;    case 0:      *buf = 0;      return (src);    default:      snprintf (buf, buflen, "%%%s%c", prefix, op);      break;  }  if (optional)    compose_status_line (buf, buflen, menu, ifstring);  else if (flags & M_FORMAT_OPTIONAL)    compose_status_line (buf, buflen, menu, elsestring);  return (src);}static void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu,       const char *p){  mutt_FormatString (buf, buflen, p, compose_format_str,         (unsigned long) menu, 0);}/* return values: * * 1	message should be postponed * 0	normal exit * -1	abort message */int mutt_compose_menu (HEADER *msg,   /* structure for new message */		    char *fcc,     /* where to save a copy of the message */		    size_t fcclen,		    HEADER *cur)   /* current message */{  char helpstr[SHORT_STRING];  char buf[LONG_STRING];  char fname[_POSIX_PATH_MAX];  MUTTMENU *menu;  ATTACHPTR **idx = NULL;  short idxlen = 0;  short idxmax = 0;  int i, close = 0;  int r = -1;		/* return value */  int op = 0;  int loop = 1;  int fccSet = 0;	/* has the user edited the Fcc: field ? */  CONTEXT *ctx = NULL, *this = NULL;  /* Sort, SortAux could be changed in mutt_index_menu() */  int oldSort, oldSortAux;  struct stat st;  mutt_attach_init (msg->content);  idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);  menu = mutt_new_menu ();  menu->menu = MENU_COMPOSE;  menu->offset = HDR_ATTACH;  menu->max = idxlen;  menu->make_entry = snd_entry;  menu->tag = mutt_tag_attach;  menu->data = idx;  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);    while (loop)  {    switch (op = mutt_menuLoop (menu))    {      case OP_REDRAW:	draw_envelope (msg, fcc);	menu->offset = HDR_ATTACH;	menu->pagelen = LINES - HDR_ATTACH - 2;	break;      case OP_COMPOSE_EDIT_FROM:	menu->redraw = edit_address_list (HDR_FROM, &msg->env->from);        mutt_message_hook (NULL, msg, M_SEND2HOOK);	break;      case OP_COMPOSE_EDIT_TO:	menu->redraw = edit_address_list (HDR_TO, &msg->env->to);        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;      case OP_COMPOSE_EDIT_BCC:	menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);        mutt_message_hook (NULL, msg, M_SEND2HOOK);	break;      case OP_COMPOSE_EDIT_CC:	menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);        mutt_message_hook (NULL, msg, M_SEND2HOOK);	        break;      case OP_COMPOSE_EDIT_SUBJECT:	if (msg->env->subject)	  strfcpy (buf, msg->env->subject, sizeof (buf));	else	  buf[0] = 0;	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)	{	  mutt_str_replace (&msg->env->subject, buf);	  move (HDR_SUBJECT, HDR_XOFFSET);	  clrtoeol ();	  if (msg->env->subject)	    mutt_paddstr (W, msg->env->subject);	}        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;      case OP_COMPOSE_EDIT_REPLY_TO:	menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to);        mutt_message_hook (NULL, msg, M_SEND2HOOK);	break;      case OP_COMPOSE_EDIT_FCC:	strfcpy (buf, fcc, sizeof (buf));	if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0)	{	  strfcpy (fcc, buf, _POSIX_PATH_MAX);	  mutt_pretty_mailbox (fcc);	  move (HDR_FCC, HDR_XOFFSET);	  mutt_paddstr (W, fcc);	  fccSet = 1;	}	MAYBE_REDRAW (menu->redraw);        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;      case OP_COMPOSE_EDIT_MESSAGE:	if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS))	{	  mutt_edit_file (Editor, msg->content->filename);	  mutt_update_encoding (msg->content);	  menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;	  mutt_message_hook (NULL, msg, M_SEND2HOOK);	  break;	}	/* fall through */      case OP_COMPOSE_EDIT_HEADERS:	if (mutt_strcmp ("builtin", Editor) != 0 &&	    (op == OP_COMPOSE_EDIT_HEADERS ||	    (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS))))	{	  char *tag = NULL, *err = NULL;	  mutt_env_to_local (msg->env);	  mutt_edit_headers (NONULL (Editor), msg->content->filename, msg,			     fcc, fcclen);	  if (mutt_env_to_idna (msg->env, &tag, &err))	  {	    mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);	    FREE (&err);	  }	}	else	{	  /* this is grouped with OP_COMPOSE_EDIT_HEADERS because the	     attachment list could change if the user invokes ~v to edit	     the message with headers, in which we need to execute the	     code below to regenerate the index array */	  mutt_builtin_editor (msg->content->filename, msg, cur);	}	mutt_update_encoding (msg->content);	/* attachments may have been added */	if (idxlen && idx[idxlen - 1]->content->next)	{	  for (i = 0; i < idxlen; i++)	    FREE (&idx[i]);	  idxlen = 0;	  idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);	  menu->data = idx;	  menu->max = idxlen;	}        menu->redraw = REDRAW_FULL;        mutt_message_hook (NULL, msg, M_SEND2HOOK);	break;      case OP_COMPOSE_ATTACH_KEY:        if (!(WithCrypto & APPLICATION_PGP))          break;       	if (idxlen == idxmax)        {	  safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));	  menu->data = idx;	}		idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));	if ((idx[idxlen]->content = crypt_pgp_make_key_attachment(NULL)) != NULL)	{	  update_idx (menu, idx, idxlen++);	  menu->redraw |= REDRAW_INDEX;	}	else	  FREE (&idx[idxlen]);	menu->redraw |= REDRAW_STATUS;	if (option(OPTNEEDREDRAW))	{	  menu->redraw = REDRAW_FULL;	  unset_option(OPTNEEDREDRAW);	}	        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;      case OP_COMPOSE_ATTACH_FILE:	{	  char *prompt, **files;	  int error, numfiles;	  fname[0] = 0;	  prompt = _("Attach file");	  numfiles = 0;	  files = NULL;	  if (_mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 0, 1, &files, &numfiles) == -1 ||	      *fname == '\0')	    break;	  if (idxlen + numfiles >= idxmax)	  {	    safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles));	    menu->data = idx;	  }	  error = 0;	  if (numfiles > 1)	    mutt_message _("Attaching selected files...");	  for (i = 0; i < numfiles; i++)	  {	    char *att = files[i];	    idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));            idx[idxlen]->unowned = 1;	    idx[idxlen]->content = mutt_make_file_attach (att);	    if (idx[idxlen]->content != NULL)	      update_idx (menu, idx, idxlen++);	    else	    {	      error = 1;	      mutt_error (_("Unable to attach %s!"), att);	      FREE (&idx[idxlen]);	    }	  }	  	  FREE (&files);	  if (!error) mutt_clear_error ();	  menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;	}        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;      case OP_COMPOSE_ATTACH_MESSAGE:	{	  char *prompt;	  HEADER *h;	  fname[0] = 0;	  prompt = _("Open mailbox to attach message from");	  if (Context)	  {	    strfcpy (fname, NONULL (Context->path), sizeof (fname));	    mutt_pretty_mailbox (fname);	  }	  if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])	    break;	  mutt_expand_path (fname, sizeof (fname));#ifdef USE_IMAP          if (!mx_is_imap (fname))#endif#ifdef USE_POP          if (!mx_is_pop (fname))#endif	  /* check to make sure the file exists and is readable */	  if (access (fname, R_OK) == -1)	  {	    mutt_perror (fname);	    break;	  }	  menu->redraw = REDRAW_FULL;	  ctx = mx_open_mailbox (fname, M_READONLY, NULL);	  if (ctx == NULL)	  {	    mutt_perror (fname);	    break;	  }	  if (!ctx->msgcount)	  {	    mx_close_mailbox (ctx, NULL);	    FREE (&ctx);	    mutt_error _("No messages in that folder.");	    break;	  }	  this = Context; /* remember current folder and sort methods*/	  oldSort = Sort; oldSortAux = SortAux;	  	  Context = ctx;	  set_option(OPTATTACHMSG);	  mutt_message _("Tag the messages you want to attach!");	  close = mutt_index_menu ();	  unset_option(OPTATTACHMSG);	  if (!Context)	  {	    /* go back to the folder we started from */	    Context = this;	    /* Restore old $sort and $sort_aux */	    Sort = oldSort;	    SortAux = oldSortAux;	    menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;	    break;	  }	  if (idxlen + Context->tagged >= idxmax)	  {	    safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + Context->tagged));	    menu->data = idx;	  }	  for (i = 0; i < Context->msgcount; i++)	  {	    h = Context->hdrs[i];	    if (h->tagged)	    {	      idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));	      idx[idxlen]->content = mutt_make_message_attach (Context, h, 1);	      if (idx[idxlen]->content != NULL)		update_idx (menu, idx, idxlen++);	      else	      {		mutt_error _("Unable to attach!");		FREE (&idx[idxlen]);	      }	    }	  }	  menu->redraw |= REDRAW_FULL;	  if (close == OP_QUIT) 	    mx_close_mailbox (Context, NULL);	  else	    mx_fastclose_mailbox (Context);	  FREE (&Context);	  /* go back to the folder we started from */	  Context = this;	  /* Restore old $sort and $sort_aux */	  Sort = oldSort;	  SortAux = oldSortAux;	}        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;      case OP_DELETE:	CHECK_COUNT;        if (idx[menu->current]->unowned)          idx[menu->current]->content->unlink = 0;	if (delete_attachment (menu, &idxlen, menu->current) == -1)	  break;	mutt_update_tree (idx, idxlen);	if (idxlen)	{	  if (menu->current > idxlen - 1)	    menu->current = idxlen - 1;	}	else	  menu->current = 0;	if (menu->current == 0)	  msg->content = idx[0]->content;        menu->redraw |= REDRAW_STATUS;        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;#define CURRENT idx[menu->current]->content            case OP_COMPOSE_TOGGLE_RECODE:      {              CHECK_COUNT;        if (!mutt_is_text_part (CURRENT))        {	  mutt_error (_("Recoding only affects text attachments."));	  break;	}        CURRENT->noconv = !CURRENT->noconv;        if (CURRENT->noconv)	  mutt_message (_("The current attachment won't be converted."));        else	  mutt_message (_("The current attachment will be converted."));	menu->redraw = REDRAW_CURRENT;        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;      }#undef CURRENT      case OP_COMPOSE_EDIT_DESCRIPTION:	CHECK_COUNT;	strfcpy (buf,		 idx[menu->current]->content->description ?		 idx[menu->current]->content->description : "",		 sizeof (buf));	/* header names should not be translated */	if (mutt_get_field ("Description: ", buf, sizeof (buf), 0) == 0)	{	  mutt_str_replace (&idx[menu->current]->content->description, buf);	  menu->redraw = REDRAW_CURRENT;	}        mutt_message_hook (NULL, msg, M_SEND2HOOK);        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -