1 This is the sidebar patch.
3 When enabled, mutt will show a list of mailboxes with (new) message counts in a
4 separate column on the left side of the screen.
6 As this feature is still considered to be unstable, this patch is only applied
7 in the "mutt-patched" package.
9 * Configuration variables:
11 sidebar_delim (string, default "|")
13 This specifies the delimiter between the sidebar (if visible) and
16 sidebar_visible (boolean, default no)
18 This specifies whether or not to show sidebar (left-side list of folders).
20 sidebar_width (integer, default 0)
22 The width of the sidebar.
25 - http://www.lunar-linux.org/index.php?page=mutt-sidebar
26 - http://lunar-linux.org/~tchan/mutt/patch-1.5.19.sidebar.20090522.txt
29 - 2008-08-02 myon: Refreshed patch using quilt push -f to remove hunks we do
30 not need (Makefile.in).
33 ===================================================================
34 --- mutt.orig/buffy.c 2009-06-25 12:36:44.000000000 +0200
35 +++ mutt/buffy.c 2009-06-25 12:36:53.000000000 +0200
37 char path[_POSIX_PATH_MAX];
38 struct stat contex_sb;
46 for (tmp = Incoming; tmp; tmp = tmp->next)
48 + if ( tmp->new == 1 )
51 if (tmp->magic != M_IMAP)
59 + if (STAT_CHECK || tmp->msgcount == 0)
66 + /* parse the mailbox, to see how much mail there is */
67 + ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
70 + msgcount = ctx->msgcount;
71 + msg_unread = ctx->unread;
72 + mx_close_mailbox(ctx, 0);
75 + tmp->msgcount = msgcount;
76 + tmp->msg_unread = msg_unread;
78 + tmp->has_new = tmp->new = 1;
82 else if (option(OPTCHECKMBOXSIZE))
85 if (tmp->newly_created &&
86 (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
87 tmp->newly_created = 0;
94 + /* count new message */
95 snprintf (path, sizeof (path), "%s/new", tmp->path);
96 if ((dirp = opendir (path)) == NULL)
102 + tmp->msg_unread = 0;
103 + tmp->msg_flagged = 0;
104 while ((de = readdir (dirp)) != NULL)
107 if (*de->d_name != '.' &&
108 (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
110 - /* one new and undeleted message is enough */
114 + tmp->has_new = tmp->new = 1;
119 + if(tmp->msg_unread)
125 + * count read messages (for folderlist (sidebar) we also need to count
126 + * messages in cur so that we the total number of messages
128 + snprintf (path, sizeof (path), "%s/cur", tmp->path);
129 + if ((dirp = opendir (path)) == NULL)
134 + while ((de = readdir (dirp)) != NULL)
137 + if (*de->d_name != '.') {
138 + if ((p = strstr (de->d_name, ":2,"))) {
139 + if (!strchr (p + 3, 'T')) {
141 + if ( !strchr (p + 3, 'S'))
143 + if (strchr(p + 3, 'F'))
144 + tmp->msg_flagged++;
157 if ((tmp->new = mh_buffy (tmp->path)) > 0)
160 + if ((dp = opendir (path)) == NULL)
163 + while ((de = readdir (dp)))
165 + if (mh_valid_message (de->d_name))
168 + tmp->has_new = tmp->new = 1;
177 ===================================================================
178 --- mutt.orig/buffy.h 2009-06-24 19:37:58.000000000 +0200
179 +++ mutt/buffy.h 2009-06-25 12:36:53.000000000 +0200
181 char path[_POSIX_PATH_MAX];
183 struct buffy_t *next;
184 + struct buffy_t *prev;
185 short new; /* mailbox has new mail */
186 + short has_new; /* set it new if new and not read */
187 + int msgcount; /* total number of messages */
188 + int msg_unread; /* number of unread messages */
189 + int msg_flagged; /* number of flagged messages */
190 short notified; /* user has been notified */
191 short magic; /* mailbox type */
192 short newly_created; /* mbox or mmdf just popped into existence */
194 ===================================================================
195 --- mutt.orig/color.c 2009-06-24 19:37:58.000000000 +0200
196 +++ mutt/color.c 2009-06-25 12:36:53.000000000 +0200
198 { "bold", MT_COLOR_BOLD },
199 { "underline", MT_COLOR_UNDERLINE },
200 { "index", MT_COLOR_INDEX },
201 + { "sidebar_new", MT_COLOR_NEW },
202 + { "sidebar_flagged", MT_COLOR_FLAGGED },
206 Index: mutt/compose.c
207 ===================================================================
208 --- mutt.orig/compose.c 2009-06-24 19:37:58.000000000 +0200
209 +++ mutt/compose.c 2009-06-25 12:36:53.000000000 +0200
212 #define HDR_XOFFSET 10
213 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
214 -#define W (COLS - HDR_XOFFSET)
215 +#define W (COLS - HDR_XOFFSET - SidebarWidth)
217 static char *Prompts[] =
219 @@ -115,16 +115,16 @@
220 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
223 - mvaddstr (HDR_CRYPT, 0, "Security: ");
224 + mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
225 else if (msg->security & APPLICATION_SMIME)
226 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
227 + mvaddstr (HDR_CRYPT, SidebarWidth, " S/MIME: ");
228 else if (msg->security & APPLICATION_PGP)
229 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
230 + mvaddstr (HDR_CRYPT, SidebarWidth, " PGP: ");
232 else if ((WithCrypto & APPLICATION_SMIME))
233 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
234 + mvaddstr (HDR_CRYPT, SidebarWidth, " S/MIME: ");
235 else if ((WithCrypto & APPLICATION_PGP))
236 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
237 + mvaddstr (HDR_CRYPT, SidebarWidth, " PGP: ");
245 - move (HDR_CRYPTINFO, 0);
246 + move (HDR_CRYPTINFO, SidebarWidth);
248 if ((WithCrypto & APPLICATION_PGP)
249 && msg->security & APPLICATION_PGP && msg->security & SIGN)
251 && (msg->security & ENCRYPT)
254 - mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
255 + mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
256 NONULL(SmimeCryptAlg));
263 - mvaddstr (HDR_MIX, 0, " Mix: ");
264 + mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
269 if (t && t[0] == '0' && t[1] == '\0')
272 - if (c + mutt_strlen (t) + 2 >= COLS)
273 + if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
280 rfc822_write_address (buf, sizeof (buf), addr, 1);
281 - mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
282 + mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
283 mutt_paddstr (W, buf);
286 @@ -255,10 +255,10 @@
287 draw_envelope_addr (HDR_TO, msg->env->to);
288 draw_envelope_addr (HDR_CC, msg->env->cc);
289 draw_envelope_addr (HDR_BCC, msg->env->bcc);
290 - mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
291 + mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
292 mutt_paddstr (W, NONULL (msg->env->subject));
293 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
294 - mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
295 + mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
296 mutt_paddstr (W, fcc);
302 SETCOLOR (MT_COLOR_STATUS);
303 - mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
304 + mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
305 BKGDSET (MT_COLOR_STATUS);
309 /* redraw the expanded list so the user can see the result */
311 rfc822_write_address (buf, sizeof (buf), *addr, 1);
312 - move (line, HDR_XOFFSET);
313 + move (line, HDR_XOFFSET+SidebarWidth);
314 mutt_paddstr (W, buf);
318 if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
320 mutt_str_replace (&msg->env->subject, buf);
321 - move (HDR_SUBJECT, HDR_XOFFSET);
322 + move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
324 if (msg->env->subject)
325 mutt_paddstr (W, msg->env->subject);
328 strfcpy (fcc, buf, fcclen);
329 mutt_pretty_mailbox (fcc, fcclen);
330 - move (HDR_FCC, HDR_XOFFSET);
331 + move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
332 mutt_paddstr (W, fcc);
335 Index: mutt/curs_main.c
336 ===================================================================
337 --- mutt.orig/curs_main.c 2009-06-25 12:36:26.000000000 +0200
338 +++ mutt/curs_main.c 2009-06-25 12:36:53.000000000 +0200
345 +#include "sidebar.h"
350 menu->redraw |= REDRAW_STATUS;
353 - if (mutt_buffy_notify () && option (OPTBEEPNEW))
355 + if (mutt_buffy_notify ())
357 + menu->redraw |= REDRAW_FULL;
358 + if (option (OPTBEEPNEW))
365 if (menu->redraw & REDRAW_FULL)
367 menu_redraw_full (menu);
368 + draw_sidebar(menu->menu);
372 @@ -571,10 +578,13 @@
374 if (menu->redraw & REDRAW_STATUS)
377 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
379 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
380 SETCOLOR (MT_COLOR_STATUS);
381 BKGDSET (MT_COLOR_STATUS);
382 + set_buffystats(Context);
383 mutt_paddstr (COLS, buf);
384 SETCOLOR (MT_COLOR_NORMAL);
385 BKGDSET (MT_COLOR_NORMAL);
387 menu->oldcurrent = -1;
389 if (option (OPTARROWCURSOR))
390 - move (menu->current - menu->top + menu->offset, 2);
391 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
392 else if (option (OPTBRAILLEFRIENDLY))
393 move (menu->current - menu->top + menu->offset, 0);
395 @@ -1075,6 +1085,7 @@
396 menu->redraw = REDRAW_FULL;
399 + case OP_SIDEBAR_OPEN:
400 case OP_MAIN_CHANGE_FOLDER:
401 case OP_MAIN_NEXT_UNREAD_MAILBOX:
403 @@ -1106,7 +1117,11 @@
405 mutt_buffy (buf, sizeof (buf));
407 - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
408 + if ( op == OP_SIDEBAR_OPEN ) {
411 + strncpy( buf, CurBuffy->path, sizeof(buf) );
412 + } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
414 if (menu->menu == MENU_PAGER)
416 @@ -1124,6 +1139,7 @@
419 mutt_expand_path (buf, sizeof (buf));
421 if (mx_get_magic (buf) <= 0)
423 mutt_error (_("%s is not a mailbox."), buf);
424 @@ -2216,6 +2232,12 @@
428 + case OP_SIDEBAR_SCROLL_UP:
429 + case OP_SIDEBAR_SCROLL_DOWN:
430 + case OP_SIDEBAR_NEXT:
431 + case OP_SIDEBAR_PREV:
432 + scroll_sidebar(op, menu->menu);
435 if (menu->menu == MENU_MAIN)
436 km_error_key (MENU_MAIN);
438 ===================================================================
439 --- mutt.orig/flags.c 2009-06-25 12:36:14.000000000 +0200
440 +++ mutt/flags.c 2009-06-25 12:36:53.000000000 +0200
444 #include "mutt_curses.h"
445 +#include "mutt_menu.h"
448 +#include "sidebar.h"
450 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
454 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
459 void mutt_tag_set_flag (int flag, int bf)
460 Index: mutt/functions.h
461 ===================================================================
462 --- mutt.orig/functions.h 2009-06-25 12:36:35.000000000 +0200
463 +++ mutt/functions.h 2009-06-25 12:36:53.000000000 +0200
465 { "decrypt-save", OP_DECRYPT_SAVE, NULL },
468 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
469 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
470 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
471 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
472 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
478 { "what-key", OP_WHAT_KEY, NULL },
480 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
481 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
482 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
483 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
484 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
488 Index: mutt/globals.h
489 ===================================================================
490 --- mutt.orig/globals.h 2009-06-25 12:36:22.000000000 +0200
491 +++ mutt/globals.h 2009-06-25 12:36:53.000000000 +0200
493 WHERE char *SendCharset;
494 WHERE char *Sendmail;
496 +WHERE char *SidebarDelim;
497 WHERE char *Signature;
498 WHERE char *SimpleSearch;
501 WHERE short ScoreThresholdRead;
502 WHERE short ScoreThresholdFlag;
504 +WHERE struct buffy_t *CurBuffy INITVAL(0);
505 +WHERE short DrawFullLine INITVAL(0);
506 +WHERE short SidebarWidth;
508 WHERE short ImapKeepalive;
509 WHERE short ImapPipelineDepth;
511 ===================================================================
512 --- mutt.orig/init.h 2009-06-25 12:36:40.000000000 +0200
513 +++ mutt/init.h 2009-06-25 12:36:53.000000000 +0200
514 @@ -1953,6 +1953,22 @@
518 + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
521 + ** This specifies the delimiter between the sidebar (if visible) and
524 + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
527 + ** This specifies whether or not to show sidebar (left-side list of folders).
529 + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
532 + ** The width of the sidebar.
534 { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
537 Index: mutt/mailbox.h
538 ===================================================================
539 --- mutt.orig/mailbox.h 2009-06-24 19:37:58.000000000 +0200
540 +++ mutt/mailbox.h 2009-06-25 12:36:53.000000000 +0200
542 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
543 * safe_fopen() for mbox-style folders.
545 +#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */
547 /* mx_open_new_message() */
548 #define M_ADD_FROM 1 /* add a From_ line */
549 Index: mutt/Makefile.am
550 ===================================================================
551 --- mutt.orig/Makefile.am 2009-06-25 12:36:26.000000000 +0200
552 +++ mutt/Makefile.am 2009-06-25 12:36:53.000000000 +0200
554 score.c send.c sendlib.c signal.c sort.c \
555 status.c system.c thread.c charset.c history.c lib.c \
556 muttlib.c editmsg.c mbyte.c \
557 - url.c ascii.c crypt-mod.c crypt-mod.h
558 + url.c ascii.c crypt-mod.c crypt-mod.h \
561 nodist_mutt_SOURCES = $(BUILT_SOURCES)
564 ===================================================================
565 --- mutt.orig/mbox.c 2009-06-25 12:36:45.000000000 +0200
566 +++ mutt/mbox.c 2009-06-25 12:36:53.000000000 +0200
568 mutt_perror (ctx->path);
571 + ctx->atime = sb.st_atime;
572 ctx->mtime = sb.st_mtime;
573 ctx->size = sb.st_size;
577 ctx->size = sb.st_size;
578 ctx->mtime = sb.st_mtime;
579 + ctx->atime = sb.st_atime;
581 #ifdef NFS_ATTRIBUTE_HACK
582 if (sb.st_mtime > sb.st_atime)
584 ===================================================================
585 --- mutt.orig/menu.c 2009-06-25 12:36:19.000000000 +0200
586 +++ mutt/menu.c 2009-06-25 12:36:53.000000000 +0200
588 #include "mutt_curses.h"
589 #include "mutt_menu.h"
591 +#include "sidebar.h"
597 char *scratch = safe_strdup (s);
598 int shift = option (OPTARROWCURSOR) ? 3 : 0;
599 - int cols = COLS - shift;
600 + int cols = COLS - shift - SidebarWidth;
602 mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
605 char buf[LONG_STRING];
609 for (i = menu->top; i < menu->top + menu->pagelen; i++)
613 if (option (OPTARROWCURSOR))
615 attrset (menu->color (i));
616 - CLEARLINE (i - menu->top + menu->offset);
617 + CLEARLINE_WIN (i - menu->top + menu->offset);
619 if (i == menu->current)
621 @@ -246,14 +248,14 @@
622 BKGDSET (MT_COLOR_INDICATOR);
625 - CLEARLINE (i - menu->top + menu->offset);
626 + CLEARLINE_WIN (i - menu->top + menu->offset);
627 print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
628 SETCOLOR (MT_COLOR_NORMAL);
629 BKGDSET (MT_COLOR_NORMAL);
633 - CLEARLINE (i - menu->top + menu->offset);
634 + CLEARLINE_WIN (i - menu->top + menu->offset);
642 - move (menu->oldcurrent + menu->offset - menu->top, 0);
643 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
644 SETCOLOR (MT_COLOR_NORMAL);
645 BKGDSET (MT_COLOR_NORMAL);
647 @@ -283,13 +285,13 @@
649 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
650 menu_pad_string (buf, sizeof (buf));
651 - move (menu->oldcurrent + menu->offset - menu->top, 3);
652 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
653 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
654 SETCOLOR (MT_COLOR_NORMAL);
657 /* now draw it in the new location */
658 - move (menu->current + menu->offset - menu->top, 0);
659 + move (menu->current + menu->offset - menu->top, SidebarWidth);
660 attrset (menu->color (menu->current));
661 ADDCOLOR (MT_COLOR_INDICATOR);
664 attrset (menu->color (menu->current));
665 ADDCOLOR (MT_COLOR_INDICATOR);
666 BKGDSET (MT_COLOR_INDICATOR);
667 - CLEARLINE (menu->current - menu->top + menu->offset);
668 + CLEARLINE_WIN (menu->current - menu->top + menu->offset);
669 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
670 SETCOLOR (MT_COLOR_NORMAL);
671 BKGDSET (MT_COLOR_NORMAL);
674 char buf[LONG_STRING];
676 - move (menu->current + menu->offset - menu->top, 0);
677 + move (menu->current + menu->offset - menu->top, SidebarWidth);
678 menu_make_entry (buf, sizeof (buf), menu, menu->current);
679 menu_pad_string (buf, sizeof (buf));
684 if (option (OPTARROWCURSOR))
685 - move (menu->current - menu->top + menu->offset, 2);
686 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
687 else if (option (OPTBRAILLEFRIENDLY))
688 move (menu->current - menu->top + menu->offset, 0);
690 Index: mutt/mutt_curses.h
691 ===================================================================
692 --- mutt.orig/mutt_curses.h 2009-06-24 19:37:58.000000000 +0200
693 +++ mutt/mutt_curses.h 2009-06-25 12:36:53.000000000 +0200
698 +#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
699 #define CLEARLINE(x) move(x,0), clrtoeol()
700 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
701 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
712 ===================================================================
713 --- mutt.orig/mutt.h 2009-06-25 12:36:26.000000000 +0200
714 +++ mutt/mutt.h 2009-06-25 12:36:53.000000000 +0200
732 unsigned int quiet : 1; /* inhibit status messages? */
733 unsigned int collapsed : 1; /* are all threads collapsed? */
734 unsigned int closing : 1; /* mailbox is being closed */
735 + unsigned int peekonly : 1; /* just taking a glance, revert atime */
738 void *data; /* driver specific data */
739 Index: mutt/muttlib.c
740 ===================================================================
741 --- mutt.orig/muttlib.c 2009-06-25 12:35:48.000000000 +0200
742 +++ mutt/muttlib.c 2009-06-25 12:36:53.000000000 +0200
743 @@ -1232,6 +1232,8 @@
746 /* see if there's room to add content, else ignore */
747 + if ( DrawFullLine )
749 if ((col < COLS && wlen < destlen) || soft)
752 @@ -1274,6 +1276,52 @@
759 + if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
763 + /* get contents after padding */
764 + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
765 + len = mutt_strlen (buf);
766 + wid = mutt_strwidth (buf);
768 + /* try to consume as many columns as we can, if we don't have
769 + * memory for that, use as much memory as possible */
770 + pad = (COLS - SidebarWidth - col - wid) / pw;
771 + if (pad > 0 && wlen + (pad * pl) + len > destlen)
772 + pad = ((signed)(destlen - wlen - len)) / pl;
777 + memcpy (wptr, src, pl);
783 + else if (soft && pad < 0)
785 + /* \0-terminate dest for length computation in mutt_wstr_trunc() */
787 + /* make sure right part is at most as wide as display */
788 + len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
789 + /* truncate left so that right part fits completely in */
790 + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
791 + wptr = dest + wlen;
793 + if (len + wlen > destlen)
794 + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
795 + memcpy (wptr, buf, len);
802 break; /* skip rest of input */
806 ===================================================================
807 --- mutt.orig/mx.c 2009-06-25 12:36:45.000000000 +0200
808 +++ mutt/mx.c 2009-06-25 12:36:53.000000000 +0200
810 * M_APPEND open mailbox for appending
811 * M_READONLY open mailbox in read-only mode
812 * M_QUIET only print error messages
813 + * M_PEEK revert atime where applicable
814 * ctx if non-null, context struct to use
816 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
819 if (flags & M_READONLY)
821 + if (flags & M_PEEK)
824 if (flags & (M_APPEND|M_NEWFOLDER))
827 void mx_fastclose_mailbox (CONTEXT *ctx)
837 + /* fix up the times so buffy won't get confused */
838 + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
840 + ut.actime = ctx->atime;
841 + ut.modtime = ctx->mtime;
842 + utime (ctx->path, &ut);
849 ===================================================================
850 --- mutt.orig/OPS 2009-06-25 12:36:14.000000000 +0200
851 +++ mutt/OPS 2009-06-25 12:36:53.000000000 +0200
853 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
854 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
855 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
856 +OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
857 +OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
858 +OP_SIDEBAR_NEXT "go down to next mailbox"
859 +OP_SIDEBAR_PREV "go to previous mailbox"
860 +OP_SIDEBAR_OPEN "open hilighted mailbox"
862 ===================================================================
863 --- mutt.orig/pager.c 2009-06-25 12:36:14.000000000 +0200
864 +++ mutt/pager.c 2009-06-25 12:36:53.000000000 +0200
869 +#include "sidebar.h"
871 #include "mutt_crypt.h"
873 @@ -1071,6 +1072,8 @@
876 int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
878 + wrap_cols -= SidebarWidth;
880 /* FIXME: this should come from lineInfo */
881 memset(&mbstate, 0, sizeof(mbstate));
882 @@ -1717,7 +1720,7 @@
883 if ((redraw & REDRAW_BODY) || topline != oldtopline)
886 - move (bodyoffset, 0);
887 + move (bodyoffset, SidebarWidth);
888 curline = oldtopline = topline;
891 @@ -1730,6 +1733,7 @@
892 &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
895 + move(lines + bodyoffset, SidebarWidth);
897 last_offset = lineInfo[curline].offset;
898 } while (force_redraw);
899 @@ -1743,6 +1747,7 @@
903 + move(lines + bodyoffset, SidebarWidth);
905 /* We are going to update the pager status bar, so it isn't
906 * necessary to reset to normal color now. */
907 @@ -1766,11 +1771,11 @@
908 /* print out the pager status bar */
909 SETCOLOR (MT_COLOR_STATUS);
910 BKGDSET (MT_COLOR_STATUS);
911 - CLEARLINE (statusoffset);
912 + CLEARLINE_WIN (statusoffset);
914 if (IsHeader (extra) || IsMsgAttach (extra))
916 - size_t l1 = COLS * MB_LEN_MAX;
917 + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
918 size_t l2 = sizeof (buffer);
919 hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
920 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
921 @@ -1780,7 +1785,7 @@
924 snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
925 - mutt_paddstr (COLS, bn);
926 + mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner);
928 BKGDSET (MT_COLOR_NORMAL);
929 SETCOLOR (MT_COLOR_NORMAL);
930 @@ -1798,18 +1803,23 @@
931 /* redraw the pager_index indicator, because the
932 * flags for this message might have changed. */
933 menu_redraw_current (index);
934 + draw_sidebar(MENU_PAGER);
936 /* print out the index status bar */
937 menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
939 - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
940 + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
941 SETCOLOR (MT_COLOR_STATUS);
942 BKGDSET (MT_COLOR_STATUS);
943 - mutt_paddstr (COLS, buffer);
944 + mutt_paddstr (COLS-SidebarWidth, buffer);
945 SETCOLOR (MT_COLOR_NORMAL);
946 BKGDSET (MT_COLOR_NORMAL);
949 + /* if we're not using the index, update every time */
951 + draw_sidebar(MENU_PAGER);
955 if (option(OPTBRAILLEFRIENDLY)) {
956 @@ -2742,6 +2752,13 @@
960 + case OP_SIDEBAR_SCROLL_UP:
961 + case OP_SIDEBAR_SCROLL_DOWN:
962 + case OP_SIDEBAR_NEXT:
963 + case OP_SIDEBAR_PREV:
964 + scroll_sidebar(ch, MENU_PAGER);
970 Index: mutt/sidebar.c
971 ===================================================================
972 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
973 +++ mutt/sidebar.c 2009-06-25 12:36:53.000000000 +0200
976 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
977 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
979 + * This program is free software; you can redistribute it and/or modify
980 + * it under the terms of the GNU General Public License as published by
981 + * the Free Software Foundation; either version 2 of the License, or
982 + * (at your option) any later version.
984 + * This program is distributed in the hope that it will be useful,
985 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
986 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
987 + * GNU General Public License for more details.
989 + * You should have received a copy of the GNU General Public License
990 + * along with this program; if not, write to the Free Software
991 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
996 +# include "config.h"
1000 +#include "mutt_menu.h"
1001 +#include "mutt_curses.h"
1002 +#include "sidebar.h"
1004 +#include <libgen.h>
1005 +#include "keymap.h"
1006 +#include <stdbool.h>
1008 +/*BUFFY *CurBuffy = 0;*/
1009 +static BUFFY *TopBuffy = 0;
1010 +static BUFFY *BottomBuffy = 0;
1011 +static int known_lines = 0;
1013 +static int quick_log10(int n)
1016 + sprintf(string, "%d", n);
1017 + return strlen(string);
1020 +void calc_boundaries (int menu)
1022 + BUFFY *tmp = Incoming;
1024 + if ( known_lines != LINES ) {
1025 + TopBuffy = BottomBuffy = 0;
1026 + known_lines = LINES;
1028 + for ( ; tmp->next != 0; tmp = tmp->next )
1029 + tmp->next->prev = tmp;
1031 + if ( TopBuffy == 0 && BottomBuffy == 0 )
1032 + TopBuffy = Incoming;
1033 + if ( BottomBuffy == 0 ) {
1034 + int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1035 + BottomBuffy = TopBuffy;
1036 + while ( --count && BottomBuffy->next )
1037 + BottomBuffy = BottomBuffy->next;
1039 + else if ( TopBuffy == CurBuffy->next ) {
1040 + int count = LINES - 2 - (menu != MENU_PAGER);
1041 + BottomBuffy = CurBuffy;
1042 + tmp = BottomBuffy;
1043 + while ( --count && tmp->prev)
1047 + else if ( BottomBuffy == CurBuffy->prev ) {
1048 + int count = LINES - 2 - (menu != MENU_PAGER);
1049 + TopBuffy = CurBuffy;
1051 + while ( --count && tmp->next )
1053 + BottomBuffy = tmp;
1057 +char *make_sidebar_entry(char *box, int size, int new, int flagged)
1059 + static char *entry = 0;
1062 + int delim_len = strlen(SidebarDelim);
1064 + c = realloc(entry, SidebarWidth - delim_len + 2);
1065 + if ( c ) entry = c;
1066 + entry[SidebarWidth - delim_len + 1] = 0;
1067 + for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1069 + strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1072 + sprintf(entry + SidebarWidth - delim_len - 3, "?");
1074 + if (flagged > 0) {
1076 + entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1077 + "% d(%d)[%d]", size, new, flagged);
1080 + entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1081 + "% d(%d)", size, new);
1083 + } else if (flagged > 0) {
1084 + sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1086 + sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1091 +void set_curbuffy(char buf[LONG_STRING])
1093 + BUFFY* tmp = CurBuffy = Incoming;
1099 + if(!strcmp(tmp->path, buf)) {
1111 +int draw_sidebar(int menu) {
1113 + int lines = option(OPTHELP) ? 1 : 0;
1115 +#ifndef USE_SLANG_CURSES
1118 + short delim_len = strlen(SidebarDelim);
1121 + static bool initialized = false;
1122 + static int prev_show_value;
1123 + static short saveSidebarWidth;
1125 + /* initialize first time */
1126 + if(!initialized) {
1127 + prev_show_value = option(OPTSIDEBAR);
1128 + saveSidebarWidth = SidebarWidth;
1129 + if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1130 + initialized = true;
1133 + /* save or restore the value SidebarWidth */
1134 + if(prev_show_value != option(OPTSIDEBAR)) {
1135 + if(prev_show_value && !option(OPTSIDEBAR)) {
1136 + saveSidebarWidth = SidebarWidth;
1138 + } else if(!prev_show_value && option(OPTSIDEBAR)) {
1139 + SidebarWidth = saveSidebarWidth;
1141 + prev_show_value = option(OPTSIDEBAR);
1145 +// if ( SidebarWidth == 0 ) return 0;
1146 + if (SidebarWidth > 0 && option (OPTSIDEBAR)
1147 + && delim_len >= SidebarWidth) {
1148 + unset_option (OPTSIDEBAR);
1149 + /* saveSidebarWidth = SidebarWidth; */
1150 + if (saveSidebarWidth > delim_len) {
1151 + SidebarWidth = saveSidebarWidth;
1152 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1156 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1157 + sleep (4); /* the advise to set a sane value should be seen long enough */
1159 + saveSidebarWidth = 0;
1163 + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1164 + if (SidebarWidth > 0) {
1165 + saveSidebarWidth = SidebarWidth;
1168 + unset_option(OPTSIDEBAR);
1172 + /* get attributes for divider */
1173 + SETCOLOR(MT_COLOR_STATUS);
1174 +#ifndef USE_SLANG_CURSES
1175 + attr_get(&attrs, &color_pair, 0);
1177 + color_pair = attr_get();
1179 + SETCOLOR(MT_COLOR_NORMAL);
1181 + /* draw the divider */
1183 + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1184 + move(lines, SidebarWidth - delim_len);
1185 + addstr(NONULL(SidebarDelim));
1186 +#ifndef USE_SLANG_CURSES
1187 + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1191 + if ( Incoming == 0 ) return 0;
1192 + lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1194 + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 )
1195 + calc_boundaries(menu);
1196 + if ( CurBuffy == 0 ) CurBuffy = Incoming;
1200 + SETCOLOR(MT_COLOR_NORMAL);
1202 + for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1203 + if ( tmp == CurBuffy )
1204 + SETCOLOR(MT_COLOR_INDICATOR);
1205 + else if ( tmp->msg_unread > 0 )
1206 + SETCOLOR(MT_COLOR_NEW);
1207 + else if ( tmp->msg_flagged > 0 )
1208 + SETCOLOR(MT_COLOR_FLAGGED);
1210 + SETCOLOR(MT_COLOR_NORMAL);
1213 + if ( Context && !strcmp( tmp->path, Context->path ) ) {
1214 + tmp->msg_unread = Context->unread;
1215 + tmp->msgcount = Context->msgcount;
1216 + tmp->msg_flagged = Context->flagged;
1218 + // check whether Maildir is a prefix of the current folder's path
1219 + short maildir_is_prefix = 0;
1220 + if ( (strlen(tmp->path) > strlen(Maildir)) &&
1221 + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1222 + maildir_is_prefix = 1;
1223 + // calculate depth of current folder and generate its display name with indented spaces
1224 + int sidebar_folder_depth = 0;
1225 + char *sidebar_folder_name;
1226 + sidebar_folder_name = basename(tmp->path);
1227 + if ( maildir_is_prefix ) {
1228 + char *tmp_folder_name;
1230 + tmp_folder_name = tmp->path + strlen(Maildir);
1231 + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1232 + if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1234 + if (sidebar_folder_depth > 0) {
1235 + sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1236 + for (i=0; i < sidebar_folder_depth; i++)
1237 + sidebar_folder_name[i]=' ';
1238 + sidebar_folder_name[i]=0;
1239 + strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1242 + printw( "%.*s", SidebarWidth - delim_len + 1,
1243 + make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1244 + tmp->msg_unread, tmp->msg_flagged));
1245 + if (sidebar_folder_depth > 0)
1246 + free(sidebar_folder_name);
1249 + SETCOLOR(MT_COLOR_NORMAL);
1250 + for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1253 + for ( ; i < SidebarWidth - delim_len; i++ )
1260 +void set_buffystats(CONTEXT* Context)
1262 + BUFFY *tmp = Incoming;
1264 + if(Context && !strcmp(tmp->path, Context->path)) {
1265 + tmp->msg_unread = Context->unread;
1266 + tmp->msgcount = Context->msgcount;
1273 +void scroll_sidebar(int op, int menu)
1275 + if(!SidebarWidth) return;
1276 + if(!CurBuffy) return;
1279 + case OP_SIDEBAR_NEXT:
1280 + if ( CurBuffy->next == NULL ) return;
1281 + CurBuffy = CurBuffy->next;
1283 + case OP_SIDEBAR_PREV:
1284 + if ( CurBuffy->prev == NULL ) return;
1285 + CurBuffy = CurBuffy->prev;
1287 + case OP_SIDEBAR_SCROLL_UP:
1288 + CurBuffy = TopBuffy;
1289 + if ( CurBuffy != Incoming ) {
1290 + calc_boundaries(menu);
1291 + CurBuffy = CurBuffy->prev;
1294 + case OP_SIDEBAR_SCROLL_DOWN:
1295 + CurBuffy = BottomBuffy;
1296 + if ( CurBuffy->next ) {
1297 + calc_boundaries(menu);
1298 + CurBuffy = CurBuffy->next;
1304 + calc_boundaries(menu);
1305 + draw_sidebar(menu);
1308 Index: mutt/sidebar.h
1309 ===================================================================
1310 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1311 +++ mutt/sidebar.h 2009-06-25 12:36:53.000000000 +0200
1314 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1315 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1317 + * This program is free software; you can redistribute it and/or modify
1318 + * it under the terms of the GNU General Public License as published by
1319 + * the Free Software Foundation; either version 2 of the License, or
1320 + * (at your option) any later version.
1322 + * This program is distributed in the hope that it will be useful,
1323 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1324 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1325 + * GNU General Public License for more details.
1327 + * You should have received a copy of the GNU General Public License
1328 + * along with this program; if not, write to the Free Software
1329 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
1341 +/* parameter is whether or not to go to the status line */
1342 +/* used for omitting the last | that covers up the status bar in the index */
1343 +int draw_sidebar(int);
1344 +void scroll_sidebar(int, int);
1345 +void set_curbuffy(char*);
1346 +void set_buffystats(CONTEXT*);
1348 +#endif /* SIDEBAR_H */
1349 Index: mutt/doc/Muttrc
1350 ===================================================================
1351 --- mutt.orig/doc/Muttrc 2009-06-24 19:37:58.000000000 +0200
1352 +++ mutt/doc/Muttrc 2009-06-25 12:36:53.000000000 +0200
1353 @@ -657,6 +657,26 @@
1354 # $crypt_autosign, $crypt_replysign and $smime_is_default.
1357 +# set sidebar_visible=no
1359 +# Name: sidebar_visible
1364 +# This specifies whether or not to show sidebar (left-side list of folders).
1367 +# set sidebar_width=0
1369 +# Name: sidebar_width
1374 +# The width of the sidebar.
1377 # set crypt_autosign=no
1379 # Name: crypt_autosign
1380 Index: mutt/imap/imap.c
1381 ===================================================================
1382 --- mutt.orig/imap/imap.c 2009-06-24 19:37:58.000000000 +0200
1383 +++ mutt/imap/imap.c 2009-06-25 12:36:53.000000000 +0200
1384 @@ -1521,7 +1521,7 @@
1386 imap_munge_mbox_name (munged, sizeof (munged), name);
1387 snprintf (command, sizeof (command),
1388 - "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
1389 + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
1391 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
1393 Index: mutt/imap/command.c
1394 ===================================================================
1395 --- mutt.orig/imap/command.c 2009-06-24 19:37:58.000000000 +0200
1396 +++ mutt/imap/command.c 2009-06-25 12:36:53.000000000 +0200
1397 @@ -1009,6 +1009,13 @@
1399 status->uidnext = oldun;
1401 + /* Added to make the sidebar show the correct numbers */
1402 + if (status->messages)
1404 + inc->msgcount = status->messages;
1405 + inc->msg_unread = status->unseen;