1 diff -urN mutt-1.5.21/buffy.c mutt-1.5.21-sidebar/buffy.c
2 --- mutt-1.5.21/buffy.c 2010-09-13 19:19:55.000000000 +0200
3 +++ mutt-1.5.21-sidebar/buffy.c 2011-03-09 12:09:45.136872460 +0100
8 + mailbox->msgcount = 0;
9 + mailbox->msg_unread = 0;
10 + mailbox->msg_flagged = 0;
12 while ((de = readdir (dirp)) != NULL)
14 if (*de->d_name == '.')
18 /* one new and undeleted message is enough */
20 + mailbox->has_new = mailbox->new = 1;
21 + mailbox->msgcount++;
22 + mailbox->msg_unread++;
31 + * count read messages (for folderlist (sidebar) we also need to count
32 + * messages in cur so that we the total number of messages
34 + snprintf (path, sizeof (path), "%s/cur", mailbox->path);
35 + if ((dirp = opendir (path)) == NULL)
39 + while ((de = readdir (dirp)) != NULL)
42 + if (*de->d_name != '.') {
43 + if ((p = strstr (de->d_name, ":2,"))) {
44 + if (!strchr (p + 3, 'T')) {
45 + mailbox->msgcount++;
46 + if ( !strchr (p + 3, 'S'))
47 + mailbox->msg_unread++;
48 + if (strchr(p + 3, 'F'))
49 + mailbox->msg_flagged++;
52 + mailbox->msgcount++;
65 if (option (OPTCHECKMBOXSIZE))
66 statcheck = sb->st_size > mailbox->size;
68 statcheck = sb->st_mtime > sb->st_atime
69 || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
71 + if (statcheck || mailbox->msgcount == 0)
76 + /* parse the mailbox, to see how much mail there is */
77 + ctx = mx_open_mailbox( mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
80 + msgcount = ctx->msgcount;
81 + msg_unread = ctx->unread;
82 + mx_close_mailbox(ctx, 0);
85 + mailbox->msgcount = msgcount;
86 + mailbox->msg_unread = msg_unread;
89 + mailbox->has_new = mailbox->new = 1;
91 if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
95 int mutt_buffy_check (int force)
98 + struct dirent *de, *dp;
100 struct stat contex_sb;
108 if ((tmp->new = mh_buffy (tmp->path)) > 0)
111 + if ((dp = opendir (tmp->path)) == NULL)
114 + while ((de = readdir (dp)))
116 + if (mh_valid_message (de->d_name))
119 + tmp->has_new = tmp->new = 1;
127 diff -urN mutt-1.5.21/buffy.h mutt-1.5.21-sidebar/buffy.h
128 --- mutt-1.5.21/buffy.h 2010-09-13 19:19:55.000000000 +0200
129 +++ mutt-1.5.21-sidebar/buffy.h 2011-03-09 12:09:45.137872960 +0100
131 char path[_POSIX_PATH_MAX];
133 struct buffy_t *next;
134 + struct buffy_t *prev;
135 short new; /* mailbox has new mail */
136 + short has_new; /* set it new if new and not read */
137 + int msgcount; /* total number of messages */
138 + int msg_unread; /* number of unread messages */
139 + int msg_flagged; /* number of flagged messages */
140 short notified; /* user has been notified */
141 short magic; /* mailbox type */
142 short newly_created; /* mbox or mmdf just popped into existence */
143 diff -urN mutt-1.5.21/color.c mutt-1.5.21-sidebar/color.c
144 --- mutt-1.5.21/color.c 2009-05-15 19:18:23.000000000 +0200
145 +++ mutt-1.5.21-sidebar/color.c 2011-03-09 12:09:45.141874960 +0100
147 { "bold", MT_COLOR_BOLD },
148 { "underline", MT_COLOR_UNDERLINE },
149 { "index", MT_COLOR_INDEX },
150 + { "sidebar_new", MT_COLOR_NEW },
151 + { "sidebar_flagged", MT_COLOR_FLAGGED },
155 diff -urN mutt-1.5.21/compose.c mutt-1.5.21-sidebar/compose.c
156 --- mutt-1.5.21/compose.c 2010-04-14 20:50:19.000000000 +0200
157 +++ mutt-1.5.21-sidebar/compose.c 2011-03-09 12:09:45.142875460 +0100
160 #define HDR_XOFFSET 10
161 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
162 -#define W (COLS - HDR_XOFFSET)
163 +#define W (COLS - HDR_XOFFSET - SidebarWidth)
165 static char *Prompts[] =
171 - mvaddstr (HDR_CRYPT, 0, "Security: ");
172 + mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
174 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
180 - move (HDR_CRYPTINFO, 0);
181 + move (HDR_CRYPTINFO, SidebarWidth);
184 if ((WithCrypto & APPLICATION_PGP)
186 && (msg->security & ENCRYPT)
189 - mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
190 + mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
191 NONULL(SmimeCryptAlg));
198 - mvaddstr (HDR_MIX, 0, " Mix: ");
199 + mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
204 if (t && t[0] == '0' && t[1] == '\0')
207 - if (c + mutt_strlen (t) + 2 >= COLS)
208 + if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
215 rfc822_write_address (buf, sizeof (buf), addr, 1);
216 - mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
217 + mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
218 mutt_paddstr (W, buf);
221 @@ -252,10 +252,10 @@
222 draw_envelope_addr (HDR_TO, msg->env->to);
223 draw_envelope_addr (HDR_CC, msg->env->cc);
224 draw_envelope_addr (HDR_BCC, msg->env->bcc);
225 - mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
226 + mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
227 mutt_paddstr (W, NONULL (msg->env->subject));
228 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
229 - mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
230 + mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
231 mutt_paddstr (W, fcc);
237 SETCOLOR (MT_COLOR_STATUS);
238 - mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
239 + mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
240 BKGDSET (MT_COLOR_STATUS);
244 /* redraw the expanded list so the user can see the result */
246 rfc822_write_address (buf, sizeof (buf), *addr, 1);
247 - move (line, HDR_XOFFSET);
248 + move (line, HDR_XOFFSET+SidebarWidth);
249 mutt_paddstr (W, buf);
253 if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
255 mutt_str_replace (&msg->env->subject, buf);
256 - move (HDR_SUBJECT, HDR_XOFFSET);
257 + move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
259 if (msg->env->subject)
260 mutt_paddstr (W, msg->env->subject);
263 strfcpy (fcc, buf, fcclen);
264 mutt_pretty_mailbox (fcc, fcclen);
265 - move (HDR_FCC, HDR_XOFFSET);
266 + move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
267 mutt_paddstr (W, fcc);
270 diff -urN mutt-1.5.21/curs_main.c mutt-1.5.21-sidebar/curs_main.c
271 --- mutt-1.5.21/curs_main.c 2010-09-13 19:19:55.000000000 +0200
272 +++ mutt-1.5.21-sidebar/curs_main.c 2011-03-09 12:21:14.092264460 +0100
279 +#include "sidebar.h"
284 menu->redraw |= REDRAW_STATUS;
287 - if (mutt_buffy_notify () && option (OPTBEEPNEW))
289 + if (mutt_buffy_notify ())
291 + menu->redraw |= REDRAW_FULL;
292 + if (option (OPTBEEPNEW))
299 if (menu->redraw & REDRAW_FULL)
301 menu_redraw_full (menu);
302 + draw_sidebar(menu->menu);
306 @@ -554,10 +561,13 @@
308 if (menu->redraw & REDRAW_STATUS)
311 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
313 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
314 SETCOLOR (MT_COLOR_STATUS);
315 BKGDSET (MT_COLOR_STATUS);
316 + set_buffystats(Context);
317 mutt_paddstr (COLS, buf);
318 SETCOLOR (MT_COLOR_NORMAL);
319 BKGDSET (MT_COLOR_NORMAL);
321 menu->oldcurrent = -1;
323 if (option (OPTARROWCURSOR))
324 - move (menu->current - menu->top + menu->offset, 2);
325 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
326 else if (option (OPTBRAILLEFRIENDLY))
327 move (menu->current - menu->top + menu->offset, 0);
329 @@ -1069,6 +1079,7 @@
330 menu->redraw = REDRAW_FULL;
333 + case OP_SIDEBAR_OPEN:
334 case OP_MAIN_CHANGE_FOLDER:
335 case OP_MAIN_NEXT_UNREAD_MAILBOX:
337 @@ -1100,7 +1111,11 @@
339 mutt_buffy (buf, sizeof (buf));
341 - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
342 + if ( op == OP_SIDEBAR_OPEN ) {
345 + strncpy( buf, CurBuffy->path, sizeof(buf) );
346 + } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
348 if (menu->menu == MENU_PAGER)
350 @@ -1118,6 +1133,7 @@
353 mutt_expand_path (buf, sizeof (buf));
355 if (mx_get_magic (buf) <= 0)
357 mutt_error (_("%s is not a mailbox."), buf);
358 @@ -2208,6 +2224,12 @@
362 + case OP_SIDEBAR_SCROLL_UP:
363 + case OP_SIDEBAR_SCROLL_DOWN:
364 + case OP_SIDEBAR_NEXT:
365 + case OP_SIDEBAR_PREV:
366 + scroll_sidebar(op, menu->menu);
369 if (menu->menu == MENU_MAIN)
370 km_error_key (MENU_MAIN);
371 diff -urN mutt-1.5.21/doc/Muttrc mutt-1.5.21-sidebar/doc/Muttrc
372 --- mutt-1.5.21/doc/Muttrc 2010-09-15 19:07:19.000000000 +0200
373 +++ mutt-1.5.21-sidebar/doc/Muttrc 2011-03-09 12:09:45.180894458 +0100
375 # $crypt_autosign, $crypt_replysign and $smime_is_default.
378 +# set sidebar_visible=no
380 +# Name: sidebar_visible
385 +# This specifies whether or not to show sidebar (left-side list of folders).
388 +# set sidebar_width=0
390 +# Name: sidebar_width
395 +# The width of the sidebar.
398 # set crypt_autosign=no
400 # Name: crypt_autosign
401 diff -urN mutt-1.5.21/flags.c mutt-1.5.21-sidebar/flags.c
402 --- mutt-1.5.21/flags.c 2009-01-04 00:27:10.000000000 +0100
403 +++ mutt-1.5.21-sidebar/flags.c 2011-03-09 12:09:45.144876460 +0100
407 #include "mutt_curses.h"
408 +#include "mutt_menu.h"
411 +#include "sidebar.h"
413 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
417 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
422 void mutt_tag_set_flag (int flag, int bf)
423 diff -urN mutt-1.5.21/functions.h mutt-1.5.21-sidebar/functions.h
424 --- mutt-1.5.21/functions.h 2010-08-24 18:34:21.000000000 +0200
425 +++ mutt-1.5.21-sidebar/functions.h 2011-03-09 12:21:14.093264460 +0100
427 { "decrypt-save", OP_DECRYPT_SAVE, NULL },
430 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
431 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
432 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
433 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
434 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
440 { "what-key", OP_WHAT_KEY, NULL },
442 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
443 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
444 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
445 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
446 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
450 diff -urN mutt-1.5.21/globals.h mutt-1.5.21-sidebar/globals.h
451 --- mutt-1.5.21/globals.h 2009-08-25 21:08:52.000000000 +0200
452 +++ mutt-1.5.21-sidebar/globals.h 2011-03-09 12:09:45.146877460 +0100
454 WHERE char *SendCharset;
455 WHERE char *Sendmail;
457 +WHERE char *SidebarDelim;
458 WHERE char *Signature;
459 WHERE char *SimpleSearch;
462 WHERE short ScoreThresholdRead;
463 WHERE short ScoreThresholdFlag;
465 +WHERE struct buffy_t *CurBuffy INITVAL(0);
466 +WHERE short DrawFullLine INITVAL(0);
467 +WHERE short SidebarWidth;
469 WHERE short ImapKeepalive;
470 WHERE short ImapPipelineDepth;
471 diff -urN mutt-1.5.21/imap/command.c mutt-1.5.21-sidebar/imap/command.c
472 --- mutt-1.5.21/imap/command.c 2010-09-15 17:39:31.000000000 +0200
473 +++ mutt-1.5.21-sidebar/imap/command.c 2011-03-09 12:09:45.184896458 +0100
474 @@ -1011,6 +1011,13 @@
476 status->uidnext = oldun;
478 + /* Added to make the sidebar show the correct numbers */
479 + if (status->messages)
481 + inc->msgcount = status->messages;
482 + inc->msg_unread = status->unseen;
488 diff -urN mutt-1.5.21/imap/imap.c mutt-1.5.21-sidebar/imap/imap.c
489 --- mutt-1.5.21/imap/imap.c 2009-08-25 21:08:52.000000000 +0200
490 +++ mutt-1.5.21-sidebar/imap/imap.c 2011-03-09 12:09:45.183895958 +0100
491 @@ -1521,7 +1521,7 @@
493 imap_munge_mbox_name (munged, sizeof (munged), name);
494 snprintf (command, sizeof (command),
495 - "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
496 + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
498 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
500 diff -urN mutt-1.5.21/init.h mutt-1.5.21-sidebar/init.h
501 --- mutt-1.5.21/init.h 2010-09-15 17:39:31.000000000 +0200
502 +++ mutt-1.5.21-sidebar/init.h 2011-03-09 12:21:14.094264460 +0100
503 @@ -1953,6 +1953,32 @@
507 + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
510 + ** This specifies the delimiter between the sidebar (if visible) and
513 + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
516 + ** This specifies whether or not to show sidebar (left-side list of folders).
518 + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
521 + ** The width of the sidebar.
523 + { "sidebar_shortpath", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 0 },
526 + ** Should the sidebar shorten the path showed.
528 + { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
531 + ** Should the sidebar be sorted.
533 { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
536 diff -urN mutt-1.5.21/mailbox.h mutt-1.5.21-sidebar/mailbox.h
537 --- mutt-1.5.21/mailbox.h 2009-04-30 19:33:48.000000000 +0200
538 +++ mutt-1.5.21-sidebar/mailbox.h 2011-03-09 12:09:45.148878460 +0100
540 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
541 * safe_fopen() for mbox-style folders.
543 +#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */
545 /* mx_open_new_message() */
546 #define M_ADD_FROM 1 /* add a From_ line */
547 diff -urN mutt-1.5.21/Makefile.am mutt-1.5.21-sidebar/Makefile.am
548 --- mutt-1.5.21/Makefile.am 2010-08-24 18:34:21.000000000 +0200
549 +++ mutt-1.5.21-sidebar/Makefile.am 2011-03-09 12:09:45.151879960 +0100
551 score.c send.c sendlib.c signal.c sort.c \
552 status.c system.c thread.c charset.c history.c lib.c \
553 muttlib.c editmsg.c mbyte.c \
554 - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
555 + url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c \
558 nodist_mutt_SOURCES = $(BUILT_SOURCES)
560 diff -urN mutt-1.5.21/mbox.c mutt-1.5.21-sidebar/mbox.c
561 --- mutt-1.5.21/mbox.c 2010-09-13 19:19:55.000000000 +0200
562 +++ mutt-1.5.21-sidebar/mbox.c 2011-03-09 12:09:45.152880460 +0100
564 mutt_perror (ctx->path);
567 + ctx->atime = sb.st_atime;
568 ctx->mtime = sb.st_mtime;
569 ctx->size = sb.st_size;
573 ctx->size = sb.st_size;
574 ctx->mtime = sb.st_mtime;
575 + ctx->atime = sb.st_atime;
577 #ifdef NFS_ATTRIBUTE_HACK
578 if (sb.st_mtime > sb.st_atime)
579 diff -urN mutt-1.5.21/menu.c mutt-1.5.21-sidebar/menu.c
580 --- mutt-1.5.21/menu.c 2010-08-25 18:31:40.000000000 +0200
581 +++ mutt-1.5.21-sidebar/menu.c 2011-03-09 12:09:45.153880960 +0100
583 #include "mutt_curses.h"
584 #include "mutt_menu.h"
586 +#include "sidebar.h"
592 char *scratch = safe_strdup (s);
593 int shift = option (OPTARROWCURSOR) ? 3 : 0;
594 - int cols = COLS - shift;
595 + int cols = COLS - shift - SidebarWidth;
597 mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
600 char buf[LONG_STRING];
604 for (i = menu->top; i < menu->top + menu->pagelen; i++)
608 if (option (OPTARROWCURSOR))
610 attrset (menu->color (i));
611 - CLEARLINE (i - menu->top + menu->offset);
612 + CLEARLINE_WIN (i - menu->top + menu->offset);
614 if (i == menu->current)
616 @@ -246,14 +248,14 @@
617 BKGDSET (MT_COLOR_INDICATOR);
620 - CLEARLINE (i - menu->top + menu->offset);
621 + CLEARLINE_WIN (i - menu->top + menu->offset);
622 print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
623 SETCOLOR (MT_COLOR_NORMAL);
624 BKGDSET (MT_COLOR_NORMAL);
628 - CLEARLINE (i - menu->top + menu->offset);
629 + CLEARLINE_WIN (i - menu->top + menu->offset);
637 - move (menu->oldcurrent + menu->offset - menu->top, 0);
638 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
639 SETCOLOR (MT_COLOR_NORMAL);
640 BKGDSET (MT_COLOR_NORMAL);
642 @@ -283,13 +285,13 @@
644 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
645 menu_pad_string (buf, sizeof (buf));
646 - move (menu->oldcurrent + menu->offset - menu->top, 3);
647 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
648 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
649 SETCOLOR (MT_COLOR_NORMAL);
652 /* now draw it in the new location */
653 - move (menu->current + menu->offset - menu->top, 0);
654 + move (menu->current + menu->offset - menu->top, SidebarWidth);
655 attrset (menu->color (menu->current));
656 ADDCOLOR (MT_COLOR_INDICATOR);
659 attrset (menu->color (menu->current));
660 ADDCOLOR (MT_COLOR_INDICATOR);
661 BKGDSET (MT_COLOR_INDICATOR);
662 - CLEARLINE (menu->current - menu->top + menu->offset);
663 + CLEARLINE_WIN (menu->current - menu->top + menu->offset);
664 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
665 SETCOLOR (MT_COLOR_NORMAL);
666 BKGDSET (MT_COLOR_NORMAL);
669 char buf[LONG_STRING];
671 - move (menu->current + menu->offset - menu->top, 0);
672 + move (menu->current + menu->offset - menu->top, SidebarWidth);
673 menu_make_entry (buf, sizeof (buf), menu, menu->current);
674 menu_pad_string (buf, sizeof (buf));
679 if (option (OPTARROWCURSOR))
680 - move (menu->current - menu->top + menu->offset, 2);
681 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
682 else if (option (OPTBRAILLEFRIENDLY))
683 move (menu->current - menu->top + menu->offset, 0);
685 diff -urN mutt-1.5.21/mutt_curses.h mutt-1.5.21-sidebar/mutt_curses.h
686 --- mutt-1.5.21/mutt_curses.h 2008-03-19 21:07:57.000000000 +0100
687 +++ mutt-1.5.21-sidebar/mutt_curses.h 2011-03-09 12:09:45.154881460 +0100
692 +#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
693 #define CLEARLINE(x) move(x,0), clrtoeol()
694 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
695 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
705 diff -urN mutt-1.5.21/mutt.h mutt-1.5.21-sidebar/mutt.h
706 --- mutt-1.5.21/mutt.h 2010-09-13 19:19:55.000000000 +0200
707 +++ mutt-1.5.21-sidebar/mutt.h 2011-03-09 12:21:14.193264454 +0100
713 + OPTSIDEBARSHORTPATH,
727 unsigned int quiet : 1; /* inhibit status messages? */
728 unsigned int collapsed : 1; /* are all threads collapsed? */
729 unsigned int closing : 1; /* mailbox is being closed */
730 + unsigned int peekonly : 1; /* just taking a glance, revert atime */
733 void *data; /* driver specific data */
734 diff -urN mutt-1.5.21/muttlib.c mutt-1.5.21-sidebar/muttlib.c
735 --- mutt-1.5.21/muttlib.c 2010-08-25 18:31:40.000000000 +0200
736 +++ mutt-1.5.21-sidebar/muttlib.c 2011-03-09 12:09:45.156882460 +0100
737 @@ -1286,6 +1286,8 @@
740 /* see if there's room to add content, else ignore */
741 + if ( DrawFullLine )
743 if ((col < COLS && wlen < destlen) || soft)
746 @@ -1329,6 +1331,52 @@
753 + if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
757 + /* get contents after padding */
758 + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
759 + len = mutt_strlen (buf);
760 + wid = mutt_strwidth (buf);
762 + /* try to consume as many columns as we can, if we don't have
763 + * memory for that, use as much memory as possible */
764 + pad = (COLS - SidebarWidth - col - wid) / pw;
765 + if (pad > 0 && wlen + (pad * pl) + len > destlen)
766 + pad = ((signed)(destlen - wlen - len)) / pl;
771 + memcpy (wptr, src, pl);
777 + else if (soft && pad < 0)
779 + /* \0-terminate dest for length computation in mutt_wstr_trunc() */
781 + /* make sure right part is at most as wide as display */
782 + len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
783 + /* truncate left so that right part fits completely in */
784 + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
785 + wptr = dest + wlen;
787 + if (len + wlen > destlen)
788 + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
789 + memcpy (wptr, buf, len);
796 break; /* skip rest of input */
799 diff -urN mutt-1.5.21/mx.c mutt-1.5.21-sidebar/mx.c
800 --- mutt-1.5.21/mx.c 2010-09-13 19:19:55.000000000 +0200
801 +++ mutt-1.5.21-sidebar/mx.c 2011-03-09 12:09:45.157882960 +0100
803 * M_APPEND open mailbox for appending
804 * M_READONLY open mailbox in read-only mode
805 * M_QUIET only print error messages
806 + * M_PEEK revert atime where applicable
807 * ctx if non-null, context struct to use
809 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
812 if (flags & M_READONLY)
814 + if (flags & M_PEEK)
817 if (flags & (M_APPEND|M_NEWFOLDER))
820 void mx_fastclose_mailbox (CONTEXT *ctx)
830 + /* fix up the times so buffy won't get confused */
831 + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
833 + ut.actime = ctx->atime;
834 + ut.modtime = ctx->mtime;
835 + utime (ctx->path, &ut);
839 /* never announce that a mailbox we've just left has new mail. #3290
840 * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
841 diff -urN mutt-1.5.21/OPS mutt-1.5.21-sidebar/OPS
842 --- mutt-1.5.21/OPS 2010-03-01 18:56:19.000000000 +0100
843 +++ mutt-1.5.21-sidebar/OPS 2011-03-09 12:21:14.091264460 +0100
845 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
846 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
847 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
848 +OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
849 +OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
850 +OP_SIDEBAR_NEXT "go down to next mailbox"
851 +OP_SIDEBAR_PREV "go to previous mailbox"
852 +OP_SIDEBAR_OPEN "open hilighted mailbox"
853 diff -urN mutt-1.5.21/pager.c mutt-1.5.21-sidebar/pager.c
854 --- mutt-1.5.21/pager.c 2010-08-25 18:31:40.000000000 +0200
855 +++ mutt-1.5.21-sidebar/pager.c 2011-03-09 12:54:30.262264458 +0100
860 +#include "sidebar.h"
862 #include "mutt_crypt.h"
864 @@ -1099,6 +1100,7 @@
865 if (check_attachment_marker ((char *)buf) == 0)
868 + wrap_cols -= SidebarWidth;
869 /* FIXME: this should come from lineInfo */
870 memset(&mbstate, 0, sizeof(mbstate));
872 @@ -1745,7 +1747,7 @@
873 if ((redraw & REDRAW_BODY) || topline != oldtopline)
876 - move (bodyoffset, 0);
877 + move (bodyoffset, SidebarWidth);
878 curline = oldtopline = topline;
881 @@ -1758,6 +1760,7 @@
882 &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
885 + move(lines + bodyoffset, SidebarWidth);
887 last_offset = lineInfo[curline].offset;
888 } while (force_redraw);
889 @@ -1771,6 +1774,7 @@
893 + move(lines + bodyoffset, SidebarWidth);
895 /* We are going to update the pager status bar, so it isn't
896 * necessary to reset to normal color now. */
897 @@ -1794,21 +1798,21 @@
898 /* print out the pager status bar */
899 SETCOLOR (MT_COLOR_STATUS);
900 BKGDSET (MT_COLOR_STATUS);
901 - CLEARLINE (statusoffset);
902 + CLEARLINE_WIN (statusoffset);
904 if (IsHeader (extra) || IsMsgAttach (extra))
906 - size_t l1 = COLS * MB_LEN_MAX;
907 + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
908 size_t l2 = sizeof (buffer);
909 hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
910 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
911 - mutt_paddstr (COLS, buffer);
912 + mutt_paddstr (COLS-SidebarWidth, buffer);
917 snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
918 - mutt_paddstr (COLS, bn);
919 + mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner);
921 BKGDSET (MT_COLOR_NORMAL);
922 SETCOLOR (MT_COLOR_NORMAL);
923 @@ -1819,18 +1823,25 @@
924 /* redraw the pager_index indicator, because the
925 * flags for this message might have changed. */
926 menu_redraw_current (index);
927 + draw_sidebar(MENU_PAGER);
929 /* print out the index status bar */
931 menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
934 - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
935 + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
936 SETCOLOR (MT_COLOR_STATUS);
937 BKGDSET (MT_COLOR_STATUS);
938 - mutt_paddstr (COLS, buffer);
939 + mutt_paddstr (COLS-SidebarWidth, buffer);
940 SETCOLOR (MT_COLOR_NORMAL);
941 BKGDSET (MT_COLOR_NORMAL);
944 + /* if we're not using the index, update every time */
946 + draw_sidebar(MENU_PAGER);
950 if (option(OPTBRAILLEFRIENDLY)) {
951 @@ -2756,6 +2765,13 @@
955 + case OP_SIDEBAR_SCROLL_UP:
956 + case OP_SIDEBAR_SCROLL_DOWN:
957 + case OP_SIDEBAR_NEXT:
958 + case OP_SIDEBAR_PREV:
959 + scroll_sidebar(ch, MENU_PAGER);
965 diff -urN mutt-1.5.21/sidebar.c mutt-1.5.21-sidebar/sidebar.c
966 --- mutt-1.5.21/sidebar.c 1970-01-01 01:00:00.000000000 +0100
967 +++ mutt-1.5.21-sidebar/sidebar.c 2011-03-09 12:21:14.200264458 +0100
970 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
971 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
973 + * This program is free software; you can redistribute it and/or modify
974 + * it under the terms of the GNU General Public License as published by
975 + * the Free Software Foundation; either version 2 of the License, or
976 + * (at your option) any later version.
978 + * This program is distributed in the hope that it will be useful,
979 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
980 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
981 + * GNU General Public License for more details.
983 + * You should have received a copy of the GNU General Public License
984 + * along with this program; if not, write to the Free Software
985 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
990 +# include "config.h"
994 +#include "mutt_menu.h"
995 +#include "mutt_curses.h"
996 +#include "sidebar.h"
1000 +#include <stdbool.h>
1002 +/*BUFFY *CurBuffy = 0;*/
1003 +static BUFFY *TopBuffy = 0;
1004 +static BUFFY *BottomBuffy = 0;
1005 +static int known_lines = 0;
1007 +static int quick_log10(int n)
1010 + sprintf(string, "%d", n);
1011 + return strlen(string);
1014 +void calc_boundaries (int menu)
1016 + BUFFY *tmp = Incoming;
1018 + if ( known_lines != LINES ) {
1019 + TopBuffy = BottomBuffy = 0;
1020 + known_lines = LINES;
1022 + for ( ; tmp->next != 0; tmp = tmp->next )
1023 + tmp->next->prev = tmp;
1025 + if (option(OPTSIDEBARSORT)) {
1030 + while (needsort==1) {
1033 + for ( ; tmp ; tmp=tmp->next ) {
1034 + if (tmp->next != NULL && strcmp(tmp->path, tmp->next->path) > 0) {
1039 + prev->next = next;
1042 + next->prev = prev;
1043 + tmp2 = next->next;
1054 + if ( TopBuffy == 0 && BottomBuffy == 0 )
1055 + TopBuffy = Incoming;
1056 + if ( BottomBuffy == 0 ) {
1057 + int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1058 + BottomBuffy = TopBuffy;
1059 + while ( --count && BottomBuffy->next )
1060 + BottomBuffy = BottomBuffy->next;
1062 + else if ( TopBuffy == CurBuffy->next ) {
1063 + int count = LINES - 2 - (menu != MENU_PAGER);
1064 + BottomBuffy = CurBuffy;
1065 + tmp = BottomBuffy;
1066 + while ( --count && tmp->prev)
1070 + else if ( BottomBuffy == CurBuffy->prev ) {
1071 + int count = LINES - 2 - (menu != MENU_PAGER);
1072 + TopBuffy = CurBuffy;
1074 + while ( --count && tmp->next )
1076 + BottomBuffy = tmp;
1080 +char *make_sidebar_entry(char *box, int size, int new, int flagged)
1082 + static char *entry = 0;
1085 + int delim_len = strlen(SidebarDelim);
1087 + c = realloc(entry, SidebarWidth - delim_len + 2);
1088 + if ( c ) entry = c;
1089 + entry[SidebarWidth - delim_len + 1] = 0;
1090 + for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1092 + strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1095 + sprintf(entry + SidebarWidth - delim_len - 3, "?");
1097 + if (flagged > 0) {
1099 + entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1100 + "% d(%d)[%d]", size, new, flagged);
1103 + entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1104 + "% d(%d)", size, new);
1106 + } else if (flagged > 0) {
1107 + sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1109 + sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1114 +void set_curbuffy(char buf[LONG_STRING])
1116 + BUFFY* tmp = CurBuffy = Incoming;
1122 + if(!strcmp(tmp->path, buf)) {
1134 +int draw_sidebar(int menu) {
1136 + int lines = option(OPTHELP) ? 1 : 0;
1138 +#ifndef USE_SLANG_CURSES
1141 + short delim_len = strlen(SidebarDelim);
1144 + static bool initialized = false;
1145 + static int prev_show_value;
1146 + static short saveSidebarWidth;
1148 + /* initialize first time */
1149 + if(!initialized) {
1150 + prev_show_value = option(OPTSIDEBAR);
1151 + saveSidebarWidth = SidebarWidth;
1152 + if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1153 + initialized = true;
1156 + /* save or restore the value SidebarWidth */
1157 + if(prev_show_value != option(OPTSIDEBAR)) {
1158 + if(prev_show_value && !option(OPTSIDEBAR)) {
1159 + saveSidebarWidth = SidebarWidth;
1161 + } else if(!prev_show_value && option(OPTSIDEBAR)) {
1162 + SidebarWidth = saveSidebarWidth;
1164 + prev_show_value = option(OPTSIDEBAR);
1168 +// if ( SidebarWidth == 0 ) return 0;
1169 + if (SidebarWidth > 0 && option (OPTSIDEBAR)
1170 + && delim_len >= SidebarWidth) {
1171 + unset_option (OPTSIDEBAR);
1172 + /* saveSidebarWidth = SidebarWidth; */
1173 + if (saveSidebarWidth > delim_len) {
1174 + SidebarWidth = saveSidebarWidth;
1175 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1179 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1180 + sleep (4); /* the advise to set a sane value should be seen long enough */
1182 + saveSidebarWidth = 0;
1186 + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1187 + if (SidebarWidth > 0) {
1188 + saveSidebarWidth = SidebarWidth;
1191 + unset_option(OPTSIDEBAR);
1195 + /* get attributes for divider */
1196 + SETCOLOR(MT_COLOR_STATUS);
1197 +#ifndef USE_SLANG_CURSES
1198 + attr_get(&attrs, &color_pair, 0);
1200 + color_pair = attr_get();
1202 + SETCOLOR(MT_COLOR_NORMAL);
1204 + /* draw the divider */
1206 + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1207 + move(lines, SidebarWidth - delim_len);
1208 + addstr(NONULL(SidebarDelim));
1209 +#ifndef USE_SLANG_CURSES
1210 + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1214 + if ( Incoming == 0 ) return 0;
1215 + lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1217 + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 )
1218 + calc_boundaries(menu);
1219 + if ( CurBuffy == 0 ) CurBuffy = Incoming;
1223 + SETCOLOR(MT_COLOR_NORMAL);
1225 + for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1226 + if ( tmp == CurBuffy )
1227 + SETCOLOR(MT_COLOR_INDICATOR);
1228 + else if ( tmp->msg_unread > 0 )
1229 + SETCOLOR(MT_COLOR_NEW);
1230 + else if ( tmp->msg_flagged > 0 )
1231 + SETCOLOR(MT_COLOR_FLAGGED);
1233 + SETCOLOR(MT_COLOR_NORMAL);
1236 + if ( Context && !strcmp( tmp->path, Context->path ) ) {
1237 + tmp->msg_unread = Context->unread;
1238 + tmp->msgcount = Context->msgcount;
1239 + tmp->msg_flagged = Context->flagged;
1241 + // check whether Maildir is a prefix of the current folder's path
1242 + short maildir_is_prefix = 0;
1243 + if ( (strlen(tmp->path) > strlen(Maildir)) &&
1244 + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1245 + maildir_is_prefix = 1;
1246 + // calculate depth of current folder and generate its display name with indented spaces
1247 + int sidebar_folder_depth = 0;
1248 + char *sidebar_folder_name;
1249 + sidebar_folder_name = basename(tmp->path);
1250 + if ( maildir_is_prefix ) {
1251 + char *tmp_folder_name;
1253 + tmp_folder_name = tmp->path + strlen(Maildir);
1254 + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1255 + if (tmp_folder_name[i] == '/' || tmp_folder_name[i] == '.') sidebar_folder_depth++;
1257 + if (sidebar_folder_depth > 0) {
1258 + if (option(OPTSIDEBARSHORTPATH)) {
1259 + tmp_folder_name = strrchr(tmp->path, '.');
1260 + if (tmp_folder_name == NULL)
1261 + tmp_folder_name = tmp->path;
1263 + tmp_folder_name++;
1266 + tmp_folder_name = tmp->path;
1267 + sidebar_folder_name = malloc(strlen(basename(tmp_folder_name)) + sidebar_folder_depth + 1);
1268 + for (i=0; i < sidebar_folder_depth; i++)
1269 + sidebar_folder_name[i]=' ';
1270 + sidebar_folder_name[i]=0;
1271 + strncat(sidebar_folder_name, basename(tmp_folder_name), strlen(basename(tmp_folder_name)) + sidebar_folder_depth);
1274 + printw( "%.*s", SidebarWidth - delim_len + 1,
1275 + make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1276 + tmp->msg_unread, tmp->msg_flagged));
1277 + if (sidebar_folder_depth > 0)
1278 + free(sidebar_folder_name);
1281 + SETCOLOR(MT_COLOR_NORMAL);
1282 + for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1285 + for ( ; i < SidebarWidth - delim_len; i++ )
1292 +void set_buffystats(CONTEXT* Context)
1294 + BUFFY *tmp = Incoming;
1296 + if(Context && !strcmp(tmp->path, Context->path)) {
1297 + tmp->msg_unread = Context->unread;
1298 + tmp->msgcount = Context->msgcount;
1305 +void scroll_sidebar(int op, int menu)
1307 + if(!SidebarWidth) return;
1308 + if(!CurBuffy) return;
1311 + case OP_SIDEBAR_NEXT:
1312 + if ( CurBuffy->next == NULL ) return;
1313 + CurBuffy = CurBuffy->next;
1315 + case OP_SIDEBAR_PREV:
1316 + if ( CurBuffy->prev == NULL ) return;
1317 + CurBuffy = CurBuffy->prev;
1319 + case OP_SIDEBAR_SCROLL_UP:
1320 + CurBuffy = TopBuffy;
1321 + if ( CurBuffy != Incoming ) {
1322 + calc_boundaries(menu);
1323 + CurBuffy = CurBuffy->prev;
1326 + case OP_SIDEBAR_SCROLL_DOWN:
1327 + CurBuffy = BottomBuffy;
1328 + if ( CurBuffy->next ) {
1329 + calc_boundaries(menu);
1330 + CurBuffy = CurBuffy->next;
1336 + calc_boundaries(menu);
1337 + draw_sidebar(menu);
1340 diff -urN mutt-1.5.21/sidebar.h mutt-1.5.21-sidebar/sidebar.h
1341 --- mutt-1.5.21/sidebar.h 1970-01-01 01:00:00.000000000 +0100
1342 +++ mutt-1.5.21-sidebar/sidebar.h 2011-03-09 12:09:45.178893458 +0100
1345 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1346 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1348 + * This program is free software; you can redistribute it and/or modify
1349 + * it under the terms of the GNU General Public License as published by
1350 + * the Free Software Foundation; either version 2 of the License, or
1351 + * (at your option) any later version.
1353 + * This program is distributed in the hope that it will be useful,
1354 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1355 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1356 + * GNU General Public License for more details.
1358 + * You should have received a copy of the GNU General Public License
1359 + * along with this program; if not, write to the Free Software
1360 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
1372 +/* parameter is whether or not to go to the status line */
1373 +/* used for omitting the last | that covers up the status bar in the index */
1374 +int draw_sidebar(int);
1375 +void scroll_sidebar(int, int);
1376 +void set_curbuffy(char*);
1377 +void set_buffystats(CONTEXT*);
1379 +#endif /* SIDEBAR_H */