4 char path[_POSIX_PATH_MAX];
10 /* update postponed count as well, on force */
14 for (tmp = Incoming; tmp; tmp = tmp->next)
16 + if ( tmp->new == 1 )
19 if (tmp->magic != M_IMAP)
27 + if (STAT_CHECK || tmp->msgcount == 0)
34 + /* parse the mailbox, to see how much mail there is */
35 + ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
38 + msgcount = ctx->msgcount;
39 + msg_unread = ctx->unread;
40 + mx_close_mailbox(ctx, 0);
43 + tmp->msgcount = msgcount;
44 + tmp->msg_unread = msg_unread;
46 + tmp->has_new = tmp->new = 1;
50 else if (option(OPTCHECKMBOXSIZE))
53 if (tmp->newly_created &&
54 (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
55 tmp->newly_created = 0;
62 + /* count new message */
63 snprintf (path, sizeof (path), "%s/new", tmp->path);
64 if ((dirp = opendir (path)) == NULL)
70 + tmp->msg_unread = 0;
71 + tmp->msg_flagged = 0;
72 while ((de = readdir (dirp)) != NULL)
75 if (*de->d_name != '.' &&
76 (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
78 - /* one new and undeleted message is enough */
82 + tmp->has_new = tmp->new = 1;
93 + * count read messages (for folderlist (sidebar) we also need to count
94 + * messages in cur so that we the total number of messages
96 + snprintf (path, sizeof (path), "%s/cur", tmp->path);
97 + if ((dirp = opendir (path)) == NULL)
102 + while ((de = readdir (dirp)) != NULL)
105 + if (*de->d_name != '.') {
106 + if ((p = strstr (de->d_name, ":2,"))) {
107 + if (!strchr (p + 3, 'T')) {
109 + if ( !strchr (p + 3, 'S'))
111 + if (strchr(p + 3, 'F'))
112 + tmp->msg_flagged++;
125 if ((tmp->new = mh_buffy (tmp->path)) > 0)
128 + if ((dp = opendir (path)) == NULL)
131 + while ((de = readdir (dp)))
133 + if (mh_valid_message (de->d_name))
136 + tmp->has_new = tmp->new = 1;
149 struct buffy_t *next;
150 + struct buffy_t *prev;
151 short new; /* mailbox has new mail */
152 + short has_new; /* set it new if new and not read */
153 + int msgcount; /* total number of messages */
154 + int msg_unread; /* number of unread messages */
155 + int msg_flagged; /* number of flagged messages */
156 short notified; /* user has been notified */
157 short magic; /* mailbox type */
158 short newly_created; /* mbox or mmdf just popped into existence */
162 { "bold", MT_COLOR_BOLD },
163 { "underline", MT_COLOR_UNDERLINE },
164 { "index", MT_COLOR_INDEX },
165 + { "sidebar_new", MT_COLOR_NEW },
166 + { "sidebar_flagged", MT_COLOR_FLAGGED },
174 #define HDR_XOFFSET 10
175 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
176 -#define W (COLS - HDR_XOFFSET)
177 +#define W (COLS - HDR_XOFFSET - SidebarWidth)
179 static char *Prompts[] =
181 @@ -115,16 +115,16 @@
182 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
185 - mvaddstr (HDR_CRYPT, 0, "Security: ");
186 + mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
187 else if (msg->security & APPLICATION_SMIME)
188 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
189 + mvaddstr (HDR_CRYPT, SidebarWidth, " S/MIME: ");
190 else if (msg->security & APPLICATION_PGP)
191 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
192 + mvaddstr (HDR_CRYPT, SidebarWidth, " PGP: ");
194 else if ((WithCrypto & APPLICATION_SMIME))
195 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
196 + mvaddstr (HDR_CRYPT, SidebarWidth, " S/MIME: ");
197 else if ((WithCrypto & APPLICATION_PGP))
198 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
199 + mvaddstr (HDR_CRYPT, SidebarWidth, " PGP: ");
207 - move (HDR_CRYPTINFO, 0);
208 + move (HDR_CRYPTINFO, SidebarWidth);
210 if ((WithCrypto & APPLICATION_PGP)
211 && msg->security & APPLICATION_PGP && msg->security & SIGN)
213 && (msg->security & ENCRYPT)
216 - mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
217 + mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
218 NONULL(SmimeCryptAlg));
225 - mvaddstr (HDR_MIX, 0, " Mix: ");
226 + mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
231 if (t && t[0] == '0' && t[1] == '\0')
234 - if (c + mutt_strlen (t) + 2 >= COLS)
235 + if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
242 rfc822_write_address (buf, sizeof (buf), addr, 1);
243 - mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
244 + mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
245 mutt_paddstr (W, buf);
248 @@ -255,10 +255,10 @@
249 draw_envelope_addr (HDR_TO, msg->env->to);
250 draw_envelope_addr (HDR_CC, msg->env->cc);
251 draw_envelope_addr (HDR_BCC, msg->env->bcc);
252 - mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
253 + mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
254 mutt_paddstr (W, NONULL (msg->env->subject));
255 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
256 - mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
257 + mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
258 mutt_paddstr (W, fcc);
264 SETCOLOR (MT_COLOR_STATUS);
265 - mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
266 + mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
267 BKGDSET (MT_COLOR_STATUS);
271 /* redraw the expanded list so the user can see the result */
273 rfc822_write_address (buf, sizeof (buf), *addr, 1);
274 - move (line, HDR_XOFFSET);
275 + move (line, HDR_XOFFSET+SidebarWidth);
276 mutt_paddstr (W, buf);
280 if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
282 mutt_str_replace (&msg->env->subject, buf);
283 - move (HDR_SUBJECT, HDR_XOFFSET);
284 + move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
286 if (msg->env->subject)
287 mutt_paddstr (W, msg->env->subject);
290 strfcpy (fcc, buf, fcclen);
291 mutt_pretty_mailbox (fcc, fcclen);
292 - move (HDR_FCC, HDR_XOFFSET);
293 + move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
294 mutt_paddstr (W, fcc);
305 +#include "sidebar.h"
310 menu->redraw |= REDRAW_STATUS;
313 - if (mutt_buffy_notify () && option (OPTBEEPNEW))
315 + if (mutt_buffy_notify ())
317 + menu->redraw |= REDRAW_FULL;
318 + if (option (OPTBEEPNEW))
325 if (menu->redraw & REDRAW_FULL)
327 menu_redraw_full (menu);
328 + draw_sidebar(menu->menu);
332 @@ -571,10 +578,13 @@
334 if (menu->redraw & REDRAW_STATUS)
337 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
339 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
340 SETCOLOR (MT_COLOR_STATUS);
341 BKGDSET (MT_COLOR_STATUS);
342 + set_buffystats(Context);
343 mutt_paddstr (COLS, buf);
344 SETCOLOR (MT_COLOR_NORMAL);
345 BKGDSET (MT_COLOR_NORMAL);
347 menu->oldcurrent = -1;
349 if (option (OPTARROWCURSOR))
350 - move (menu->current - menu->top + menu->offset, 2);
351 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
352 else if (option (OPTBRAILLEFRIENDLY))
353 move (menu->current - menu->top + menu->offset, 0);
355 @@ -1068,6 +1078,7 @@
356 menu->redraw = REDRAW_FULL;
359 + case OP_SIDEBAR_OPEN:
360 case OP_MAIN_CHANGE_FOLDER:
361 case OP_MAIN_NEXT_UNREAD_MAILBOX:
363 @@ -1099,7 +1110,11 @@
365 mutt_buffy (buf, sizeof (buf));
367 - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
368 + if ( op == OP_SIDEBAR_OPEN ) {
371 + strncpy( buf, CurBuffy->path, sizeof(buf) );
372 + } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
374 if (menu->menu == MENU_PAGER)
376 @@ -1117,6 +1132,7 @@
379 mutt_expand_path (buf, sizeof (buf));
381 if (mx_get_magic (buf) <= 0)
383 mutt_error (_("%s is not a mailbox."), buf);
384 @@ -2209,6 +2225,12 @@
388 + case OP_SIDEBAR_SCROLL_UP:
389 + case OP_SIDEBAR_SCROLL_DOWN:
390 + case OP_SIDEBAR_NEXT:
391 + case OP_SIDEBAR_PREV:
392 + scroll_sidebar(op, menu->menu);
395 if (menu->menu == MENU_MAIN)
396 km_error_key (MENU_MAIN);
402 #include "mutt_curses.h"
403 +#include "mutt_menu.h"
406 +#include "sidebar.h"
408 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
412 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
417 void mutt_tag_set_flag (int flag, int bf)
421 { "decrypt-save", OP_DECRYPT_SAVE, NULL },
424 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
425 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
426 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
427 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
428 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
434 { "what-key", OP_WHAT_KEY, NULL },
436 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
437 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
438 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
439 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
440 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
447 WHERE char *SendCharset;
448 WHERE char *Sendmail;
450 +WHERE char *SidebarDelim;
451 WHERE char *Signature;
452 WHERE char *SimpleSearch;
455 WHERE short ScoreThresholdRead;
456 WHERE short ScoreThresholdFlag;
458 +WHERE struct buffy_t *CurBuffy INITVAL(0);
459 +WHERE short DrawFullLine INITVAL(0);
460 +WHERE short SidebarWidth;
462 WHERE short ImapKeepalive;
463 WHERE short ImapPipelineDepth;
466 @@ -1594,6 +1594,22 @@
467 ** you may \fIunset\fP this setting.
470 + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
473 + ** This specifies the delimiter between the sidebar (if visible) and
476 + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
479 + ** This specifies whether or not to show sidebar (left-side list of folders).
481 + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
484 + ** The width of the sidebar.
486 { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
492 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
493 * safe_fopen() for mbox-style folders.
495 +#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */
497 /* mx_open_new_message() */
498 #define M_ADD_FROM 1 /* add a From_ line */
502 score.c send.c sendlib.c signal.c sort.c \
503 status.c system.c thread.c charset.c history.c lib.c \
504 muttlib.c editmsg.c mbyte.c \
505 - url.c ascii.c crypt-mod.c crypt-mod.h
506 + url.c ascii.c crypt-mod.c crypt-mod.h \
509 nodist_mutt_SOURCES = $(BUILT_SOURCES)
514 mutt_perror (ctx->path);
517 + ctx->atime = sb.st_atime;
518 ctx->mtime = sb.st_mtime;
519 ctx->size = sb.st_size;
523 ctx->size = sb.st_size;
524 ctx->mtime = sb.st_mtime;
525 + ctx->atime = sb.st_atime;
527 #ifdef NFS_ATTRIBUTE_HACK
528 if (sb.st_mtime > sb.st_atime)
532 #include "mutt_curses.h"
533 #include "mutt_menu.h"
535 +#include "sidebar.h"
541 char *scratch = safe_strdup (s);
542 int shift = option (OPTARROWCURSOR) ? 3 : 0;
543 - int cols = COLS - shift;
544 + int cols = COLS - shift - SidebarWidth;
546 mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
549 char buf[LONG_STRING];
553 for (i = menu->top; i < menu->top + menu->pagelen; i++)
557 if (option (OPTARROWCURSOR))
559 attrset (menu->color (i));
560 - CLEARLINE (i - menu->top + menu->offset);
561 + CLEARLINE_WIN (i - menu->top + menu->offset);
563 if (i == menu->current)
565 @@ -246,14 +248,14 @@
566 BKGDSET (MT_COLOR_INDICATOR);
569 - CLEARLINE (i - menu->top + menu->offset);
570 + CLEARLINE_WIN (i - menu->top + menu->offset);
571 print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
572 SETCOLOR (MT_COLOR_NORMAL);
573 BKGDSET (MT_COLOR_NORMAL);
577 - CLEARLINE (i - menu->top + menu->offset);
578 + CLEARLINE_WIN (i - menu->top + menu->offset);
586 - move (menu->oldcurrent + menu->offset - menu->top, 0);
587 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
588 SETCOLOR (MT_COLOR_NORMAL);
589 BKGDSET (MT_COLOR_NORMAL);
591 @@ -283,13 +285,13 @@
593 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
594 menu_pad_string (buf, sizeof (buf));
595 - move (menu->oldcurrent + menu->offset - menu->top, 3);
596 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
597 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
598 SETCOLOR (MT_COLOR_NORMAL);
601 /* now draw it in the new location */
602 - move (menu->current + menu->offset - menu->top, 0);
603 + move (menu->current + menu->offset - menu->top, SidebarWidth);
604 attrset (menu->color (menu->current));
605 ADDCOLOR (MT_COLOR_INDICATOR);
608 attrset (menu->color (menu->current));
609 ADDCOLOR (MT_COLOR_INDICATOR);
610 BKGDSET (MT_COLOR_INDICATOR);
611 - CLEARLINE (menu->current - menu->top + menu->offset);
612 + CLEARLINE_WIN (menu->current - menu->top + menu->offset);
613 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
614 SETCOLOR (MT_COLOR_NORMAL);
615 BKGDSET (MT_COLOR_NORMAL);
618 char buf[LONG_STRING];
620 - move (menu->current + menu->offset - menu->top, 0);
621 + move (menu->current + menu->offset - menu->top, SidebarWidth);
622 menu_make_entry (buf, sizeof (buf), menu, menu->current);
623 menu_pad_string (buf, sizeof (buf));
628 if (option (OPTARROWCURSOR))
629 - move (menu->current - menu->top + menu->offset, 2);
630 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
631 else if (option (OPTBRAILLEFRIENDLY))
632 move (menu->current - menu->top + menu->offset, 0);
640 +#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
641 #define CLEARLINE(x) move(x,0), clrtoeol()
642 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
643 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
672 unsigned int quiet : 1; /* inhibit status messages? */
673 unsigned int collapsed : 1; /* are all threads collapsed? */
674 unsigned int closing : 1; /* mailbox is being closed */
675 + unsigned int peekonly : 1; /* just taking a glance, revert atime */
678 void *data; /* driver specific data */
681 @@ -1217,6 +1217,8 @@
684 /* see if there's room to add content, else ignore */
685 + if ( DrawFullLine )
687 if ((col < COLS && wlen < destlen) || soft)
690 @@ -1259,6 +1261,52 @@
697 + if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
701 + /* get contents after padding */
702 + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
703 + len = mutt_strlen (buf);
704 + wid = mutt_strwidth (buf);
706 + /* try to consume as many columns as we can, if we don't have
707 + * memory for that, use as much memory as possible */
708 + pad = (COLS - SidebarWidth - col - wid) / pw;
709 + if (pad > 0 && wlen + (pad * pl) + len > destlen)
710 + pad = ((signed)(destlen - wlen - len)) / pl;
715 + memcpy (wptr, src, pl);
721 + else if (soft && pad < 0)
723 + /* \0-terminate dest for length computation in mutt_wstr_trunc() */
725 + /* make sure right part is at most as wide as display */
726 + len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
727 + /* truncate left so that right part fits completely in */
728 + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
729 + wptr = dest + wlen;
731 + if (len + wlen > destlen)
732 + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
733 + memcpy (wptr, buf, len);
740 break; /* skip rest of input */
746 * M_APPEND open mailbox for appending
747 * M_READONLY open mailbox in read-only mode
748 * M_QUIET only print error messages
749 + * M_PEEK revert atime where applicable
750 * ctx if non-null, context struct to use
752 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
755 if (flags & M_READONLY)
757 + if (flags & M_PEEK)
760 if (flags & (M_APPEND|M_NEWFOLDER))
763 void mx_fastclose_mailbox (CONTEXT *ctx)
773 + /* fix up the times so buffy won't get confused */
774 + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
776 + ut.actime = ctx->atime;
777 + ut.modtime = ctx->mtime;
778 + utime (ctx->path, &ut);
787 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
788 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
789 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
790 +OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
791 +OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
792 +OP_SIDEBAR_NEXT "go down to next mailbox"
793 +OP_SIDEBAR_PREV "go to previous mailbox"
794 +OP_SIDEBAR_OPEN "open hilighted mailbox"
801 +#include "sidebar.h"
803 #include "mutt_crypt.h"
805 @@ -1060,6 +1061,8 @@
808 int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
810 + wrap_cols -= SidebarWidth;
812 /* FIXME: this should come from lineInfo */
813 memset(&mbstate, 0, sizeof(mbstate));
814 @@ -1694,7 +1697,7 @@
815 if ((redraw & REDRAW_BODY) || topline != oldtopline)
818 - move (bodyoffset, 0);
819 + move (bodyoffset, SidebarWidth);
820 curline = oldtopline = topline;
823 @@ -1707,6 +1710,7 @@
824 &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
827 + move(lines + bodyoffset, SidebarWidth);
829 last_offset = lineInfo[curline].offset;
830 } while (force_redraw);
831 @@ -1720,6 +1724,7 @@
835 + move(lines + bodyoffset, SidebarWidth);
837 /* We are going to update the pager status bar, so it isn't
838 * necessary to reset to normal color now. */
839 @@ -1743,22 +1748,22 @@
840 /* print out the pager status bar */
841 SETCOLOR (MT_COLOR_STATUS);
842 BKGDSET (MT_COLOR_STATUS);
843 - CLEARLINE (statusoffset);
844 + CLEARLINE_WIN (statusoffset);
845 if (IsHeader (extra))
847 - size_t l1 = COLS * MB_LEN_MAX;
848 + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
849 size_t l2 = sizeof (buffer);
850 hfi.hdr = extra->hdr;
851 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
853 else if (IsMsgAttach (extra))
855 - size_t l1 = COLS * MB_LEN_MAX;
856 + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
857 size_t l2 = sizeof (buffer);
858 hfi.hdr = extra->bdy->hdr;
859 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
861 - mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner);
862 + mutt_paddstr (COLS-SidebarWidth, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner);
863 BKGDSET (MT_COLOR_NORMAL);
864 SETCOLOR (MT_COLOR_NORMAL);
865 if (option(OPTXTERMSETTITLES))
866 @@ -1775,18 +1780,23 @@
867 /* redraw the pager_index indicator, because the
868 * flags for this message might have changed. */
869 menu_redraw_current (index);
870 + draw_sidebar(MENU_PAGER);
872 /* print out the index status bar */
873 menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
875 - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
876 + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
877 SETCOLOR (MT_COLOR_STATUS);
878 BKGDSET (MT_COLOR_STATUS);
879 - mutt_paddstr (COLS, buffer);
880 + mutt_paddstr (COLS-SidebarWidth, buffer);
881 SETCOLOR (MT_COLOR_NORMAL);
882 BKGDSET (MT_COLOR_NORMAL);
885 + /* if we're not using the index, update every time */
887 + draw_sidebar(MENU_PAGER);
891 if (option(OPTBRAILLEFRIENDLY)) {
892 @@ -2684,6 +2694,13 @@
896 + case OP_SIDEBAR_SCROLL_UP:
897 + case OP_SIDEBAR_SCROLL_DOWN:
898 + case OP_SIDEBAR_NEXT:
899 + case OP_SIDEBAR_PREV:
900 + scroll_sidebar(ch, MENU_PAGER);
910 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
911 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
913 + * This program is free software; you can redistribute it and/or modify
914 + * it under the terms of the GNU General Public License as published by
915 + * the Free Software Foundation; either version 2 of the License, or
916 + * (at your option) any later version.
918 + * This program is distributed in the hope that it will be useful,
919 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
920 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
921 + * GNU General Public License for more details.
923 + * You should have received a copy of the GNU General Public License
924 + * along with this program; if not, write to the Free Software
925 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
930 +# include "config.h"
934 +#include "mutt_menu.h"
935 +#include "mutt_curses.h"
936 +#include "sidebar.h"
940 +#include <stdbool.h>
942 +/*BUFFY *CurBuffy = 0;*/
943 +static BUFFY *TopBuffy = 0;
944 +static BUFFY *BottomBuffy = 0;
945 +static int known_lines = 0;
947 +static int quick_log10(int n)
950 + sprintf(string, "%d", n);
951 + return strlen(string);
954 +void calc_boundaries (int menu)
956 + BUFFY *tmp = Incoming;
958 + if ( known_lines != LINES ) {
959 + TopBuffy = BottomBuffy = 0;
960 + known_lines = LINES;
962 + for ( ; tmp->next != 0; tmp = tmp->next )
963 + tmp->next->prev = tmp;
965 + if ( TopBuffy == 0 && BottomBuffy == 0 )
966 + TopBuffy = Incoming;
967 + if ( BottomBuffy == 0 ) {
968 + int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
969 + BottomBuffy = TopBuffy;
970 + while ( --count && BottomBuffy->next )
971 + BottomBuffy = BottomBuffy->next;
973 + else if ( TopBuffy == CurBuffy->next ) {
974 + int count = LINES - 2 - (menu != MENU_PAGER);
975 + BottomBuffy = CurBuffy;
977 + while ( --count && tmp->prev)
981 + else if ( BottomBuffy == CurBuffy->prev ) {
982 + int count = LINES - 2 - (menu != MENU_PAGER);
983 + TopBuffy = CurBuffy;
985 + while ( --count && tmp->next )
991 +char *make_sidebar_entry(char *box, int size, int new, int flagged)
993 + static char *entry = 0;
996 + int delim_len = strlen(SidebarDelim);
998 + c = realloc(entry, SidebarWidth - delim_len + 2);
999 + if ( c ) entry = c;
1000 + entry[SidebarWidth - delim_len + 1] = 0;
1001 + for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1003 + strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1006 + sprintf(entry + SidebarWidth - delim_len - 3, "?");
1008 + if (flagged > 0) {
1010 + entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1011 + "% d(%d)[%d]", size, new, flagged);
1014 + entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1015 + "% d(%d)", size, new);
1017 + } else if (flagged > 0) {
1018 + sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1020 + sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1025 +void set_curbuffy(char buf[LONG_STRING])
1027 + BUFFY* tmp = CurBuffy = Incoming;
1033 + if(!strcmp(tmp->path, buf)) {
1045 +int draw_sidebar(int menu) {
1047 + int lines = option(OPTHELP) ? 1 : 0;
1049 +#ifndef USE_SLANG_CURSES
1052 + short delim_len = strlen(SidebarDelim);
1055 + static bool initialized = false;
1056 + static int prev_show_value;
1057 + static short saveSidebarWidth;
1059 + /* initialize first time */
1060 + if(!initialized) {
1061 + prev_show_value = option(OPTSIDEBAR);
1062 + saveSidebarWidth = SidebarWidth;
1063 + if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1064 + initialized = true;
1067 + /* save or restore the value SidebarWidth */
1068 + if(prev_show_value != option(OPTSIDEBAR)) {
1069 + if(prev_show_value && !option(OPTSIDEBAR)) {
1070 + saveSidebarWidth = SidebarWidth;
1072 + } else if(!prev_show_value && option(OPTSIDEBAR)) {
1073 + SidebarWidth = saveSidebarWidth;
1075 + prev_show_value = option(OPTSIDEBAR);
1079 +// if ( SidebarWidth == 0 ) return 0;
1080 + if (SidebarWidth > 0 && option (OPTSIDEBAR)
1081 + && delim_len >= SidebarWidth) {
1082 + unset_option (OPTSIDEBAR);
1083 + /* saveSidebarWidth = SidebarWidth; */
1084 + if (saveSidebarWidth > delim_len) {
1085 + SidebarWidth = saveSidebarWidth;
1086 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1090 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1091 + sleep (4); /* the advise to set a sane value should be seen long enough */
1093 + saveSidebarWidth = 0;
1097 + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1098 + if (SidebarWidth > 0) {
1099 + saveSidebarWidth = SidebarWidth;
1102 + unset_option(OPTSIDEBAR);
1106 + /* get attributes for divider */
1107 + SETCOLOR(MT_COLOR_STATUS);
1108 +#ifndef USE_SLANG_CURSES
1109 + attr_get(&attrs, &color_pair, 0);
1111 + color_pair = attr_get();
1113 + SETCOLOR(MT_COLOR_NORMAL);
1115 + /* draw the divider */
1117 + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1118 + move(lines, SidebarWidth - delim_len);
1119 + addstr(NONULL(SidebarDelim));
1120 +#ifndef USE_SLANG_CURSES
1121 + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1125 + if ( Incoming == 0 ) return 0;
1126 + lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1128 + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 )
1129 + calc_boundaries(menu);
1130 + if ( CurBuffy == 0 ) CurBuffy = Incoming;
1134 + SETCOLOR(MT_COLOR_NORMAL);
1136 + for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1137 + if ( tmp == CurBuffy )
1138 + SETCOLOR(MT_COLOR_INDICATOR);
1139 + else if ( tmp->msg_unread > 0 )
1140 + SETCOLOR(MT_COLOR_NEW);
1141 + else if ( tmp->msg_flagged > 0 )
1142 + SETCOLOR(MT_COLOR_FLAGGED);
1144 + SETCOLOR(MT_COLOR_NORMAL);
1147 + if ( Context && !strcmp( tmp->path, Context->path ) ) {
1148 + tmp->msg_unread = Context->unread;
1149 + tmp->msgcount = Context->msgcount;
1150 + tmp->msg_flagged = Context->flagged;
1152 + // check whether Maildir is a prefix of the current folder's path
1153 + short maildir_is_prefix = 0;
1154 + if ( (strlen(tmp->path) > strlen(Maildir)) &&
1155 + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1156 + maildir_is_prefix = 1;
1157 + // calculate depth of current folder and generate its display name with indented spaces
1158 + int sidebar_folder_depth = 0;
1159 + char *sidebar_folder_name;
1160 + sidebar_folder_name = basename(tmp->path);
1161 + if ( maildir_is_prefix ) {
1162 + char *tmp_folder_name;
1164 + tmp_folder_name = tmp->path + strlen(Maildir);
1165 + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1166 + if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1168 + if (sidebar_folder_depth > 0) {
1169 + sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1170 + for (i=0; i < sidebar_folder_depth; i++)
1171 + sidebar_folder_name[i]=' ';
1172 + sidebar_folder_name[i]=0;
1173 + strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1176 + printw( "%.*s", SidebarWidth - delim_len + 1,
1177 + make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1178 + tmp->msg_unread, tmp->msg_flagged));
1179 + if (sidebar_folder_depth > 0)
1180 + free(sidebar_folder_name);
1183 + SETCOLOR(MT_COLOR_NORMAL);
1184 + for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1187 + for ( ; i < SidebarWidth - delim_len; i++ )
1194 +void set_buffystats(CONTEXT* Context)
1196 + BUFFY *tmp = Incoming;
1198 + if(Context && !strcmp(tmp->path, Context->path)) {
1199 + tmp->msg_unread = Context->unread;
1200 + tmp->msgcount = Context->msgcount;
1207 +void scroll_sidebar(int op, int menu)
1209 + if(!SidebarWidth) return;
1210 + if(!CurBuffy) return;
1213 + case OP_SIDEBAR_NEXT:
1214 + if ( CurBuffy->next == NULL ) return;
1215 + CurBuffy = CurBuffy->next;
1217 + case OP_SIDEBAR_PREV:
1218 + if ( CurBuffy->prev == NULL ) return;
1219 + CurBuffy = CurBuffy->prev;
1221 + case OP_SIDEBAR_SCROLL_UP:
1222 + CurBuffy = TopBuffy;
1223 + if ( CurBuffy != Incoming ) {
1224 + calc_boundaries(menu);
1225 + CurBuffy = CurBuffy->prev;
1228 + case OP_SIDEBAR_SCROLL_DOWN:
1229 + CurBuffy = BottomBuffy;
1230 + if ( CurBuffy->next ) {
1231 + calc_boundaries(menu);
1232 + CurBuffy = CurBuffy->next;
1238 + calc_boundaries(menu);
1239 + draw_sidebar(menu);
1246 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1247 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1249 + * This program is free software; you can redistribute it and/or modify
1250 + * it under the terms of the GNU General Public License as published by
1251 + * the Free Software Foundation; either version 2 of the License, or
1252 + * (at your option) any later version.
1254 + * This program is distributed in the hope that it will be useful,
1255 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1256 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1257 + * GNU General Public License for more details.
1259 + * You should have received a copy of the GNU General Public License
1260 + * along with this program; if not, write to the Free Software
1261 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
1273 +/* parameter is whether or not to go to the status line */
1274 +/* used for omitting the last | that covers up the status bar in the index */
1275 +int draw_sidebar(int);
1276 +void scroll_sidebar(int, int);
1277 +void set_curbuffy(char*);
1278 +void set_buffystats(CONTEXT*);
1280 +#endif /* SIDEBAR_H */
1283 @@ -2167,6 +2167,26 @@
1287 +# set sidebar_visible=no
1289 +# Name: sidebar_visible
1294 +# This specifies whether or not to show sidebar (left-side list of folders).
1297 +# set sidebar_width=0
1299 +# Name: sidebar_width
1304 +# The width of the sidebar.
1307 # set crypt_autosign=no
1309 # Name: crypt_autosign
1312 @@ -1513,7 +1513,7 @@
1314 imap_munge_mbox_name (munged, sizeof (munged), name);
1315 snprintf (command, sizeof (command),
1316 - "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
1317 + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
1319 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
1321 --- a/imap/command.c
1322 +++ b/imap/command.c
1323 @@ -1009,6 +1009,13 @@
1325 status->uidnext = oldun;
1327 + /* Added to make the sidebar show the correct numbers */
1328 + if (status->messages)
1330 + inc->msgcount = status->messages;
1331 + inc->msg_unread = status->unseen;
1340 +patch-1.5.19.sidebar.20090522.txt