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 const char * const Prompts[] =
169 static void redraw_crypt_lines (HEADER *msg)
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 @@ -249,10 +249,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"));
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);
258 if (msg->env->subject)
259 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);
308 if ((menu->redraw & REDRAW_STATUS) || update_status_time ())
311 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
313 move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
314 SETCOLOR (MT_COLOR_STATUS);
315 + set_buffystats(Context);
316 mutt_paddstr (COLS, buf);
318 menu->redraw &= ~REDRAW_STATUS;
320 menu->oldcurrent = -1;
322 if (option (OPTARROWCURSOR))
323 - move (menu->current - menu->top + menu->offset, 2);
324 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
325 else if (option (OPTBRAILLEFRIENDLY))
326 move (menu->current - menu->top + menu->offset, 0);
328 @@ -1070,6 +1080,7 @@
329 menu->redraw = REDRAW_FULL;
332 + case OP_SIDEBAR_OPEN:
333 case OP_MAIN_CHANGE_FOLDER:
334 case OP_MAIN_NEXT_UNREAD_MAILBOX:
336 @@ -1101,7 +1112,11 @@
338 mutt_buffy (buf, sizeof (buf));
340 - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
341 + if ( op == OP_SIDEBAR_OPEN ) {
344 + strncpy( buf, CurBuffy->path, sizeof(buf) );
345 + } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
347 if (menu->menu == MENU_PAGER)
349 @@ -1119,6 +1134,7 @@
352 mutt_expand_path (buf, sizeof (buf));
354 if (mx_get_magic (buf) <= 0)
356 mutt_error (_("%s is not a mailbox."), buf);
357 @@ -2222,6 +2238,12 @@
361 + case OP_SIDEBAR_SCROLL_UP:
362 + case OP_SIDEBAR_SCROLL_DOWN:
363 + case OP_SIDEBAR_NEXT:
364 + case OP_SIDEBAR_PREV:
365 + scroll_sidebar(op, menu->menu);
368 if (menu->menu == MENU_MAIN)
369 km_error_key (MENU_MAIN);
370 diff -urN mutt-1.5.21/doc/Muttrc mutt-1.5.21-sidebar/doc/Muttrc
371 --- mutt-1.5.21/doc/Muttrc 2010-09-15 19:07:19.000000000 +0200
372 +++ mutt-1.5.21-sidebar/doc/Muttrc 2011-03-09 12:09:45.180894458 +0100
374 # $crypt_autosign, $crypt_replysign and $smime_is_default.
377 +# set sidebar_visible=no
379 +# Name: sidebar_visible
384 +# This specifies whether or not to show sidebar (left-side list of folders).
387 +# set sidebar_width=0
389 +# Name: sidebar_width
394 +# The width of the sidebar.
397 # set crypt_autosign=no
399 # Name: crypt_autosign
400 diff -urN mutt-1.5.21/flags.c mutt-1.5.21-sidebar/flags.c
401 --- mutt-1.5.21/flags.c 2009-01-04 00:27:10.000000000 +0100
402 +++ mutt-1.5.21-sidebar/flags.c 2011-03-09 12:09:45.144876460 +0100
406 #include "mutt_curses.h"
407 +#include "mutt_menu.h"
410 +#include "sidebar.h"
412 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
416 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
421 void mutt_tag_set_flag (int flag, int bf)
422 diff -urN mutt-1.5.21/functions.h mutt-1.5.21-sidebar/functions.h
423 --- mutt-1.5.21/functions.h 2010-08-24 18:34:21.000000000 +0200
424 +++ mutt-1.5.21-sidebar/functions.h 2011-03-09 12:21:14.093264460 +0100
426 { "decrypt-save", OP_DECRYPT_SAVE, NULL },
429 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
430 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
431 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
432 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
433 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
439 { "what-key", OP_WHAT_KEY, NULL },
441 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
442 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
443 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
444 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
445 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
449 diff -urN mutt-1.5.21/globals.h mutt-1.5.21-sidebar/globals.h
450 --- mutt-1.5.21/globals.h 2009-08-25 21:08:52.000000000 +0200
451 +++ mutt-1.5.21-sidebar/globals.h 2011-03-09 12:09:45.146877460 +0100
453 WHERE char *SendCharset;
454 WHERE char *Sendmail;
456 +WHERE char *SidebarDelim;
457 WHERE char *Signature;
458 WHERE char *SimpleSearch;
461 WHERE short ScoreThresholdRead;
462 WHERE short ScoreThresholdFlag;
464 +WHERE struct buffy_t *CurBuffy INITVAL(0);
465 +WHERE short DrawFullLine INITVAL(0);
466 +WHERE short SidebarWidth;
468 WHERE short ImapKeepalive;
469 WHERE short ImapPipelineDepth;
470 diff -urN mutt-1.5.21/imap/command.c mutt-1.5.21-sidebar/imap/command.c
471 --- mutt-1.5.21/imap/command.c 2010-09-15 17:39:31.000000000 +0200
472 +++ mutt-1.5.21-sidebar/imap/command.c 2011-03-09 12:09:45.184896458 +0100
473 @@ -1011,6 +1011,13 @@
475 status->uidnext = oldun;
477 + /* Added to make the sidebar show the correct numbers */
478 + if (status->messages)
480 + inc->msgcount = status->messages;
481 + inc->msg_unread = status->unseen;
487 diff -urN mutt-1.5.21/imap/imap.c mutt-1.5.21-sidebar/imap/imap.c
488 --- mutt-1.5.21/imap/imap.c 2009-08-25 21:08:52.000000000 +0200
489 +++ mutt-1.5.21-sidebar/imap/imap.c 2011-03-09 12:09:45.183895958 +0100
490 @@ -1521,7 +1521,7 @@
492 imap_munge_mbox_name (munged, sizeof (munged), name);
493 snprintf (command, sizeof (command),
494 - "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
495 + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
497 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
499 diff -urN mutt-1.5.21/init.h mutt-1.5.21-sidebar/init.h
500 --- mutt-1.5.21/init.h 2010-09-15 17:39:31.000000000 +0200
501 +++ mutt-1.5.21-sidebar/init.h 2011-03-09 12:21:14.094264460 +0100
502 @@ -1953,6 +1953,32 @@
506 + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
509 + ** This specifies the delimiter between the sidebar (if visible) and
512 + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
515 + ** This specifies whether or not to show sidebar (left-side list of folders).
517 + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
520 + ** The width of the sidebar.
522 + { "sidebar_shortpath", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 0 },
525 + ** Should the sidebar shorten the path showed.
527 + { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
530 + ** Should the sidebar be sorted.
532 { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
535 diff -urN mutt-1.5.21/mailbox.h mutt-1.5.21-sidebar/mailbox.h
536 --- mutt-1.5.21/mailbox.h 2009-04-30 19:33:48.000000000 +0200
537 +++ mutt-1.5.21-sidebar/mailbox.h 2011-03-09 12:09:45.148878460 +0100
539 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
540 * safe_fopen() for mbox-style folders.
542 +#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */
544 /* mx_open_new_message() */
545 #define M_ADD_FROM 1 /* add a From_ line */
546 diff -urN mutt-1.5.21/Makefile.am mutt-1.5.21-sidebar/Makefile.am
547 --- mutt-1.5.21/Makefile.am 2010-08-24 18:34:21.000000000 +0200
548 +++ mutt-1.5.21-sidebar/Makefile.am 2011-03-09 12:09:45.151879960 +0100
550 score.c send.c sendlib.c signal.c sort.c \
551 status.c system.c thread.c charset.c history.c lib.c \
552 muttlib.c editmsg.c mbyte.c \
553 - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
554 + url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c \
557 nodist_mutt_SOURCES = $(BUILT_SOURCES)
559 diff -urN mutt-1.5.21/mbox.c mutt-1.5.21-sidebar/mbox.c
560 --- mutt-1.5.21/mbox.c 2010-09-13 19:19:55.000000000 +0200
561 +++ mutt-1.5.21-sidebar/mbox.c 2011-03-09 12:09:45.152880460 +0100
563 mutt_perror (ctx->path);
566 + ctx->atime = sb.st_atime;
567 ctx->mtime = sb.st_mtime;
568 ctx->size = sb.st_size;
572 ctx->size = sb.st_size;
573 ctx->mtime = sb.st_mtime;
574 + ctx->atime = sb.st_atime;
576 #ifdef NFS_ATTRIBUTE_HACK
577 if (sb.st_mtime > sb.st_atime)
578 diff -urN mutt-1.5.21/menu.c mutt-1.5.21-sidebar/menu.c
579 --- mutt-1.5.21/menu.c 2010-08-25 18:31:40.000000000 +0200
580 +++ mutt-1.5.21-sidebar/menu.c 2011-03-09 12:09:45.153880960 +0100
582 #include "mutt_curses.h"
583 #include "mutt_menu.h"
585 +#include "sidebar.h"
587 extern size_t UngetCount;
591 char *scratch = safe_strdup (s);
592 int shift = option (OPTARROWCURSOR) ? 3 : 0;
593 - int cols = COLS - shift;
594 + int cols = COLS - shift - SidebarWidth;
596 mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
603 for (i = menu->top; i < menu->top + menu->pagelen; i++)
607 menu_pad_string (buf, sizeof (buf));
610 - move(i - menu->top + menu->offset, 0);
611 + move(i - menu->top + menu->offset, SidebarWidth);
614 if (i == menu->current)
619 - CLEARLINE(i - menu->top + menu->offset);
620 + CLEARLINE_WIN(i - menu->top + menu->offset);
628 - move (menu->oldcurrent + menu->offset - menu->top, 0);
629 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
630 ATTRSET(menu->color (menu->oldcurrent));
632 if (option (OPTARROWCURSOR))
633 @@ -301,13 +303,13 @@
635 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
636 menu_pad_string (buf, sizeof (buf));
637 - move (menu->oldcurrent + menu->offset - menu->top, 3);
638 + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
639 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
642 /* now draw it in the new location */
643 SETCOLOR(MT_COLOR_INDICATOR);
644 - mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
645 + mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->");
650 menu_make_entry (buf, sizeof (buf), menu, menu->current);
651 menu_pad_string (buf, sizeof (buf));
652 SETCOLOR(MT_COLOR_INDICATOR);
653 - move(menu->current - menu->top + menu->offset, 0);
654 + move(menu->current - menu->top + menu->offset, SidebarWidth);
655 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
657 menu->redraw &= REDRAW_STATUS;
659 char buf[LONG_STRING];
660 int attr = menu->color (menu->current);
662 - move (menu->current + menu->offset - menu->top, 0);
663 + move (menu->current + menu->offset - menu->top, SidebarWidth);
664 menu_make_entry (buf, sizeof (buf), menu, menu->current);
665 menu_pad_string (buf, sizeof (buf));
670 if (option (OPTARROWCURSOR))
671 - move (menu->current - menu->top + menu->offset, 2);
672 + move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
673 else if (option (OPTBRAILLEFRIENDLY))
674 move (menu->current - menu->top + menu->offset, 0);
676 diff -urN mutt-1.5.21/mutt_curses.h mutt-1.5.21-sidebar/mutt_curses.h
677 --- mutt-1.5.21/mutt_curses.h 2008-03-19 21:07:57.000000000 +0100
678 +++ mutt-1.5.21-sidebar/mutt_curses.h 2011-03-09 12:09:45.154881460 +0100
683 +#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
684 #define CLEARLINE(x) move(x,0), clrtoeol()
685 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
686 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
696 diff -urN mutt-1.5.21/mutt.h mutt-1.5.21-sidebar/mutt.h
697 --- mutt-1.5.21/mutt.h 2010-09-13 19:19:55.000000000 +0200
698 +++ mutt-1.5.21-sidebar/mutt.h 2011-03-09 12:21:14.193264454 +0100
704 + OPTSIDEBARSHORTPATH,
718 unsigned int quiet : 1; /* inhibit status messages? */
719 unsigned int collapsed : 1; /* are all threads collapsed? */
720 unsigned int closing : 1; /* mailbox is being closed */
721 + unsigned int peekonly : 1; /* just taking a glance, revert atime */
724 void *data; /* driver specific data */
725 diff -urN mutt-1.5.21/muttlib.c mutt-1.5.21-sidebar/muttlib.c
726 --- mutt-1.5.21/muttlib.c 2010-08-25 18:31:40.000000000 +0200
727 +++ mutt-1.5.21-sidebar/muttlib.c 2011-03-09 12:09:45.156882460 +0100
728 @@ -1286,6 +1286,8 @@
731 /* see if there's room to add content, else ignore */
732 + if ( DrawFullLine )
734 if ((col < COLS && wlen < destlen) || soft)
737 @@ -1329,6 +1331,52 @@
744 + if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
748 + /* get contents after padding */
749 + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
750 + len = mutt_strlen (buf);
751 + wid = mutt_strwidth (buf);
753 + /* try to consume as many columns as we can, if we don't have
754 + * memory for that, use as much memory as possible */
755 + pad = (COLS - SidebarWidth - col - wid) / pw;
756 + if (pad > 0 && wlen + (pad * pl) + len > destlen)
757 + pad = ((signed)(destlen - wlen - len)) / pl;
762 + memcpy (wptr, src, pl);
768 + else if (soft && pad < 0)
770 + /* \0-terminate dest for length computation in mutt_wstr_trunc() */
772 + /* make sure right part is at most as wide as display */
773 + len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
774 + /* truncate left so that right part fits completely in */
775 + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
776 + wptr = dest + wlen;
778 + if (len + wlen > destlen)
779 + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
780 + memcpy (wptr, buf, len);
787 break; /* skip rest of input */
790 diff -urN mutt-1.5.21/mx.c mutt-1.5.21-sidebar/mx.c
791 --- mutt-1.5.21/mx.c 2010-09-13 19:19:55.000000000 +0200
792 +++ mutt-1.5.21-sidebar/mx.c 2011-03-09 12:09:45.157882960 +0100
794 * M_APPEND open mailbox for appending
795 * M_READONLY open mailbox in read-only mode
796 * M_QUIET only print error messages
797 + * M_PEEK revert atime where applicable
798 * ctx if non-null, context struct to use
800 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
803 if (flags & M_READONLY)
805 + if (flags & M_PEEK)
808 if (flags & (M_APPEND|M_NEWFOLDER))
811 void mx_fastclose_mailbox (CONTEXT *ctx)
821 + /* fix up the times so buffy won't get confused */
822 + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
824 + ut.actime = ctx->atime;
825 + ut.modtime = ctx->mtime;
826 + utime (ctx->path, &ut);
830 /* never announce that a mailbox we've just left has new mail. #3290
831 * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
832 diff -urN mutt-1.5.21/OPS mutt-1.5.21-sidebar/OPS
833 --- mutt-1.5.21/OPS 2010-03-01 18:56:19.000000000 +0100
834 +++ mutt-1.5.21-sidebar/OPS 2011-03-09 12:21:14.091264460 +0100
836 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
837 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
838 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
839 +OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
840 +OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
841 +OP_SIDEBAR_NEXT "go down to next mailbox"
842 +OP_SIDEBAR_PREV "go to previous mailbox"
843 +OP_SIDEBAR_OPEN "open hilighted mailbox"
844 diff -urN mutt-1.5.21/pager.c mutt-1.5.21-sidebar/pager.c
845 --- mutt-1.5.21/pager.c 2010-08-25 18:31:40.000000000 +0200
846 +++ mutt-1.5.21-sidebar/pager.c 2011-03-09 12:54:30.262264458 +0100
851 +#include "sidebar.h"
853 #include "mutt_crypt.h"
855 @@ -1099,6 +1100,7 @@
856 if (check_attachment_marker ((char *)buf) == 0)
859 + wrap_cols -= SidebarWidth;
860 /* FIXME: this should come from lineInfo */
861 memset(&mbstate, 0, sizeof(mbstate));
863 @@ -1809,7 +1811,7 @@
864 if ((redraw & REDRAW_BODY) || topline != oldtopline)
867 - move (bodyoffset, 0);
868 + move (bodyoffset, SidebarWidth);
869 curline = oldtopline = topline;
872 @@ -1822,6 +1824,7 @@
873 &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
876 + move(lines + bodyoffset, SidebarWidth);
878 last_offset = lineInfo[curline].offset;
879 } while (force_redraw);
880 @@ -1834,6 +1837,7 @@
884 + move(lines + bodyoffset, SidebarWidth);
888 @@ -1857,22 +1861,22 @@
889 strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
891 /* print out the pager status bar */
892 - move (statusoffset, 0);
893 + move (statusoffset, SidebarWidth);
894 SETCOLOR (MT_COLOR_STATUS);
896 if (IsHeader (extra) || IsMsgAttach (extra))
898 - size_t l1 = COLS * MB_LEN_MAX;
899 + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
900 size_t l2 = sizeof (buffer);
901 hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
902 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
903 - mutt_paddstr (COLS, buffer);
904 + mutt_paddstr (COLS-SidebarWidth, buffer);
909 snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
910 - mutt_paddstr (COLS, bn);
911 + mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner);
915 @@ -1882,16 +1886,23 @@
916 /* redraw the pager_index indicator, because the
917 * flags for this message might have changed. */
918 menu_redraw_current (index);
919 + draw_sidebar(MENU_PAGER);
921 /* print out the index status bar */
923 menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
926 - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
927 + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
928 SETCOLOR (MT_COLOR_STATUS);
929 - mutt_paddstr (COLS, buffer);
930 + mutt_paddstr (COLS-SidebarWidth, buffer);
934 + /* if we're not using the index, update every time */
936 + draw_sidebar(MENU_PAGER);
940 if (option(OPTBRAILLEFRIENDLY)) {
941 @@ -2848,6 +2859,13 @@
945 + case OP_SIDEBAR_SCROLL_UP:
946 + case OP_SIDEBAR_SCROLL_DOWN:
947 + case OP_SIDEBAR_NEXT:
948 + case OP_SIDEBAR_PREV:
949 + scroll_sidebar(ch, MENU_PAGER);
955 diff -urN mutt-1.5.21/sidebar.c mutt-1.5.21-sidebar/sidebar.c
956 --- mutt-1.5.21/sidebar.c 1970-01-01 01:00:00.000000000 +0100
957 +++ mutt-1.5.21-sidebar/sidebar.c 2011-03-09 12:21:14.200264458 +0100
960 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
961 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
963 + * This program is free software; you can redistribute it and/or modify
964 + * it under the terms of the GNU General Public License as published by
965 + * the Free Software Foundation; either version 2 of the License, or
966 + * (at your option) any later version.
968 + * This program is distributed in the hope that it will be useful,
969 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
970 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
971 + * GNU General Public License for more details.
973 + * You should have received a copy of the GNU General Public License
974 + * along with this program; if not, write to the Free Software
975 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
980 +# include "config.h"
984 +#include "mutt_menu.h"
985 +#include "mutt_curses.h"
986 +#include "sidebar.h"
990 +#include <stdbool.h>
992 +/*BUFFY *CurBuffy = 0;*/
993 +static BUFFY *TopBuffy = 0;
994 +static BUFFY *BottomBuffy = 0;
995 +static int known_lines = 0;
997 +static int quick_log10(int n)
1000 + sprintf(string, "%d", n);
1001 + return strlen(string);
1004 +void calc_boundaries (int menu)
1006 + BUFFY *tmp = Incoming;
1008 + if ( known_lines != LINES ) {
1009 + TopBuffy = BottomBuffy = 0;
1010 + known_lines = LINES;
1012 + for ( ; tmp->next != 0; tmp = tmp->next )
1013 + tmp->next->prev = tmp;
1015 + if (option(OPTSIDEBARSORT)) {
1020 + while (needsort==1) {
1023 + for ( ; tmp ; tmp=tmp->next ) {
1024 + if (tmp->next != NULL && strcmp(tmp->path, tmp->next->path) > 0) {
1029 + prev->next = next;
1032 + next->prev = prev;
1033 + tmp2 = next->next;
1044 + if ( TopBuffy == 0 && BottomBuffy == 0 )
1045 + TopBuffy = Incoming;
1046 + if ( BottomBuffy == 0 ) {
1047 + int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1048 + BottomBuffy = TopBuffy;
1049 + while ( --count && BottomBuffy->next )
1050 + BottomBuffy = BottomBuffy->next;
1052 + else if ( TopBuffy == CurBuffy->next ) {
1053 + int count = LINES - 2 - (menu != MENU_PAGER);
1054 + BottomBuffy = CurBuffy;
1055 + tmp = BottomBuffy;
1056 + while ( --count && tmp->prev)
1060 + else if ( BottomBuffy == CurBuffy->prev ) {
1061 + int count = LINES - 2 - (menu != MENU_PAGER);
1062 + TopBuffy = CurBuffy;
1064 + while ( --count && tmp->next )
1066 + BottomBuffy = tmp;
1070 +char *make_sidebar_entry(char *box, int size, int new, int flagged)
1072 + static char *entry = 0;
1075 + int delim_len = strlen(SidebarDelim);
1077 + c = realloc(entry, SidebarWidth - delim_len + 2);
1078 + if ( c ) entry = c;
1079 + entry[SidebarWidth - delim_len + 1] = 0;
1080 + for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1082 + strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1085 + sprintf(entry + SidebarWidth - delim_len - 3, "?");
1087 + if (flagged > 0) {
1089 + entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1090 + "% d(%d)[%d]", size, new, flagged);
1093 + entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1094 + "% d(%d)", size, new);
1096 + } else if (flagged > 0) {
1097 + sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1099 + sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1104 +void set_curbuffy(char buf[LONG_STRING])
1106 + BUFFY* tmp = CurBuffy = Incoming;
1112 + if(!strcmp(tmp->path, buf)) {
1124 +int draw_sidebar(int menu) {
1126 + int lines = option(OPTHELP) ? 1 : 0;
1128 +#ifndef USE_SLANG_CURSES
1131 + short delim_len = strlen(SidebarDelim);
1134 + static bool initialized = false;
1135 + static int prev_show_value;
1136 + static short saveSidebarWidth;
1138 + /* initialize first time */
1139 + if(!initialized) {
1140 + prev_show_value = option(OPTSIDEBAR);
1141 + saveSidebarWidth = SidebarWidth;
1142 + if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1143 + initialized = true;
1146 + /* save or restore the value SidebarWidth */
1147 + if(prev_show_value != option(OPTSIDEBAR)) {
1148 + if(prev_show_value && !option(OPTSIDEBAR)) {
1149 + saveSidebarWidth = SidebarWidth;
1151 + } else if(!prev_show_value && option(OPTSIDEBAR)) {
1152 + SidebarWidth = saveSidebarWidth;
1154 + prev_show_value = option(OPTSIDEBAR);
1158 +// if ( SidebarWidth == 0 ) return 0;
1159 + if (SidebarWidth > 0 && option (OPTSIDEBAR)
1160 + && delim_len >= SidebarWidth) {
1161 + unset_option (OPTSIDEBAR);
1162 + /* saveSidebarWidth = SidebarWidth; */
1163 + if (saveSidebarWidth > delim_len) {
1164 + SidebarWidth = saveSidebarWidth;
1165 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1169 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1170 + sleep (4); /* the advise to set a sane value should be seen long enough */
1172 + saveSidebarWidth = 0;
1176 + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1177 + if (SidebarWidth > 0) {
1178 + saveSidebarWidth = SidebarWidth;
1181 + unset_option(OPTSIDEBAR);
1185 + /* get attributes for divider */
1186 + SETCOLOR(MT_COLOR_STATUS);
1187 +#ifndef USE_SLANG_CURSES
1188 + attr_get(&attrs, &color_pair, 0);
1190 + color_pair = attr_get();
1192 + SETCOLOR(MT_COLOR_NORMAL);
1194 + /* draw the divider */
1196 + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1197 + move(lines, SidebarWidth - delim_len);
1198 + addstr(NONULL(SidebarDelim));
1199 +#ifndef USE_SLANG_CURSES
1200 + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1204 + if ( Incoming == 0 ) return 0;
1205 + lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1207 + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 )
1208 + calc_boundaries(menu);
1209 + if ( CurBuffy == 0 ) CurBuffy = Incoming;
1213 + SETCOLOR(MT_COLOR_NORMAL);
1215 + for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1216 + if ( tmp == CurBuffy )
1217 + SETCOLOR(MT_COLOR_INDICATOR);
1218 + else if ( tmp->msg_unread > 0 )
1219 + SETCOLOR(MT_COLOR_NEW);
1220 + else if ( tmp->msg_flagged > 0 )
1221 + SETCOLOR(MT_COLOR_FLAGGED);
1223 + SETCOLOR(MT_COLOR_NORMAL);
1226 + if ( Context && !strcmp( tmp->path, Context->path ) ) {
1227 + tmp->msg_unread = Context->unread;
1228 + tmp->msgcount = Context->msgcount;
1229 + tmp->msg_flagged = Context->flagged;
1231 + // check whether Maildir is a prefix of the current folder's path
1232 + short maildir_is_prefix = 0;
1233 + if ( (strlen(tmp->path) > strlen(Maildir)) &&
1234 + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1235 + maildir_is_prefix = 1;
1236 + // calculate depth of current folder and generate its display name with indented spaces
1237 + int sidebar_folder_depth = 0;
1238 + char *sidebar_folder_name;
1239 + sidebar_folder_name = basename(tmp->path);
1240 + if ( maildir_is_prefix ) {
1241 + char *tmp_folder_name;
1243 + tmp_folder_name = tmp->path + strlen(Maildir);
1244 + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1245 + if (tmp_folder_name[i] == '/' || tmp_folder_name[i] == '.') sidebar_folder_depth++;
1247 + if (sidebar_folder_depth > 0) {
1248 + if (option(OPTSIDEBARSHORTPATH)) {
1249 + tmp_folder_name = strrchr(tmp->path, '.');
1250 + if (tmp_folder_name == NULL)
1251 + tmp_folder_name = tmp->path;
1253 + tmp_folder_name++;
1256 + tmp_folder_name = tmp->path;
1257 + sidebar_folder_name = malloc(strlen(basename(tmp_folder_name)) + sidebar_folder_depth + 1);
1258 + for (i=0; i < sidebar_folder_depth; i++)
1259 + sidebar_folder_name[i]=' ';
1260 + sidebar_folder_name[i]=0;
1261 + strncat(sidebar_folder_name, basename(tmp_folder_name), strlen(basename(tmp_folder_name)) + sidebar_folder_depth);
1264 + printw( "%.*s", SidebarWidth - delim_len + 1,
1265 + make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1266 + tmp->msg_unread, tmp->msg_flagged));
1267 + if (sidebar_folder_depth > 0)
1268 + free(sidebar_folder_name);
1271 + SETCOLOR(MT_COLOR_NORMAL);
1272 + for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1275 + for ( ; i < SidebarWidth - delim_len; i++ )
1282 +void set_buffystats(CONTEXT* Context)
1284 + BUFFY *tmp = Incoming;
1286 + if(Context && !strcmp(tmp->path, Context->path)) {
1287 + tmp->msg_unread = Context->unread;
1288 + tmp->msgcount = Context->msgcount;
1295 +void scroll_sidebar(int op, int menu)
1297 + if(!SidebarWidth) return;
1298 + if(!CurBuffy) return;
1301 + case OP_SIDEBAR_NEXT:
1302 + if ( CurBuffy->next == NULL ) return;
1303 + CurBuffy = CurBuffy->next;
1305 + case OP_SIDEBAR_PREV:
1306 + if ( CurBuffy->prev == NULL ) return;
1307 + CurBuffy = CurBuffy->prev;
1309 + case OP_SIDEBAR_SCROLL_UP:
1310 + CurBuffy = TopBuffy;
1311 + if ( CurBuffy != Incoming ) {
1312 + calc_boundaries(menu);
1313 + CurBuffy = CurBuffy->prev;
1316 + case OP_SIDEBAR_SCROLL_DOWN:
1317 + CurBuffy = BottomBuffy;
1318 + if ( CurBuffy->next ) {
1319 + calc_boundaries(menu);
1320 + CurBuffy = CurBuffy->next;
1326 + calc_boundaries(menu);
1327 + draw_sidebar(menu);
1330 diff -urN mutt-1.5.21/sidebar.h mutt-1.5.21-sidebar/sidebar.h
1331 --- mutt-1.5.21/sidebar.h 1970-01-01 01:00:00.000000000 +0100
1332 +++ mutt-1.5.21-sidebar/sidebar.h 2011-03-09 12:09:45.178893458 +0100
1335 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1336 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1338 + * This program is free software; you can redistribute it and/or modify
1339 + * it under the terms of the GNU General Public License as published by
1340 + * the Free Software Foundation; either version 2 of the License, or
1341 + * (at your option) any later version.
1343 + * This program is distributed in the hope that it will be useful,
1344 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1345 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1346 + * GNU General Public License for more details.
1348 + * You should have received a copy of the GNU General Public License
1349 + * along with this program; if not, write to the Free Software
1350 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
1362 +/* parameter is whether or not to go to the status line */
1363 +/* used for omitting the last | that covers up the status bar in the index */
1364 +int draw_sidebar(int);
1365 +void scroll_sidebar(int, int);
1366 +void set_curbuffy(char*);
1367 +void set_buffystats(CONTEXT*);
1369 +#endif /* SIDEBAR_H */