X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pager.c;h=95d1f08694f71fa23ea51b788490527e581c176a;hp=1cf451d4078bd3b0f949423de21bcf611da5d98d;hb=44f97e3b57de6d306b9a1a9b58f992b80e920213;hpb=047342c2a0526885217e03d06e9b7a715f55b92f diff --git a/pager.c b/pager.c index 1cf451d..95d1f08 100644 --- a/pager.c +++ b/pager.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "mutt_curses.h" #include "mutt_regex.h" @@ -971,7 +975,7 @@ fill_buffer (FILE *f, long *last_pos, long offset, unsigned char *buf, unsigned char *fmt, size_t blen, int *buf_ready) { unsigned char *p; - static int b_read; + static int b_read = 0; if (*buf_ready == 0) { @@ -1038,8 +1042,11 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, wchar_t wc; mbstate_t mbstate; - int wrap_cols = COLS - WrapMargin - SidebarWidth; - + int wrap_cols = COLS; + if (!(flags & (M_SHOWFLAT))) + wrap_cols -= WrapMargin; + wrap_cols -= SidebarWidth; + if (wrap_cols <= 0) wrap_cols = COLS; @@ -1447,57 +1454,6 @@ upNLines (int nlines, struct line_t *info, int cur, int hiding) return cur; } -static void -mutt_display_xface (HEADER *hdr) -{ - LIST *face; - char buf[2000]; - - if (slrnface_fd < 0) - return; - - if (!hdr) - return; - - face = hdr->env->x_face; - - if (face == NULL || face->data == NULL) - write(slrnface_fd, "clear\n", sizeof "clear"); - else - do { - int len; - - len = snprintf (buf, sizeof (buf), "xface %s\n", face->data); - if (len <= sizeof (buf)) - { - write (slrnface_fd, buf, len); - break; - } - /* - * slrnface will ignore X-Faces larger than approx. 2000 chars, so - * try the next one, if it exists. - */ - } while (face = face->next); -} - -static void -mutt_clear_xface (void) -{ - if (slrnface_fd < 0) - return; - - write(slrnface_fd, "clear\n", sizeof "clear"); -} - -static void -mutt_show_xface (void) -{ - if (slrnface_fd < 0) - return; - - write(slrnface_fd, "show\n", sizeof "show"); -} - static struct mapping_t PagerHelp[] = { { N_("Exit"), OP_EXIT }, { N_("PrevPg"), OP_PREV_PAGE }, @@ -1620,9 +1576,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer); } - if (IsHeader (extra)) - mutt_display_xface(extra->hdr); - while (ch != -1) { mutt_curs_set (0); @@ -1731,13 +1684,15 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) 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; - } + &SearchRE) == 0) { + if (!lineInfo[i].continuation && ++j == lines) + { + topline = i; + if (!SearchFlag) + break; + } + redraw |= REDRAW_SIDEBAR; + } /* while */ } if ((redraw & REDRAW_BODY) || topline != oldtopline) @@ -1757,6 +1712,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) lines++; curline++; move(lines + bodyoffset, SidebarWidth); + redraw |= REDRAW_SIDEBAR; } last_offset = lineInfo[curline].offset; } while (force_redraw); @@ -1786,17 +1742,17 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) CLEARLINE_WIN(statusoffset); if (IsHeader (extra)) { - _mutt_make_string (buffer, - COLS-9-SidebarWidth < sizeof (buffer) ? - COLS-9-SidebarWidth : sizeof (buffer), - NONULL (PagerFmt), Context, extra->hdr, M_FORMAT_MAKEPRINT); + 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)) { - _mutt_make_string (buffer, - COLS - 9 - SidebarWidth < sizeof (buffer) ? - COLS - 9 - SidebarWidth : sizeof (buffer), - NONULL (PagerFmt), Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT); + 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-SidebarWidth, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner); @@ -1809,18 +1765,20 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) SETCOLOR (MT_COLOR_NORMAL); } + if (redraw & REDRAW_SIDEBAR) + draw_sidebar(MENU_PAGER); + if ((redraw & REDRAW_INDEX) && index) { /* redraw the pager_index indicator, because the * flags for this message might have changed. */ menu_redraw_current (index); - draw_sidebar(MENU_PAGER); + draw_sidebar(MENU_PAGER); /* print out the index status bar */ menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), - SidebarWidth); + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),option(OPTSTATUSONTOP)?0:SidebarWidth); SETCOLOR (MT_COLOR_STATUS); - mutt_paddstr (COLS-SidebarWidth, buffer); + mutt_paddstr (COLS-(option(OPTSTATUSONTOP)?0:SidebarWidth), buffer); SETCOLOR (MT_COLOR_NORMAL); } /* if we're not using the index, update every time */ @@ -2100,8 +2058,10 @@ search_next: while (display_line (fp, &last_pos, &lineInfo, i, &lastLine, &maxLine, M_SEARCH | (flags & M_PAGER_NSKIP), &QuoteList, &q_level, - &force_redraw, &SearchRE) == 0) + &force_redraw, &SearchRE) == 0) { i++; + redraw |= REDRAW_SIDEBAR; + } if (!SearchBack) { @@ -2152,9 +2112,7 @@ search_next: if (! InHelp) { InHelp = 1; - mutt_clear_xface (); mutt_help (MENU_PAGER); - mutt_show_xface (); redraw = REDRAW_FULL; InHelp = 0; } @@ -2183,8 +2141,10 @@ search_next: (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) + && lineInfo[new_topline].type != MT_COLOR_QUOTED) { + redraw |= REDRAW_SIDEBAR; new_topline++; + } if (dretval < 0) { @@ -2196,8 +2156,10 @@ search_next: (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) + && lineInfo[new_topline].type == MT_COLOR_QUOTED) { new_topline++; + redraw |= REDRAW_SIDEBAR; + } if (dretval < 0) { @@ -2216,8 +2178,10 @@ search_next: while (display_line (fp, &last_pos, &lineInfo, i, &lastLine, &maxLine, has_types, &QuoteList, &q_level, &force_redraw, - &SearchRE) == 0) + &SearchRE) == 0) { i++; + redraw |= REDRAW_SIDEBAR; + } topline = upNLines (bodylen, lineInfo, lastLine, hideQuoted); } else @@ -2260,6 +2224,17 @@ search_next: mutt_resend_message (NULL, extra->ctx, extra->hdr); redraw = REDRAW_FULL; break; + + case OP_CHECK_TRADITIONAL: + CHECK_MODE (IsHeader (extra)); + if (!(WithCrypto & APPLICATION_PGP)) + break; + if (!(extra->hdr->security & PGP_TRADITIONAL_CHECKED)) + { + ch = -1; + rc = OP_CHECK_TRADITIONAL; + } + break; case OP_CREATE_ALIAS: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); @@ -2401,6 +2376,7 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); &QuoteList, &q_level, &force_redraw, &SearchRE) == 0) { + redraw |= REDRAW_SIDEBAR; if (! lineInfo[topline].continuation) j--; if (j > 0) @@ -2471,9 +2447,7 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE); case OP_MAIL: CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); CHECK_ATTACH; - mutt_clear_xface(); - ci_send_message (0, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); + ci_send_message (0, NULL, NULL, extra->ctx, NULL); redraw = REDRAW_FULL; break; @@ -2481,20 +2455,17 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE); case OP_POST: CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); CHECK_ATTACH; - mutt_clear_xface(); if (extra->ctx && extra->ctx->magic == M_NNTP && !((NNTP_DATA *)extra->ctx->data)->allowed && query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) break; ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL); - mutt_show_xface(); redraw = REDRAW_FULL; break; case OP_FORWARD_TO_GROUP: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; - mutt_clear_xface(); if (extra->ctx && extra->ctx->magic == M_NNTP && !((NNTP_DATA *)extra->ctx->data)->allowed && query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) @@ -2504,14 +2475,12 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE); extra->idxlen, extra->bdy, SENDNEWS); else ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); redraw = REDRAW_FULL; break; case OP_FOLLOWUP: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; - mutt_clear_xface(); if (IsMsgAttach (extra)) followup_to = extra->bdy->hdr->env->followup_to; @@ -2531,7 +2500,6 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE); else ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); redraw = REDRAW_FULL; break; } @@ -2539,63 +2507,53 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE); case OP_REPLY: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); - CHECK_ATTACH; - mutt_clear_xface(); + CHECK_ATTACH; if (IsMsgAttach (extra)) mutt_attach_reply (extra->fp, extra->hdr, extra->idx, extra->idxlen, extra->bdy, SENDREPLY); else ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); redraw = REDRAW_FULL; break; case OP_RECALL_MESSAGE: - CHECK_MODE(IsHeader (extra)); + CHECK_MODE(IsHeader (extra) && !IsAttach(extra)); CHECK_ATTACH; - mutt_clear_xface(); ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); redraw = REDRAW_FULL; break; case OP_GROUP_REPLY: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; - mutt_clear_xface(); if (IsMsgAttach (extra)) mutt_attach_reply (extra->fp, extra->hdr, extra->idx, extra->idxlen, extra->bdy, SENDREPLY|SENDGROUPREPLY); else ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); redraw = REDRAW_FULL; break; case OP_LIST_REPLY: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; - mutt_clear_xface(); if (IsMsgAttach (extra)) mutt_attach_reply (extra->fp, extra->hdr, extra->idx, extra->idxlen, extra->bdy, SENDREPLY|SENDLISTREPLY); else ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); redraw = REDRAW_FULL; break; case OP_FORWARD_MESSAGE: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; - mutt_clear_xface(); if (IsMsgAttach (extra)) mutt_attach_forward (extra->fp, extra->hdr, extra->idx, extra->idxlen, extra->bdy, 0); else ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); - mutt_show_xface(); redraw = REDRAW_FULL; break; @@ -2645,15 +2603,18 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE); break; case OP_SHELL_ESCAPE: - mutt_clear_xface (); mutt_shell_escape (); - mutt_show_xface (); MAYBE_REDRAW (redraw); break; case OP_TAG: CHECK_MODE(IsHeader (extra)); mutt_set_flag (Context, extra->hdr, M_TAG, !extra->hdr->tagged); + + Context->last_tag = extra->hdr->tagged ? extra->hdr : + ((Context->last_tag == extra->hdr && !extra->hdr->tagged) + ? NULL : Context->last_tag); + redraw = REDRAW_STATUS | REDRAW_INDEX; if (option (OPTRESOLVE)) { @@ -2786,7 +2747,9 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); case OP_SIDEBAR_SCROLL_UP: case OP_SIDEBAR_SCROLL_DOWN: case OP_SIDEBAR_NEXT: + case OP_SIDEBAR_NEXT_NEW: case OP_SIDEBAR_PREV: + case OP_SIDEBAR_PREV_NEW: scroll_sidebar(ch, MENU_PAGER); break; default: @@ -2815,6 +2778,5 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); FREE (&lineInfo); if (index) mutt_menuDestroy(&index); - mutt_clear_xface (); return (rc != -1 ? rc : 0); }