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

📄 pager.c

📁 mutt-1.5.12 源代码。linux 下邮件接受的工具。
💻 C
📖 第 1 页 / 共 5 页
字号:
      }#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)      if (Resize != NULL)      {	if ((SearchCompiled = Resize->SearchCompiled))	{	  REGCOMP	    (&SearchRE, searchbuf, REG_NEWLINE | mutt_which_case (searchbuf));	  SearchFlag = M_SEARCH;	  SearchBack = Resize->SearchBack;	}	lines = Resize->line;	redraw |= REDRAW_SIGWINCH;	FREE (&Resize);      }#endif      if (IsHeader (extra) && PagerIndexLines)      {	if (index == NULL)	{	  /* only allocate the space if/when we need the index.	     Initialise the menu as per the main index */	  index = mutt_new_menu();	  index->menu = MENU_MAIN;	  index->make_entry = index_make_entry;	  index->color = index_color;	  index->max = Context->vcount;	  index->current = extra->hdr->virtual;	}	SETCOLOR (MT_COLOR_NORMAL);	index->offset  = indexoffset + (option (OPTSTATUSONTOP) ? 1 : 0);	index->pagelen = indexlen - 1;	/* some fudge to work out where abouts the indicator should go */	if (index->current - indicator < 0)	  index->top = 0;	else if (index->max - index->current < index->pagelen - indicator)	  index->top = index->max - index->pagelen;	else	  index->top = index->current - indicator;	menu_redraw_index(index);      }      redraw |= REDRAW_BODY | REDRAW_INDEX | REDRAW_STATUS;      mutt_show_error ();    }    if (redraw & REDRAW_SIGWINCH)    {      i = -1;      j = -1;      while (display_line (fp, &last_pos, &lineInfo, ++i, &lastLine, &maxLine,	     has_types | SearchFlag, &QuoteList, &q_level, &force_redraw,	     &SearchRE) == 0)	if (!lineInfo[i].continuation && ++j == lines)	{	  topline = i;	  if (!SearchFlag)	    break;	}    }    if ((redraw & REDRAW_BODY) || topline != oldtopline)    {      do {	move (bodyoffset, 0);	curline = oldtopline = topline;	lines = 0;	force_redraw = 0;	while (lines < bodylen && lineInfo[curline].offset <= sb.st_size - 1)	{	  if (display_line (fp, &last_pos, &lineInfo, curline, &lastLine, 			    &maxLine,			    (flags & M_DISPLAYFLAGS) | hideQuoted | SearchFlag, 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)	    lines++;	  curline++;	}	last_offset = lineInfo[curline].offset;      } while (force_redraw);      SETCOLOR (MT_COLOR_TILDE);      BKGDSET (MT_COLOR_TILDE);      while (lines < bodylen)      {	clrtoeol ();	if (option (OPTTILDE))	  addch ('~');	addch ('\n');	lines++;      }      /* We are going to update the pager status bar, so it isn't       * necessary to reset to normal color now. */      redraw |= REDRAW_STATUS; /* need to update the % seen */    }    if (redraw & REDRAW_STATUS)    {      /* print out the pager status bar */      SETCOLOR (MT_COLOR_STATUS);      BKGDSET (MT_COLOR_STATUS);      CLEARLINE (statusoffset);      if (IsHeader (extra))      {	size_t l1 = (COLS - 9) * MB_LEN_MAX;	size_t l2 = sizeof (buffer);	_mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),			   Context, extra->hdr, M_FORMAT_MAKEPRINT);      }      else if (IsMsgAttach (extra))      {	size_t l1 = (COLS - 9) * MB_LEN_MAX;	size_t l2 = sizeof (buffer);	_mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),			   Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);      }      mutt_paddstr (COLS-10, IsHeader (extra) || IsMsgAttach (extra) ?		    buffer : banner);      addstr (" -- (");      if (last_pos < sb.st_size - 1)	printw ("%d%%)", (int) (100 * last_offset / sb.st_size));      else	addstr (topline == 0 ? "all)" : "end)");      BKGDSET (MT_COLOR_NORMAL);      SETCOLOR (MT_COLOR_NORMAL);    }    if ((redraw & REDRAW_INDEX) && index)    {      /* redraw the pager_index indicator, because the       * flags for this message might have changed. */      menu_redraw_current (index);      /* print out the index status bar */      menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);      SETCOLOR (MT_COLOR_STATUS);      BKGDSET (MT_COLOR_STATUS);      mutt_paddstr (COLS, buffer);      SETCOLOR (MT_COLOR_NORMAL);      BKGDSET (MT_COLOR_NORMAL);    }    redraw = 0;    if (option(OPTBRAILLEFRIENDLY)) {      if (brailleLine!=-1) {        move(brailleLine+1, 0);        brailleLine = -1;      }    } else move (statusoffset, COLS-1);    mutt_refresh ();    if (IsHeader (extra) && OldHdr == extra->hdr && TopLine != topline        && lineInfo[curline].offset < sb.st_size-1)    {      if (TopLine - topline > lines)        topline += lines;      else        topline = TopLine;      continue;    }    else      OldHdr = NULL;          ch = km_dokey (MENU_PAGER);    if (ch != -1)      mutt_clear_error ();    mutt_curs_set (1);    if (SigInt)    {      mutt_query_exit ();      continue;    }#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)    else if (SigWinch)    {      mutt_resize_screen ();      /* Store current position. */      lines = -1;      for (i = 0; i <= topline; i++)	if (!lineInfo[i].continuation)	  lines++;      if (flags & M_PAGER_RETWINCH)      {	Resize = safe_malloc (sizeof (struct resize));	Resize->line = lines;	Resize->SearchCompiled = SearchCompiled;	Resize->SearchBack = SearchBack;	ch = -1;	rc = OP_REFORMAT_WINCH;      }      else      {	for (i = 0; i < maxLine; i++)	{	  lineInfo[i].offset = 0;	  lineInfo[i].type = -1;	  lineInfo[i].continuation = 0;	  lineInfo[i].chunks = 0;	  lineInfo[i].search_cnt = -1;	  lineInfo[i].quote = NULL;	  safe_realloc (&(lineInfo[i].syntax),			sizeof (struct syntax_t));	  if (SearchCompiled && lineInfo[i].search)	      FREE (&(lineInfo[i].search));	}	lastLine = 0;	topline = 0;	redraw = REDRAW_FULL | REDRAW_SIGWINCH;	ch = 0;      }      SigWinch = 0;      clearok(stdscr,TRUE);/*force complete redraw*/      continue;    }#endif    else if (ch == -1)    {      ch = 0;      continue;    }    rc = ch;    switch (ch)    {      case OP_EXIT:	rc = -1;	ch = -1;	break;      case OP_NEXT_PAGE:	if (lineInfo[curline].offset < sb.st_size-1)	{	  topline = upNLines (PagerContext, lineInfo, curline, hideQuoted);	}	else if (option (OPTPAGERSTOP))	{	  /* emulate "less -q" and don't go on to the next message. */	  mutt_error _("Bottom of message is shown.");	}	else	{	  /* end of the current message, so display the next message. */	  rc = OP_MAIN_NEXT_UNDELETED;	  ch = -1;	}	break;      case OP_PREV_PAGE:	if (topline != 0)	{	  topline = upNLines (bodylen-PagerContext, lineInfo, topline, hideQuoted);	}	else	  mutt_error _("Top of message is shown.");	break;      case OP_NEXT_LINE:	if (lineInfo[curline].offset < sb.st_size-1)	{	  topline++;	  if (hideQuoted)	  {	    while (lineInfo[topline].type == MT_COLOR_QUOTED &&		   topline < lastLine)	      topline++;	  }	}	else	  mutt_error _("Bottom of message is shown.");	break;      case OP_PREV_LINE:	if (topline)	  topline = upNLines (1, lineInfo, topline, hideQuoted);	else	  mutt_error _("Top of message is shown.");	break;      case OP_PAGER_TOP:        if (topline)	  topline = 0;      	else	  mutt_error _("Top of message is shown.");	break;      case OP_HALF_UP:	if (topline)	  topline = upNLines (bodylen/2, lineInfo, topline, hideQuoted);	else	  mutt_error _("Top of message is shown.");	break;      case OP_HALF_DOWN:	if (lineInfo[curline].offset < sb.st_size-1)	{	  topline = upNLines (bodylen/2, lineInfo, curline, hideQuoted);	}	else if (option (OPTPAGERSTOP))	{	  /* emulate "less -q" and don't go on to the next message. */	  mutt_error _("Bottom of message is shown.");	}	else	{	  /* end of the current message, so display the next message. */	  rc = OP_MAIN_NEXT_UNDELETED;	  ch = -1;	}	break;      case OP_SEARCH_NEXT:      case OP_SEARCH_OPPOSITE:	if (SearchCompiled)	{search_next:	  if ((!SearchBack && ch==OP_SEARCH_NEXT) ||	      (SearchBack &&ch==OP_SEARCH_OPPOSITE))	  {	    /* searching forward */	    for (i = topline + 1; i < lastLine; i++)	    {	      if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) && 		    !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)		break;	    }	    if (i < lastLine)	      topline = i;	    else	      mutt_error _("Not found.");	  }	  else	  {	    /* searching backward */	    for (i = topline - 1; i >= 0; i--)	    {	      if ((!hideQuoted || (has_types && 		    lineInfo[i].type != MT_COLOR_QUOTED)) && 		    !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)		break;	    }	    if (i >= 0)	      topline = i;	    else	      mutt_error _("Not found.");	  }	  if (lineInfo[topline].search_cnt > 0)	    SearchFlag = M_SEARCH;	  break;	}	/* no previous search pattern, so fall through to search */      case OP_SEARCH:      case OP_SEARCH_REVERSE:        strfcpy (buffer, searchbuf, sizeof (buffer));	if (mutt_get_field ((SearchBack ? _("Reverse search: ") :			  _("Search: ")), buffer, sizeof (buffer),			  M_CLEAR) != 0)	  break;	if (!strcmp (buffer, searchbuf))	{	  if (SearchCompiled)	  {	    /* do an implicit search-next */	    if (ch == OP_SEARCH)	      ch = OP_SEARCH_NEXT;	    else	      ch = OP_SEARCH_OPPOSITE;	    goto search_next;	  }	}              if (!buffer[0])	  break;      	strfcpy (searchbuf, buffer, sizeof (searchbuf));	/* leave SearchBack alone if ch == OP_SEARCH_NEXT */	if (ch == OP_SEARCH)	  SearchBack = 0;	else if (ch == OP_SEARCH_REVERSE)	  SearchBack = 1;	if (SearchCompiled)	{	  regfree (&SearchRE);	  for (i = 0; i < lastLine; i++)	  {	    if (lineInfo[i].search)	      FREE (&(lineInfo[i].search));	    lineInfo[i].search_cnt = -1;	  }	}	if ((err = REGCOMP (&SearchRE, searchbuf, REG_NEWLINE | mutt_which_case (searchbuf))) != 0)	{	  regerror (err, &SearchRE, buffer, sizeof (buffer));	  mutt_error ("%s", buffer);	  regfree (&SearchRE);	  for (i = 0; i < maxLine ; i++)	  {	    /* cleanup */	    if (lineInfo[i].search)	      FREE (&(lineInfo[i].search));	    lineInfo[i].search_cnt = -1;	  }	  SearchFlag = 0;	  SearchCompiled = 0;	}	else	{	  SearchCompiled = 1;	  /* update the search pointers */	  i = 0;	  while (display_line (fp, &last_pos, &lineInfo, i, &lastLine, 				&maxLine, M_SEARCH | (flags & M_PAGER_NSKIP),				&QuoteList, &q_level,				&force_redraw, &SearchRE) == 0)	    i++;	  if (!SearchBack)	  {	    /* searching forward */	    for (i = topline; i < lastLine; i++)	    {	      if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) && 		    !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)		break;	    }	    if (i < lastLine) topline = i;	  }	  else	  {	    /* searching backward */	    for (i = topline; i >= 0; i--)	    {	      if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) && 		    !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)		break;	    }	    if (i >= 0) topline = i;	  }	  if (lineInfo[topline].search_cnt == 0)	  {	    SearchFlag = 0;	    mutt_error _("Not found.");	  }	  else	    SearchFlag = M_SEARCH;	}	redraw = REDRAW_BODY;	break;      case OP_SEARCH_TOGGLE:	if (SearchCompiled)	{	  SearchFlag ^= M_SEARCH;	  redraw = REDRAW_BODY;	}	break;      case OP_HELP:	/* don't let the user enter the help-menu from the help screen! */	if (! InHelp)	{	  InHelp = 1;	  mutt_help (MENU_PAGER);	  redraw = REDRAW_FULL;	  InHelp = 0;	}	else	  mutt_error _("Help is currently being shown.");	break;      case OP_PAGER_HIDE_QUOTED:	if (has_types)	{	  hideQuoted ^= M_HIDE;	  if (hideQuoted && lineInfo[topline].type == MT_COLOR_QUOTED)	    topline = upNLines (1, lineInfo, topline, hideQuoted);	  else	    redraw = REDRAW_BODY;	}	break;      case OP_PAGER_SKIP_QUOTED:	if (has_types)	{	  int dretval = 0;	  int new_topline = topline;	  while ((new_topline < lastLine ||		  (0 == (dretval = display_line (fp, &last_pos, &lineInfo,			 new_topline, &lastLine, &maxLine, M_TYPES,			 &QuoteList, &q_level, &force_redraw, &SearchRE))))		 && lineInfo[new_topline].type != MT_COLOR_QUOTED)	    new_topline++;	  if (dretval < 0)	  {	    mutt_error _("No more quoted text.");	    break;	  }	  while ((new_topline < lastLine ||		  (0 == (dretval = display_line (fp, &last_pos, &lineInfo,			 new_topline, &lastLine, &maxLine, M_TYPES,			 &QuoteList, &q_level, &force_redraw, &SearchRE))))		 && lineInfo[new_topline].type == MT_COLOR_QUOTED)	    new_topline++;	  if (dretval < 0)	  {	    mutt_error _("No more unquoted text after quoted text.");	    break;	  	  }	  topline = new_topline;

⌨️ 快捷键说明

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