]> git.pld-linux.org Git - packages/mutt.git/blob - mutt-sidebar.patch
3d64557c483a16cce659670f5c9e29272514a16a
[packages/mutt.git] / mutt-sidebar.patch
1 *** mutt-1.5.24-orig/buffy.c    2015-08-30 12:06:38.000000000 -0500
2 --- mutt-1.5.24/buffy.c 2015-09-16 23:18:13.000000000 -0500
3 ***************
4 *** 161,166 ****
5 --- 161,209 ----
6     }
7   }
8   
9 + static int buffy_compare_name(const void *a, const void *b) {
10 +   const BUFFY *b1 = * (BUFFY * const *) a;
11 +   const BUFFY *b2 = * (BUFFY * const *) b;
12
13 +   return mutt_strcoll(b1->path, b2->path);
14 + }
15
16 + static BUFFY *buffy_sort(BUFFY *b)
17 + {
18 +   BUFFY *tmp = b;
19 +   int buffycount = 0;
20 +   BUFFY **ary;
21 +   int i;
22
23 +   if (!option(OPTSIDEBARSORT))
24 +     return b;
25
26 +   for (; tmp != NULL; tmp = tmp->next)
27 +     buffycount++;
28
29 +   ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
30
31 +   tmp = b;
32 +   for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
33 +     ary[i] = tmp;
34 +   }
35
36 +   qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
37
38 +   for (i = 0; i < buffycount - 1; i++) {
39 +     ary[i]->next = ary[i+1];
40 +   }
41 +   ary[buffycount - 1]->next = NULL;
42 +   for (i = 1; i < buffycount; i++) {
43 +     ary[i]->prev = ary[i-1];
44 +   }
45 +   ary[0]->prev = NULL;
46
47 +   tmp = ary[0];
48 +   free(ary);
49 +   return tmp;
50 + }
51
52   BUFFY *mutt_find_mailbox (const char *path)
53   {
54     BUFFY *tmp = NULL;
55 ***************
56 *** 196,204 ****
57 --- 239,251 ----
58   static BUFFY *buffy_new (const char *path)
59   {
60     BUFFY* buffy;
61 +   char rp[PATH_MAX];
62 +   char *r;
63   
64     buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
65     strfcpy (buffy->path, path, sizeof (buffy->path));
66 +   r = realpath(path, rp);
67 +   strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
68     buffy->next = NULL;
69     buffy->magic = 0;
70   
71 ***************
72 *** 243,250 ****
73       p = realpath (buf, f1);
74       for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
75       {
76 !       q = realpath ((*tmp)->path, f2);
77 !       if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0)
78         {
79         dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
80         break;
81 --- 290,297 ----
82       p = realpath (buf, f1);
83       for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
84       {
85 !       q = (*tmp)->realpath;
86 !       if (mutt_strcmp (p ? p : buf, q) == 0)
87         {
88         dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
89         break;
90 ***************
91 *** 282,287 ****
92 --- 329,335 ----
93       else
94         (*tmp)->size = 0;
95     }
96 +   Incoming = buffy_sort(Incoming);
97     return 0;
98   }
99   
100 ***************
101 *** 306,311 ****
102 --- 354,364 ----
103         return 0;
104     }
105   
106 +   if (option(OPTSIDEBAR) && mailbox->msg_unread > 0) {
107 +       mailbox->new = 1;
108 +       return 1;
109 +   }
110
111     if ((dirp = opendir (path)) == NULL)
112     {
113       mailbox->magic = 0;
114 ***************
115 *** 357,362 ****
116 --- 410,482 ----
117   
118     return 0;
119   }
120 +   
121 +  /* update message counts for the sidebar */
122 + void buffy_maildir_update (BUFFY* mailbox)
123 + {
124 +  char path[_POSIX_PATH_MAX];
125 +  DIR *dirp;
126 +  struct dirent *de;
127 +  char *p;
128
129 +  if(!option(OPTSIDEBAR))
130 +      return;
131
132 +  mailbox->msgcount = 0;
133 +  mailbox->msg_unread = 0;
134 +  mailbox->msg_flagged = 0;
135
136 +  snprintf (path, sizeof (path), "%s/new", mailbox->path);
137 +        
138 +  if ((dirp = opendir (path)) == NULL)
139 +  {   
140 +    mailbox->magic = 0;
141 +    return;
142 +  } 
143 +        
144 +  while ((de = readdir (dirp)) != NULL)
145 +  {
146 +    if (*de->d_name == '.')
147 +      continue;
148
149 +    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
150 +      mailbox->new = 1;
151 +      mailbox->msgcount++;
152 +      mailbox->msg_unread++;
153 +    }
154 +  }
155
156 +  closedir (dirp);
157 +  snprintf (path, sizeof (path), "%s/cur", mailbox->path);
158 +        
159 +  if ((dirp = opendir (path)) == NULL)
160 +  {   
161 +   mailbox->magic = 0;
162 +    return;
163 +  } 
164 +        
165 +  while ((de = readdir (dirp)) != NULL)
166 +  {
167 +    if (*de->d_name == '.')
168 +      continue;
169
170 +    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
171 +      mailbox->msgcount++;
172 +      if ((p = strstr (de->d_name, ":2,"))) {
173 +        if (!strchr (p + 3, 'T')) {
174 +          if (!strchr (p + 3, 'S'))
175 +            mailbox->msg_unread++;
176 +          if (strchr(p + 3, 'F'))
177 +            mailbox->msg_flagged++;
178 +        }
179 +      }
180 +    }
181 +  }
182
183 +  mailbox->sb_last_checked = time(NULL);
184 +  closedir (dirp);
185 + }
186
187   /* returns 1 if mailbox has new mail */ 
188   static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
189   {
190 ***************
191 *** 368,374 ****
192     else
193       statcheck = sb->st_mtime > sb->st_atime
194         || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
195 !   if (statcheck)
196     {
197       if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
198       {
199 --- 488,494 ----
200     else
201       statcheck = sb->st_mtime > sb->st_atime
202         || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
203 !   if ((!option(OPTSIDEBAR) && statcheck) || (option(OPTSIDEBAR) && mailbox->msg_unread > 0))
204     {
205       if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
206       {
207 ***************
208 *** 388,393 ****
209 --- 508,534 ----
210     return rc;
211   }
212   
213 + /* update message counts for the sidebar */
214 + void buffy_mbox_update (BUFFY* mailbox, struct stat *sb)
215 + {
216 +   CONTEXT *ctx = NULL;
217
218 +   if(!option(OPTSIDEBAR))
219 +       return;
220 +   if(mailbox->sb_last_checked > sb->st_mtime && mailbox->msgcount != 0)
221 +       return; /* no check necessary */
222
223 +   ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
224 +   if(ctx)
225 +   {
226 +     mailbox->msgcount = ctx->msgcount;
227 +     mailbox->msg_unread = ctx->unread;
228 +     mailbox->msg_flagged = ctx->flagged;
229 +     mailbox->sb_last_checked = time(NULL);
230 +     mx_close_mailbox(ctx, 0);
231 +   }
232 + }
233
234   int mutt_buffy_check (int force)
235   {
236     BUFFY *tmp;
237 ***************
238 *** 461,477 ****
239         {
240         case M_MBOX:
241         case M_MMDF:
242         if (buffy_mbox_hasnew (tmp, &sb) > 0)
243           BuffyCount++;
244         break;
245   
246         case M_MAILDIR:
247         if (buffy_maildir_hasnew (tmp) > 0)
248           BuffyCount++;
249         break;
250   
251         case M_MH:
252 !       mh_buffy(tmp);
253         if (tmp->new)
254           BuffyCount++;
255         break;
256 --- 602,621 ----
257         {
258         case M_MBOX:
259         case M_MMDF:
260 +       buffy_mbox_update (tmp, &sb);
261         if (buffy_mbox_hasnew (tmp, &sb) > 0)
262           BuffyCount++;
263         break;
264   
265         case M_MAILDIR:
266 +       buffy_maildir_update (tmp);
267         if (buffy_maildir_hasnew (tmp) > 0)
268           BuffyCount++;
269         break;
270   
271         case M_MH:
272 !       mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged, &tmp->sb_last_checked);
273 !         mh_buffy(tmp);
274         if (tmp->new)
275           BuffyCount++;
276         break;
277 *** mutt-1.5.24-orig/buffy.h    2015-08-30 12:06:38.000000000 -0500
278 --- mutt-1.5.24/buffy.h 2015-09-16 23:18:13.000000000 -0500
279 ***************
280 *** 23,35 ****
281 --- 23,41 ----
282   typedef struct buffy_t
283   {
284     char path[_POSIX_PATH_MAX];
285 +   char realpath[_POSIX_PATH_MAX];
286     off_t size;
287     struct buffy_t *next;
288 +   struct buffy_t *prev;
289     short new;                  /* mailbox has new mail */
290 +   int msgcount;                       /* total number of messages */
291 +   int msg_unread;             /* number of unread messages */
292 +   int msg_flagged;            /* number of flagged messages */
293     short notified;             /* user has been notified */
294     short magic;                        /* mailbox type */
295     short newly_created;                /* mbox or mmdf just popped into existence */
296     time_t last_visited;                /* time of last exit from this mailbox */
297 +   time_t sb_last_checked;      /* time of last buffy check from sidebar */
298   }
299   BUFFY;
300   
301 *** mutt-1.5.24-orig/color.c    2015-08-30 12:06:38.000000000 -0500
302 --- mutt-1.5.24/color.c 2015-09-16 23:18:13.000000000 -0500
303 ***************
304 *** 94,99 ****
305 --- 94,101 ----
306     { "underline",      MT_COLOR_UNDERLINE },
307     { "index",          MT_COLOR_INDEX },
308     { "prompt",         MT_COLOR_PROMPT },
309 +   { "sidebar_new",    MT_COLOR_NEW },
310 +   { "sidebar_flagged",        MT_COLOR_FLAGGED },
311     { NULL,             0 }
312   };
313   
314 *** mutt-1.5.24-orig/compose.c  2015-08-30 12:06:38.000000000 -0500
315 --- mutt-1.5.24/compose.c       2015-09-16 23:18:13.000000000 -0500
316 ***************
317 *** 72,78 ****
318   
319   #define HDR_XOFFSET 10
320   #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
321 ! #define W (COLS - HDR_XOFFSET)
322   
323   static const char * const Prompts[] =
324   {
325 --- 72,78 ----
326   
327   #define HDR_XOFFSET 10
328   #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
329 ! #define W (COLS - HDR_XOFFSET - SidebarWidth)
330   
331   static const char * const Prompts[] =
332   {
333 ***************
334 *** 110,116 ****
335   
336   static void redraw_crypt_lines (HEADER *msg)
337   {
338 !   mvaddstr (HDR_CRYPT, 0, "Security: ");
339   
340     if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
341     {
342 --- 110,116 ----
343   
344   static void redraw_crypt_lines (HEADER *msg)
345   {
346 !   mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
347   
348     if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
349     {
350 ***************
351 *** 145,151 ****
352         addstr (_(" (OppEnc mode)"));
353   
354     clrtoeol ();
355 !   move (HDR_CRYPTINFO, 0);
356     clrtoeol ();
357   
358     if ((WithCrypto & APPLICATION_PGP)
359 --- 145,151 ----
360         addstr (_(" (OppEnc mode)"));
361   
362     clrtoeol ();
363 !   move (HDR_CRYPTINFO, SidebarWidth);
364     clrtoeol ();
365   
366     if ((WithCrypto & APPLICATION_PGP)
367 ***************
368 *** 162,168 ****
369         && (msg->security & ENCRYPT)
370         && SmimeCryptAlg
371         && *SmimeCryptAlg) {
372 !       mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
373                 NONULL(SmimeCryptAlg));
374     }
375   }
376 --- 162,168 ----
377         && (msg->security & ENCRYPT)
378         && SmimeCryptAlg
379         && *SmimeCryptAlg) {
380 !       mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
381                 NONULL(SmimeCryptAlg));
382     }
383   }
384 ***************
385 *** 175,181 ****
386     int c;
387     char *t;
388   
389 !   mvaddstr (HDR_MIX, 0,     "     Mix: ");
390   
391     if (!chain)
392     {
393 --- 175,181 ----
394     int c;
395     char *t;
396   
397 !   mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
398   
399     if (!chain)
400     {
401 ***************
402 *** 190,196 ****
403       if (t && t[0] == '0' && t[1] == '\0')
404         t = "<random>";
405       
406 !     if (c + mutt_strlen (t) + 2 >= COLS)
407         break;
408   
409       addstr (NONULL(t));
410 --- 190,196 ----
411       if (t && t[0] == '0' && t[1] == '\0')
412         t = "<random>";
413       
414 !     if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
415         break;
416   
417       addstr (NONULL(t));
418 ***************
419 *** 242,248 ****
420   
421     buf[0] = 0;
422     rfc822_write_address (buf, sizeof (buf), addr, 1);
423 !   mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
424     mutt_paddstr (W, buf);
425   }
426   
427 --- 242,248 ----
428   
429     buf[0] = 0;
430     rfc822_write_address (buf, sizeof (buf), addr, 1);
431 !   mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
432     mutt_paddstr (W, buf);
433   }
434   
435 ***************
436 *** 252,261 ****
437     draw_envelope_addr (HDR_TO, msg->env->to);
438     draw_envelope_addr (HDR_CC, msg->env->cc);
439     draw_envelope_addr (HDR_BCC, msg->env->bcc);
440 !   mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
441     mutt_paddstr (W, NONULL (msg->env->subject));
442     draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
443 !   mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
444     mutt_paddstr (W, fcc);
445   
446     if (WithCrypto)
447 --- 252,261 ----
448     draw_envelope_addr (HDR_TO, msg->env->to);
449     draw_envelope_addr (HDR_CC, msg->env->cc);
450     draw_envelope_addr (HDR_BCC, msg->env->bcc);
451 !   mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
452     mutt_paddstr (W, NONULL (msg->env->subject));
453     draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
454 !   mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
455     mutt_paddstr (W, fcc);
456   
457     if (WithCrypto)
458 ***************
459 *** 266,272 ****
460   #endif
461   
462     SETCOLOR (MT_COLOR_STATUS);
463 !   mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
464     clrtoeol ();
465   
466     NORMAL_COLOR;
467 --- 266,272 ----
468   #endif
469   
470     SETCOLOR (MT_COLOR_STATUS);
471 !   mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
472     clrtoeol ();
473   
474     NORMAL_COLOR;
475 ***************
476 *** 302,308 ****
477     /* redraw the expanded list so the user can see the result */
478     buf[0] = 0;
479     rfc822_write_address (buf, sizeof (buf), *addr, 1);
480 !   move (line, HDR_XOFFSET);
481     mutt_paddstr (W, buf);
482     
483     return 0;
484 --- 302,308 ----
485     /* redraw the expanded list so the user can see the result */
486     buf[0] = 0;
487     rfc822_write_address (buf, sizeof (buf), *addr, 1);
488 !   move (line, HDR_XOFFSET+SidebarWidth);
489     mutt_paddstr (W, buf);
490     
491     return 0;
492 ***************
493 *** 562,568 ****
494         if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
495         {
496           mutt_str_replace (&msg->env->subject, buf);
497 !         move (HDR_SUBJECT, HDR_XOFFSET);
498           if (msg->env->subject)
499             mutt_paddstr (W, msg->env->subject);
500           else
501 --- 562,568 ----
502         if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
503         {
504           mutt_str_replace (&msg->env->subject, buf);
505 !         move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
506           if (msg->env->subject)
507             mutt_paddstr (W, msg->env->subject);
508           else
509 ***************
510 *** 580,586 ****
511         {
512           strfcpy (fcc, buf, fcclen);
513           mutt_pretty_mailbox (fcc, fcclen);
514 !         move (HDR_FCC, HDR_XOFFSET);
515           mutt_paddstr (W, fcc);
516           fccSet = 1;
517         }
518 --- 580,586 ----
519         {
520           strfcpy (fcc, buf, fcclen);
521           mutt_pretty_mailbox (fcc, fcclen);
522 !         move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
523           mutt_paddstr (W, fcc);
524           fccSet = 1;
525         }
526 *** mutt-1.5.24-orig/configure.ac       2015-08-30 12:24:20.000000000 -0500
527 --- mutt-1.5.24/configure.ac    2015-09-16 23:18:13.000000000 -0500
528 ***************
529 *** 1302,1307 ****
530 --- 1302,1309 ----
531     AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,[ Define if you have <langinfo.h> and nl_langinfo(YESEXPR). ])
532   fi
533   
534 + AC_CHECK_FUNCS(fmemopen open_memstream)
535
536   dnl Documentation tools
537   have_openjade="no"
538   AC_PATH_PROG([OSPCAT], [ospcat], [none])
539 *** mutt-1.5.24-orig/curs_main.c        2015-08-30 12:06:38.000000000 -0500
540 --- mutt-1.5.24/curs_main.c     2015-09-16 23:18:13.000000000 -0500
541 ***************
542 *** 26,32 ****
543 --- 26,34 ----
544   #include "mailbox.h"
545   #include "mapping.h"
546   #include "sort.h"
547 + #include "buffy.h"
548   #include "mx.h"
549 + #include "sidebar.h"
550   
551   #ifdef USE_POP
552   #include "pop.h"
553 ***************
554 *** 596,615 ****
555          menu->redraw |= REDRAW_STATUS;
556        if (do_buffy_notify)
557        {
558 !        if (mutt_buffy_notify () && option (OPTBEEPNEW))
559 !       beep ();
560        }
561        else
562          do_buffy_notify = 1;
563       }
564   
565       if (op != -1)
566         mutt_curs_set (0);
567   
568       if (menu->redraw & REDRAW_FULL)
569       {
570         menu_redraw_full (menu);
571         mutt_show_error ();
572       }
573   
574       if (menu->menu == MENU_MAIN)
575 --- 598,628 ----
576          menu->redraw |= REDRAW_STATUS;
577        if (do_buffy_notify)
578        {
579 !        if (mutt_buffy_notify ())
580 !        {
581 !          menu->redraw |= REDRAW_STATUS;
582 !          if (option (OPTBEEPNEW))
583 !            beep ();
584 !        }
585        }
586        else
587          do_buffy_notify = 1;
588       }
589   
590 +     if(option(OPTSIDEBAR))
591 +         menu->redraw |= REDRAW_SIDEBAR;
592
593       if (op != -1)
594         mutt_curs_set (0);
595   
596       if (menu->redraw & REDRAW_FULL)
597       {
598         menu_redraw_full (menu);
599 +       draw_sidebar(menu->menu);
600         mutt_show_error ();
601 +     } else if(menu->redraw & REDRAW_SIDEBAR) {
602 +         draw_sidebar(menu->menu);
603 +         menu->redraw &= ~REDRAW_SIDEBAR;
604       }
605   
606       if (menu->menu == MENU_MAIN)
607 ***************
608 *** 631,639 ****
609 --- 644,655 ----
610   
611         if (menu->redraw & REDRAW_STATUS)
612         {
613 +         DrawFullLine = 1;
614         menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
615 +         DrawFullLine = 0;
616         move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
617         SETCOLOR (MT_COLOR_STATUS);
618 +         set_buffystats(Context);
619         mutt_paddstr (COLS, buf);
620         NORMAL_COLOR;
621         menu->redraw &= ~REDRAW_STATUS;
622 ***************
623 *** 653,659 ****
624         menu->oldcurrent = -1;
625   
626         if (option (OPTARROWCURSOR))
627 !       move (menu->current - menu->top + menu->offset, 2);
628         else if (option (OPTBRAILLEFRIENDLY))
629         move (menu->current - menu->top + menu->offset, 0);
630         else
631 --- 669,675 ----
632         menu->oldcurrent = -1;
633   
634         if (option (OPTARROWCURSOR))
635 !       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
636         else if (option (OPTBRAILLEFRIENDLY))
637         move (menu->current - menu->top + menu->offset, 0);
638         else
639 ***************
640 *** 1095,1100 ****
641 --- 1111,1117 ----
642           break;
643   
644         CHECK_MSGCOUNT;
645 +         CHECK_VISIBLE;
646         CHECK_READONLY;
647         {
648           int oldvcount = Context->vcount;
649 ***************
650 *** 1154,1159 ****
651 --- 1171,1177 ----
652           menu->redraw = REDRAW_FULL;
653         break;
654   
655 +       case OP_SIDEBAR_OPEN:
656         case OP_MAIN_CHANGE_FOLDER:
657         case OP_MAIN_NEXT_UNREAD_MAILBOX:
658   
659 ***************
660 *** 1185,1191 ****
661         {
662           mutt_buffy (buf, sizeof (buf));
663   
664 !         if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
665           {
666             if (menu->menu == MENU_PAGER)
667             {
668 --- 1203,1213 ----
669         {
670           mutt_buffy (buf, sizeof (buf));
671   
672 !           if ( op == OP_SIDEBAR_OPEN ) {
673 !               if(!CurBuffy)
674 !                 break;
675 !             strncpy( buf, CurBuffy->path, sizeof(buf) );  
676 !           } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
677           {
678             if (menu->menu == MENU_PAGER)
679             {
680 ***************
681 *** 1203,1208 ****
682 --- 1225,1231 ----
683         }
684   
685         mutt_expand_path (buf, sizeof (buf));
686 +         set_curbuffy(buf);
687         if (mx_get_magic (buf) <= 0)
688         {
689           mutt_error (_("%s is not a mailbox."), buf);
690 ***************
691 *** 2293,2298 ****
692 --- 2316,2327 ----
693         mutt_what_key();
694         break;
695   
696 +       case OP_SIDEBAR_SCROLL_UP:
697 +       case OP_SIDEBAR_SCROLL_DOWN:
698 +       case OP_SIDEBAR_NEXT:
699 +       case OP_SIDEBAR_PREV:
700 +         scroll_sidebar(op, menu->menu);
701 +         break;
702         default:
703         if (menu->menu == MENU_MAIN)
704           km_error_key (MENU_MAIN);
705 *** mutt-1.5.24-orig/flags.c    2015-08-30 12:06:38.000000000 -0500
706 --- mutt-1.5.24/flags.c 2015-09-16 23:18:13.000000000 -0500
707 ***************
708 *** 22,29 ****
709 --- 22,31 ----
710   
711   #include "mutt.h"
712   #include "mutt_curses.h"
713 + #include "mutt_menu.h"
714   #include "sort.h"
715   #include "mx.h"
716 + #include "sidebar.h"
717   
718   void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
719   {
720 ***************
721 *** 263,268 ****
722 --- 265,271 ----
723      */
724     if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
725       h->searched = 0;
726 +       draw_sidebar(0);
727   }
728   
729   void mutt_tag_set_flag (int flag, int bf)
730 *** mutt-1.5.24-orig/functions.h        2015-08-30 12:06:38.000000000 -0500
731 --- mutt-1.5.24/functions.h     2015-09-16 23:18:13.000000000 -0500
732 ***************
733 *** 169,174 ****
734 --- 169,179 ----
735     { "decrypt-save",           OP_DECRYPT_SAVE,                NULL },
736   
737   
738 +  { "sidebar-scroll-up",       OP_SIDEBAR_SCROLL_UP, NULL },
739 +  { "sidebar-scroll-down",     OP_SIDEBAR_SCROLL_DOWN, NULL },
740 +  { "sidebar-next",            OP_SIDEBAR_NEXT, NULL },
741 +  { "sidebar-prev",            OP_SIDEBAR_PREV, NULL },
742 +  { "sidebar-open",            OP_SIDEBAR_OPEN, NULL },
743     { NULL,                     0,                              NULL }
744   };
745   
746 ***************
747 *** 272,277 ****
748 --- 277,287 ----
749   
750     { "what-key",               OP_WHAT_KEY,            NULL },
751   
752 +   { "sidebar-scroll-up",      OP_SIDEBAR_SCROLL_UP, NULL },
753 +   { "sidebar-scroll-down",    OP_SIDEBAR_SCROLL_DOWN, NULL },
754 +   { "sidebar-next",   OP_SIDEBAR_NEXT, NULL },
755 +   { "sidebar-prev",   OP_SIDEBAR_PREV, NULL },
756 +   { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
757     { NULL,             0,                              NULL }
758   };
759   
760 *** mutt-1.5.24-orig/globals.h  2015-08-30 12:06:38.000000000 -0500
761 --- mutt-1.5.24/globals.h       2015-09-16 23:18:13.000000000 -0500
762 ***************
763 *** 118,123 ****
764 --- 118,126 ----
765   WHERE char *SendCharset;
766   WHERE char *Sendmail;
767   WHERE char *Shell;
768 + WHERE char *SidebarDelim;
769 + WHERE char *SidebarFormat;
770 + WHERE char *SidebarIndentStr;
771   WHERE char *Signature;
772   WHERE char *SimpleSearch;
773   #if USE_SMTP
774 ***************
775 *** 213,218 ****
776 --- 216,224 ----
777   WHERE short ScoreThresholdRead;
778   WHERE short ScoreThresholdFlag;
779   
780 + WHERE struct buffy_t *CurBuffy INITVAL(0);
781 + WHERE short DrawFullLine INITVAL(0);
782 + WHERE short SidebarWidth;
783   #ifdef USE_IMAP
784   WHERE short ImapKeepalive;
785   WHERE short ImapPipelineDepth;
786 *** mutt-1.5.24-orig/handler.c  2015-08-30 12:06:38.000000000 -0500
787 --- mutt-1.5.24/handler.c       2015-09-16 23:18:13.000000000 -0500
788 ***************
789 *** 1603,1608 ****
790 --- 1603,1613 ----
791   
792     fseeko (s->fpin, b->offset, 0);
793   
794 + #ifdef HAVE_FMEMOPEN
795 +   char *temp;
796 +   size_t tempsize;
797 + #endif
798
799     /* see if we need to decode this part before processing it */
800     if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE ||
801         b->encoding == ENCUUENCODED || plaintext ||
802 ***************
803 *** 1618,1623 ****
804 --- 1623,1636 ----
805       {
806         /* decode to a tempfile, saving the original destination */
807         fp = s->fpout;
808 + #ifdef HAVE_FMEMOPEN
809 +      if ((s->fpout = open_memstream(&temp, &tempsize)) == NULL)
810 +      {
811 +        mutt_error _("Unable to open memory stream!");
812 +        dprint (1, (debugfile, "Can't open memory stream.\n"));
813 +        return -1;
814 +      }
815 + #else
816         mutt_mktemp (tempfile, sizeof (tempfile));
817         if ((s->fpout = safe_fopen (tempfile, "w")) == NULL)
818         {
819 ***************
820 *** 1625,1630 ****
821 --- 1638,1644 ----
822           dprint (1, (debugfile, "Can't open %s.\n", tempfile));
823           return -1;
824         }
825 + #endif
826         /* decoding the attachment changes the size and offset, so save a copy
827           * of the "real" values now, and restore them after processing
828           */
829 ***************
830 *** 1653,1661 ****
831         /* restore final destination and substitute the tempfile for input */
832         s->fpout = fp;
833         fp = s->fpin;
834         s->fpin = fopen (tempfile, "r");
835         unlink (tempfile);
836
837         /* restore the prefix */
838         s->prefix = savePrefix;
839       }
840 --- 1667,1685 ----
841         /* restore final destination and substitute the tempfile for input */
842         s->fpout = fp;
843         fp = s->fpin;
844 + #ifdef HAVE_FMEMOPEN
845 +       if(tempsize)
846 +         s->fpin = fmemopen(temp, tempsize, "r");
847 +       else /* fmemopen cannot handle zero-length buffers */
848 +         s->fpin = safe_fopen ("/dev/null", "r");
849 +       if(s->fpin == NULL) {
850 +        mutt_perror("failed to re-open memstream!");
851 +        return (-1);
852 +       }
853 + #else
854         s->fpin = fopen (tempfile, "r");
855         unlink (tempfile);
856 ! #endif
857         /* restore the prefix */
858         s->prefix = savePrefix;
859       }
860 ***************
861 *** 1680,1685 ****
862 --- 1704,1713 ----
863   
864         /* restore the original source stream */
865         safe_fclose (&s->fpin);
866 + #ifdef HAVE_FMEMOPEN
867 +       if(tempsize)
868 +           FREE(&temp);
869 + #endif
870         s->fpin = fp;
871       }
872     }
873 *** mutt-1.5.24-orig/init.h     2015-08-30 12:06:38.000000000 -0500
874 --- mutt-1.5.24/init.h  2015-09-16 23:18:13.000000000 -0500
875 ***************
876 *** 2016,2021 ****
877 --- 2016,2069 ----
878     ** not used.
879     ** (PGP only)
880     */
881 +   {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, UL "|"},
882 +   /*
883 +   ** .pp
884 +   ** This specifies the delimiter between the sidebar (if visible) and 
885 +   ** other screens.
886 +   */
887 +   {"sidebar_indentstr", DT_STR, R_BOTH, UL &SidebarIndentStr, UL " "},
888 +   /*
889 +   ** .pp
890 +   ** This specifies the string that is used to indent items
891 +   ** with sidebar_folderindent= yes
892 +   */
893 +   { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
894 +   /*
895 +   ** .pp
896 +   ** This specifies whether or not to show sidebar (left-side list of folders).
897 +   */
898 +   { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
899 +   /*
900 +   ** .pp
901 +   ** This specifies whether or not to sort the sidebar alphabetically.
902 +   */
903 +   { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
904 +   /*
905 +   ** .pp
906 +   ** The width of the sidebar.
907 +   */
908 +   { "sidebar_shortpath", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 0 },
909 +   /*
910 +   ** .pp
911 +   ** Should the sidebar shorten the path showed.
912 +   */
913 +   {"sidebar_format", DT_STR, R_NONE, UL &SidebarFormat, UL "%B%?F? [%F]?%* %?N?%N/?%4S"},
914 +   /*
915 +   ** .pp
916 +   ** Format string for the sidebar. The sequences `%N', `%F' and `%S'
917 +   ** will be replaced by the number of new or flagged messages or the total
918 +   ** size of them mailbox. `%B' will be replaced with the name of the mailbox.
919 +   ** The `%!' sequence will be expanded to `!' if there is one flagged message;
920 +   ** to `!!' if there are two flagged messages; and to `n!' for n flagged
921 +   ** messages, n>2.
922 +   */
923 +   { "sidebar_folderindent", DT_BOOL, R_BOTH, OPTSIDEBARFOLDERINDENT, 0 },
924 +   /*
925 +   ** .pp
926 +   ** Should folders be indented in the sidebar.
927 +   */
928
929     { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
930     /*
931     ** .pp
932 *** mutt-1.5.24-orig/mailbox.h  2015-08-30 12:06:38.000000000 -0500
933 --- mutt-1.5.24/mailbox.h       2015-09-16 23:18:13.000000000 -0500
934 ***************
935 *** 27,32 ****
936 --- 27,33 ----
937   #define M_NEWFOLDER   (1<<4) /* create a new folder - same as M_APPEND, but uses
938                                 * safe_fopen() for mbox-style folders.
939                                 */
940 + #define M_PEEK                (1<<5) /* revert atime back after taking a look (if applicable) */
941   
942   /* mx_open_new_message() */
943   #define M_ADD_FROM    (1<<0)  /* add a From_ line */
944 *** mutt-1.5.24-orig/main.c     2015-08-30 12:06:38.000000000 -0500
945 --- mutt-1.5.24/main.c  2015-09-16 23:18:13.000000000 -0500
946 ***************
947 *** 50,55 ****
948 --- 50,56 ----
949   #include <unistd.h>
950   #include <errno.h>
951   #include <sys/stat.h>
952 + #include <limits.h>
953   #include <sys/utsname.h>
954   
955   #ifdef HAVE_GETOPT_H
956 ***************
957 *** 555,561 ****
958   
959   int main (int argc, char **argv)
960   {
961 !   char folder[_POSIX_PATH_MAX] = "";
962     char *subject = NULL;
963     char *includeFile = NULL;
964     char *draftFile = NULL;
965 --- 556,562 ----
966   
967   int main (int argc, char **argv)
968   {
969 !   char folder[PATH_MAX] = "";
970     char *subject = NULL;
971     char *includeFile = NULL;
972     char *draftFile = NULL;
973 ***************
974 *** 1036,1041 ****
975 --- 1037,1049 ----
976         strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
977       mutt_expand_path (folder, sizeof (folder));
978   
979 +     {
980 +       char tmpfolder[PATH_MAX];
981 +       strfcpy (tmpfolder, folder, sizeof (tmpfolder));
982 +       if(!realpath(tmpfolder, folder))
983 +           strfcpy (folder, tmpfolder, sizeof (tmpfolder));
984 +     }
985
986       mutt_str_replace (&CurrentFolder, folder);
987       mutt_str_replace (&LastFolder, folder);
988   
989 ***************
990 *** 1058,1063 ****
991 --- 1066,1072 ----
992       if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL))
993          || !explicit_folder)
994       {
995 +       set_curbuffy(folder);
996         mutt_index_menu ();
997         if (Context)
998         FREE (&Context);
999 *** mutt-1.5.24-orig/Makefile.am        2015-08-30 12:06:38.000000000 -0500
1000 --- mutt-1.5.24/Makefile.am     2015-09-16 23:18:13.000000000 -0500
1001 ***************
1002 *** 33,38 ****
1003 --- 33,39 ----
1004         rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \
1005         score.c send.c sendlib.c signal.c signature.c sort.c \
1006         status.c system.c thread.c charset.c history.c lib.c \
1007 +       sidebar.c \
1008         muttlib.c editmsg.c mbyte.c \
1009         url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1010   
1011 *** mutt-1.5.24-orig/mbox.c     2015-08-30 12:06:38.000000000 -0500
1012 --- mutt-1.5.24/mbox.c  2015-09-16 23:18:13.000000000 -0500
1013 ***************
1014 *** 100,105 ****
1015 --- 100,106 ----
1016       mutt_perror (ctx->path);
1017       return (-1);
1018     }
1019 +   ctx->atime = sb.st_atime;
1020     ctx->mtime = sb.st_mtime;
1021     ctx->size = sb.st_size;
1022   
1023 ***************
1024 *** 251,256 ****
1025 --- 252,258 ----
1026   
1027     ctx->size = sb.st_size;
1028     ctx->mtime = sb.st_mtime;
1029 +   ctx->atime = sb.st_atime;
1030   
1031   #ifdef NFS_ATTRIBUTE_HACK
1032     if (sb.st_mtime > sb.st_atime)
1033 *** mutt-1.5.24-orig/menu.c     2015-08-30 12:06:38.000000000 -0500
1034 --- mutt-1.5.24/menu.c  2015-09-16 23:18:13.000000000 -0500
1035 ***************
1036 *** 24,29 ****
1037 --- 24,30 ----
1038   #include "mutt_curses.h"
1039   #include "mutt_menu.h"
1040   #include "mbyte.h"
1041 + #include "sidebar.h"
1042   
1043   extern size_t UngetCount;
1044   
1045 ***************
1046 *** 186,192 ****
1047   {
1048     char *scratch = safe_strdup (s);
1049     int shift = option (OPTARROWCURSOR) ? 3 : 0;
1050 !   int cols = COLS - shift;
1051   
1052     mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1053     s[n - 1] = 0;
1054 --- 187,193 ----
1055   {
1056     char *scratch = safe_strdup (s);
1057     int shift = option (OPTARROWCURSOR) ? 3 : 0;
1058 !   int cols = COLS - shift - SidebarWidth;
1059   
1060     mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1061     s[n - 1] = 0;
1062 ***************
1063 *** 239,244 ****
1064 --- 240,246 ----
1065     int do_color;
1066     int attr;
1067   
1068 +   draw_sidebar(1);
1069     for (i = menu->top; i < menu->top + menu->pagelen; i++)
1070     {
1071       if (i < menu->max)
1072 ***************
1073 *** 249,255 ****
1074         menu_pad_string (buf, sizeof (buf));
1075   
1076         ATTRSET(attr);
1077 !       move(i - menu->top + menu->offset, 0);
1078         do_color = 1;
1079   
1080         if (i == menu->current)
1081 --- 251,257 ----
1082         menu_pad_string (buf, sizeof (buf));
1083   
1084         ATTRSET(attr);
1085 !       move(i - menu->top + menu->offset, SidebarWidth);
1086         do_color = 1;
1087   
1088         if (i == menu->current)
1089 ***************
1090 *** 272,278 ****
1091       else
1092       {
1093         NORMAL_COLOR;
1094 !       CLEARLINE(i - menu->top + menu->offset);
1095       }
1096     }
1097     NORMAL_COLOR;
1098 --- 274,280 ----
1099       else
1100       {
1101         NORMAL_COLOR;
1102 !       CLEARLINE_WIN (i - menu->top + menu->offset);
1103       }
1104     }
1105     NORMAL_COLOR;
1106 ***************
1107 *** 289,295 ****
1108       return;
1109     }
1110     
1111 !   move (menu->oldcurrent + menu->offset - menu->top, 0);
1112     ATTRSET(menu->color (menu->oldcurrent));
1113   
1114     if (option (OPTARROWCURSOR))
1115 --- 291,297 ----
1116       return;
1117     }
1118     
1119 !   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
1120     ATTRSET(menu->color (menu->oldcurrent));
1121   
1122     if (option (OPTARROWCURSOR))
1123 ***************
1124 *** 301,313 ****
1125       {
1126         menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1127         menu_pad_string (buf, sizeof (buf));
1128 !       move (menu->oldcurrent + menu->offset - menu->top, 3);
1129         print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1130       }
1131   
1132       /* now draw it in the new location */
1133       SETCOLOR(MT_COLOR_INDICATOR);
1134 !     mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
1135     }
1136     else
1137     {
1138 --- 303,315 ----
1139       {
1140         menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1141         menu_pad_string (buf, sizeof (buf));
1142 !       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
1143         print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1144       }
1145   
1146       /* now draw it in the new location */
1147       SETCOLOR(MT_COLOR_INDICATOR);
1148 !     mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->");
1149     }
1150     else
1151     {
1152 ***************
1153 *** 320,326 ****
1154       menu_make_entry (buf, sizeof (buf), menu, menu->current);
1155       menu_pad_string (buf, sizeof (buf));
1156       SETCOLOR(MT_COLOR_INDICATOR);
1157 !     move(menu->current - menu->top + menu->offset, 0);
1158       print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1159     }
1160     menu->redraw &= REDRAW_STATUS;
1161 --- 322,328 ----
1162       menu_make_entry (buf, sizeof (buf), menu, menu->current);
1163       menu_pad_string (buf, sizeof (buf));
1164       SETCOLOR(MT_COLOR_INDICATOR);
1165 !     move(menu->current - menu->top + menu->offset, SidebarWidth);
1166       print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1167     }
1168     menu->redraw &= REDRAW_STATUS;
1169 ***************
1170 *** 332,338 ****
1171     char buf[LONG_STRING];
1172     int attr = menu->color (menu->current);
1173     
1174 !   move (menu->current + menu->offset - menu->top, 0);
1175     menu_make_entry (buf, sizeof (buf), menu, menu->current);
1176     menu_pad_string (buf, sizeof (buf));
1177   
1178 --- 334,340 ----
1179     char buf[LONG_STRING];
1180     int attr = menu->color (menu->current);
1181     
1182 !   move (menu->current + menu->offset - menu->top, SidebarWidth);
1183     menu_make_entry (buf, sizeof (buf), menu, menu->current);
1184     menu_pad_string (buf, sizeof (buf));
1185   
1186 ***************
1187 *** 872,878 ****
1188       
1189       
1190       if (option (OPTARROWCURSOR))
1191 !       move (menu->current - menu->top + menu->offset, 2);
1192       else if (option (OPTBRAILLEFRIENDLY))
1193         move (menu->current - menu->top + menu->offset, 0);
1194       else
1195 --- 874,880 ----
1196       
1197       
1198       if (option (OPTARROWCURSOR))
1199 !       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
1200       else if (option (OPTBRAILLEFRIENDLY))
1201         move (menu->current - menu->top + menu->offset, 0);
1202       else
1203 *** mutt-1.5.24-orig/mh.c       2015-08-30 12:06:38.000000000 -0500
1204 --- mutt-1.5.24/mh.c    2015-09-16 23:18:13.000000000 -0500
1205 ***************
1206 *** 295,300 ****
1207 --- 295,326 ----
1208     mhs_free_sequences (&mhs);
1209   }
1210   
1211 + void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged, time_t *sb_last_checked)
1212 + {
1213 +   int i;
1214 +   struct mh_sequences mhs;
1215 +   memset (&mhs, 0, sizeof (mhs));
1216
1217 +   if(!option(OPTSIDEBAR))
1218 +       return;
1219
1220 +   if (mh_read_sequences (&mhs, path) < 0)
1221 +     return;
1222
1223 +   msgcount = 0;
1224 +   msg_unread = 0;
1225 +   msg_flagged = 0;
1226 +   for (i = 0; i <= mhs.max; i++)
1227 +     msgcount++;
1228 +     if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
1229 +       msg_unread++;
1230 +     }
1231 +     if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
1232 +       msg_flagged++;
1233 +   mhs_free_sequences (&mhs);
1234 +   *sb_last_checked = time(NULL);
1235 + }
1236
1237   static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
1238   {
1239     int fd;
1240 *** mutt-1.5.24-orig/mutt_curses.h      2015-08-30 12:06:38.000000000 -0500
1241 --- mutt-1.5.24/mutt_curses.h   2015-09-16 23:18:13.000000000 -0500
1242 ***************
1243 *** 64,69 ****
1244 --- 64,70 ----
1245   #undef lines
1246   #endif /* lines */
1247   
1248 + #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
1249   #define CLEARLINE(x) move(x,0), clrtoeol()
1250   #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
1251   #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
1252 ***************
1253 *** 121,126 ****
1254 --- 122,129 ----
1255     MT_COLOR_UNDERLINE,
1256     MT_COLOR_INDEX,
1257     MT_COLOR_PROMPT,
1258 +   MT_COLOR_NEW,
1259 +   MT_COLOR_FLAGGED,
1260     MT_COLOR_MAX
1261   };
1262   
1263 *** mutt-1.5.24-orig/mutt_menu.h        2015-08-30 12:06:38.000000000 -0500
1264 --- mutt-1.5.24/mutt_menu.h     2015-09-16 23:18:13.000000000 -0500
1265 ***************
1266 *** 34,39 ****
1267 --- 34,40 ----
1268   #define REDRAW_FULL           (1<<5)
1269   #define REDRAW_BODY           (1<<6)
1270   #define REDRAW_SIGWINCH               (1<<7)
1271 + #define REDRAW_SIDEBAR                (1<<8)
1272   
1273   #define M_MODEFMT "-- Mutt: %s"
1274   
1275 *** mutt-1.5.24-orig/mutt.h     2015-08-30 12:06:38.000000000 -0500
1276 --- mutt-1.5.24/mutt.h  2015-09-16 23:18:13.000000000 -0500
1277 ***************
1278 *** 423,428 ****
1279 --- 423,432 ----
1280     OPTSAVEEMPTY,
1281     OPTSAVENAME,
1282     OPTSCORE,
1283 +   OPTSIDEBAR,
1284 +   OPTSIDEBARSHORTPATH,
1285 +   OPTSIDEBARSORT,
1286 +   OPTSIDEBARFOLDERINDENT,
1287     OPTSIGDASHES,
1288     OPTSIGONTOP,
1289     OPTSORTRE,
1290 ***************
1291 *** 866,871 ****
1292 --- 870,876 ----
1293   {
1294     char *path;
1295     FILE *fp;
1296 +   time_t atime;
1297     time_t mtime;
1298     off_t size;
1299     off_t vsize;
1300 ***************
1301 *** 900,905 ****
1302 --- 905,911 ----
1303     unsigned int quiet : 1;     /* inhibit status messages? */
1304     unsigned int collapsed : 1;   /* are all threads collapsed? */
1305     unsigned int closing : 1;   /* mailbox is being closed */
1306 +   unsigned int peekonly : 1;  /* just taking a glance, revert atime */
1307   
1308     /* driver hooks */
1309     void *data;                 /* driver specific data */
1310 *** mutt-1.5.24-orig/muttlib.c  2015-08-30 12:06:38.000000000 -0500
1311 --- mutt-1.5.24/muttlib.c       2015-09-16 23:18:13.000000000 -0500
1312 ***************
1313 *** 1276,1281 ****
1314 --- 1276,1283 ----
1315           pl = pw = 1;
1316   
1317         /* see if there's room to add content, else ignore */
1318 +         if ( DrawFullLine )
1319 +         {
1320         if ((col < COLS && wlen < destlen) || soft)
1321         {
1322           int pad;
1323 ***************
1324 *** 1319,1324 ****
1325 --- 1321,1372 ----
1326           col += wid;
1327           src += pl;
1328         }
1329 +         }
1330 +         else
1331 +         {
1332 +       if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
1333 +         {
1334 +         int pad;
1335
1336 +         /* get contents after padding */
1337 +         mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
1338 +         len = mutt_strlen (buf);
1339 +         wid = mutt_strwidth (buf);
1340
1341 +         /* try to consume as many columns as we can, if we don't have
1342 +          * memory for that, use as much memory as possible */
1343 +         pad = (COLS - SidebarWidth - col - wid) / pw;
1344 +         if (pad > 0 && wlen + (pad * pl) + len > destlen)
1345 +           pad = ((signed)(destlen - wlen - len)) / pl;
1346 +         if (pad > 0)
1347 +         {
1348 +           while (pad--)
1349 +           {
1350 +             memcpy (wptr, src, pl);
1351 +             wptr += pl;
1352 +             wlen += pl;
1353 +             col += pw;
1354 +           }
1355 +         }
1356 +         else if (soft && pad < 0)
1357 +         {
1358 +           /* \0-terminate dest for length computation in mutt_wstr_trunc() */
1359 +           *wptr = 0;
1360 +           /* make sure right part is at most as wide as display */
1361 +           len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
1362 +           /* truncate left so that right part fits completely in */
1363 +           wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
1364 +           wptr = dest + wlen;
1365 +         }
1366 +         if (len + wlen > destlen)
1367 +           len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
1368 +         memcpy (wptr, buf, len);
1369 +         wptr += len;
1370 +         wlen += len;
1371 +         col += wid;
1372 +         src += pl;
1373 +       }
1374 +         }
1375         break; /* skip rest of input */
1376         }
1377         else if (ch == '|')
1378 *** mutt-1.5.24-orig/mx.c       2015-08-30 12:06:38.000000000 -0500
1379 --- mutt-1.5.24/mx.c    2015-09-16 23:18:13.000000000 -0500
1380 ***************
1381 *** 580,585 ****
1382 --- 580,586 ----
1383    *            M_APPEND        open mailbox for appending
1384    *            M_READONLY      open mailbox in read-only mode
1385    *            M_QUIET         only print error messages
1386 +  *            M_PEEK          revert atime where applicable
1387    *    ctx     if non-null, context struct to use
1388    */
1389   CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
1390 ***************
1391 *** 602,607 ****
1392 --- 603,610 ----
1393       ctx->quiet = 1;
1394     if (flags & M_READONLY)
1395       ctx->readonly = 1;
1396 +   if (flags & M_PEEK)
1397 +     ctx->peekonly = 1;
1398   
1399     if (flags & (M_APPEND|M_NEWFOLDER))
1400     {
1401 ***************
1402 *** 701,713 ****
1403   void mx_fastclose_mailbox (CONTEXT *ctx)
1404   {
1405     int i;
1406   
1407     if(!ctx) 
1408       return;
1409   
1410     /* never announce that a mailbox we've just left has new mail. #3290
1411      * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
1412 !   mutt_buffy_setnotified(ctx->path);
1413   
1414     if (ctx->mx_close)
1415       ctx->mx_close (ctx);
1416 --- 704,729 ----
1417   void mx_fastclose_mailbox (CONTEXT *ctx)
1418   {
1419     int i;
1420 + #ifndef BUFFY_SIZE
1421 +   struct utimbuf ut;
1422 + #endif
1423   
1424     if(!ctx) 
1425       return;
1426 + #ifndef BUFFY_SIZE
1427 +   /* fix up the times so buffy won't get confused */
1428 +   if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
1429 +   {
1430 +     ut.actime = ctx->atime;
1431 +     ut.modtime = ctx->mtime;
1432 +     utime (ctx->path, &ut); 
1433 +   }
1434 + #endif
1435   
1436     /* never announce that a mailbox we've just left has new mail. #3290
1437      * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
1438 !   if(!ctx->peekonly)
1439 !     mutt_buffy_setnotified(ctx->path);
1440   
1441     if (ctx->mx_close)
1442       ctx->mx_close (ctx);
1443 ***************
1444 *** 719,724 ****
1445 --- 735,742 ----
1446     mutt_clear_threads (ctx);
1447     for (i = 0; i < ctx->msgcount; i++)
1448       mutt_free_header (&ctx->hdrs[i]);
1449 +   ctx->msgcount -= ctx->deleted;
1450 +   set_buffystats(ctx);
1451     FREE (&ctx->hdrs);
1452     FREE (&ctx->v2r);
1453     FREE (&ctx->path);
1454 ***************
1455 *** 812,817 ****
1456 --- 830,839 ----
1457       if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 
1458           && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
1459         read_msgs++;
1460 +     if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read)
1461 +       ctx->unread--;
1462 +     if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged)
1463 +       ctx->flagged--;
1464     }
1465   
1466     if (read_msgs && quadoption (OPT_MOVE) != M_NO)
1467 *** mutt-1.5.24-orig/mx.h       2015-08-30 12:06:38.000000000 -0500
1468 --- mutt-1.5.24/mx.h    2015-09-16 23:18:13.000000000 -0500
1469 ***************
1470 *** 57,62 ****
1471 --- 57,63 ----
1472   int mh_read_dir (CONTEXT *, const char *);
1473   int mh_sync_mailbox (CONTEXT *, int *);
1474   int mh_check_mailbox (CONTEXT *, int *);
1475 + void mh_buffy_update (const char *, int *, int *, int *, time_t *);
1476   int mh_check_empty (const char *);
1477   
1478   int maildir_read_dir (CONTEXT *);
1479 *** mutt-1.5.24-orig/OPS        2015-08-30 12:06:38.000000000 -0500
1480 --- mutt-1.5.24/OPS     2015-09-16 23:18:13.000000000 -0500
1481 ***************
1482 *** 179,181 ****
1483 --- 179,186 ----
1484   OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
1485   OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
1486   OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
1487 + OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
1488 + OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
1489 + OP_SIDEBAR_NEXT "go down to next mailbox"
1490 + OP_SIDEBAR_PREV "go to previous mailbox"
1491 + OP_SIDEBAR_OPEN "open hilighted mailbox"
1492 *** mutt-1.5.24-orig/pager.c    2015-08-30 12:06:38.000000000 -0500
1493 --- mutt-1.5.24/pager.c 2015-09-16 23:18:13.000000000 -0500
1494 ***************
1495 *** 29,34 ****
1496 --- 29,35 ----
1497   #include "pager.h"
1498   #include "attach.h"
1499   #include "mbyte.h"
1500 + #include "sidebar.h"
1501   
1502   #include "mutt_crypt.h"
1503   
1504 ***************
1505 *** 1095,1100 ****
1506 --- 1096,1102 ----
1507     wchar_t wc;
1508     mbstate_t mbstate;
1509     int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
1510 +   wrap_cols -= SidebarWidth;
1511   
1512     if (check_attachment_marker ((char *)buf) == 0)
1513       wrap_cols = COLS;
1514 ***************
1515 *** 1572,1577 ****
1516 --- 1574,1580 ----
1517   
1518     int bodyoffset = 1;                 /* offset of first line of real text */
1519     int statusoffset = 0;               /* offset for the status bar */
1520 +   int statuswidth;
1521     int helpoffset = LINES - 2;         /* offset for the help bar. */
1522     int bodylen = LINES - 2 - bodyoffset; /* length of displayable area */
1523   
1524 ***************
1525 *** 1746,1752 ****
1526       if ((redraw & REDRAW_BODY) || topline != oldtopline)
1527       {
1528         do {
1529 !       move (bodyoffset, 0);
1530         curline = oldtopline = topline;
1531         lines = 0;
1532         force_redraw = 0;
1533 --- 1749,1755 ----
1534       if ((redraw & REDRAW_BODY) || topline != oldtopline)
1535       {
1536         do {
1537 !       move (bodyoffset, SidebarWidth);
1538         curline = oldtopline = topline;
1539         lines = 0;
1540         force_redraw = 0;
1541 ***************
1542 *** 1759,1764 ****
1543 --- 1762,1768 ----
1544                             &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
1545             lines++;
1546           curline++;
1547 +         move(lines + bodyoffset, SidebarWidth);
1548         }
1549         last_offset = lineInfo[curline].offset;
1550         } while (force_redraw);
1551 ***************
1552 *** 1771,1776 ****
1553 --- 1775,1781 ----
1554           addch ('~');
1555         addch ('\n');
1556         lines++;
1557 +       move(lines + bodyoffset, SidebarWidth);
1558         }
1559         NORMAL_COLOR;
1560   
1561 ***************
1562 *** 1788,1816 ****
1563         hfi.ctx = Context;
1564         hfi.pager_progress = pager_progress_str;
1565   
1566         if (last_pos < sb.st_size - 1)
1567         snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1568         else
1569         strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1570   
1571         /* print out the pager status bar */
1572 !       move (statusoffset, 0);
1573         SETCOLOR (MT_COLOR_STATUS);
1574   
1575         if (IsHeader (extra) || IsMsgAttach (extra))
1576         {
1577 !       size_t l1 = COLS * MB_LEN_MAX;
1578         size_t l2 = sizeof (buffer);
1579         hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1580         mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1581 !       mutt_paddstr (COLS, buffer);
1582         }
1583         else
1584         {
1585         char bn[STRING];
1586         snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1587 !       mutt_paddstr (COLS, bn);
1588         }
1589         NORMAL_COLOR;
1590         if (option(OPTTSENABLED) && TSSupported)
1591         {
1592 --- 1793,1831 ----
1593         hfi.ctx = Context;
1594         hfi.pager_progress = pager_progress_str;
1595   
1596 +       statuswidth = COLS - (option(OPTSTATUSONTOP) && PagerIndexLines > 0 ? SidebarWidth : 0);
1597
1598         if (last_pos < sb.st_size - 1)
1599         snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1600         else
1601         strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1602   
1603         /* print out the pager status bar */
1604 !       move (statusoffset, SidebarWidth);
1605         SETCOLOR (MT_COLOR_STATUS);
1606 +       if(option(OPTSTATUSONTOP) && PagerIndexLines > 0) {
1607 +           CLEARLINE_WIN (statusoffset);
1608 +       } else {
1609 +           CLEARLINE (statusoffset);
1610 +           DrawFullLine = 1; /* for mutt_make_string_info */
1611 +       }
1612   
1613         if (IsHeader (extra) || IsMsgAttach (extra))
1614         {
1615 !       size_t l1 = statuswidth * MB_LEN_MAX;
1616         size_t l2 = sizeof (buffer);
1617         hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1618         mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1619 !       mutt_paddstr (statuswidth, buffer);
1620         }
1621         else
1622         {
1623         char bn[STRING];
1624         snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1625 !       mutt_paddstr (statuswidth, bn);
1626         }
1627 +       if(!option(OPTSTATUSONTOP) || PagerIndexLines == 0)
1628 +           DrawFullLine = 0; /* reset */
1629         NORMAL_COLOR;
1630         if (option(OPTTSENABLED) && TSSupported)
1631         {
1632 ***************
1633 *** 1826,1841 ****
1634         /* redraw the pager_index indicator, because the
1635          * flags for this message might have changed. */
1636         menu_redraw_current (index);
1637   
1638         /* print out the index status bar */
1639         menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
1640    
1641 !       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
1642         SETCOLOR (MT_COLOR_STATUS);
1643 !       mutt_paddstr (COLS, buffer);
1644         NORMAL_COLOR;
1645       }
1646   
1647       redraw = 0;
1648   
1649       if (option(OPTBRAILLEFRIENDLY)) {
1650 --- 1841,1862 ----
1651         /* redraw the pager_index indicator, because the
1652          * flags for this message might have changed. */
1653         menu_redraw_current (index);
1654 +       draw_sidebar(MENU_PAGER);
1655   
1656         /* print out the index status bar */
1657         menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
1658    
1659 !       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
1660 !           (option(OPTSTATUSONTOP) ? 0: SidebarWidth));
1661         SETCOLOR (MT_COLOR_STATUS);
1662 !       mutt_paddstr (COLS - (option(OPTSTATUSONTOP) ? 0 : SidebarWidth), buffer);
1663         NORMAL_COLOR;
1664       }
1665   
1666 +     /* if we're not using the index, update every time */
1667 +     if ( index == 0 )
1668 +       draw_sidebar(MENU_PAGER);
1669
1670       redraw = 0;
1671   
1672       if (option(OPTBRAILLEFRIENDLY)) {
1673 ***************
1674 *** 2770,2775 ****
1675 --- 2791,2803 ----
1676         mutt_what_key ();
1677         break;
1678   
1679 +       case OP_SIDEBAR_SCROLL_UP:
1680 +       case OP_SIDEBAR_SCROLL_DOWN:
1681 +       case OP_SIDEBAR_NEXT:
1682 +       case OP_SIDEBAR_PREV:
1683 +       scroll_sidebar(ch, MENU_PAGER);
1684 +       break;
1685
1686         default:
1687         ch = -1;
1688         break;
1689 *** mutt-1.5.24-orig/pattern.c  2015-08-30 12:06:38.000000000 -0500
1690 --- mutt-1.5.24/pattern.c       2015-09-16 23:18:13.000000000 -0500
1691 ***************
1692 *** 154,159 ****
1693 --- 154,163 ----
1694     HEADER *h = ctx->hdrs[msgno];
1695     char *buf;
1696     size_t blen;
1697 + #ifdef HAVE_FMEMOPEN
1698 +   char *temp;
1699 +   size_t tempsize;
1700 + #endif
1701   
1702     if ((msg = mx_open_message (ctx, msgno)) != NULL)
1703     {
1704 ***************
1705 *** 163,174 ****
1706 --- 167,186 ----
1707         memset (&s, 0, sizeof (s));
1708         s.fpin = msg->fp;
1709         s.flags = M_CHARCONV;
1710 + #ifdef HAVE_FMEMOPEN
1711 +       if((s.fpout = open_memstream(&temp, &tempsize)) == NULL)
1712 +       {
1713 +       mutt_perror ("Error opening memstream");
1714 +       return (0);
1715 +       }
1716 + #else
1717         mutt_mktemp (tempfile, sizeof (tempfile));
1718         if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL)
1719         {
1720         mutt_perror (tempfile);
1721         return (0);
1722         }
1723 + #endif
1724   
1725         if (pat->op != M_BODY)
1726         mutt_copy_header (msg->fp, h, s.fpout, CH_FROM | CH_DECODE, NULL);
1727 ***************
1728 *** 184,190 ****
1729 --- 196,206 ----
1730           if (s.fpout)
1731           {
1732             safe_fclose (&s.fpout);
1733 + #ifdef HAVE_FMEMOPEN
1734 +             FREE(&temp);
1735 + #else
1736             unlink (tempfile);
1737 + #endif
1738           }
1739           return (0);
1740         }
1741 ***************
1742 *** 193,203 ****
1743 --- 209,236 ----
1744         mutt_body_handler (h->content, &s);
1745         }
1746   
1747 + #ifdef HAVE_FMEMOPEN
1748 +       fclose(s.fpout);
1749 +       lng = tempsize;
1750
1751 +       if(tempsize) {
1752 +           if ((fp = fmemopen(temp, tempsize, "r")) == NULL) {
1753 +             mutt_perror ("Error re-opening memstream");
1754 +             return (0);
1755 +           }
1756 +       } else { /* fmemopen cannot handle empty buffers */
1757 +           if ((fp = safe_fopen ("/dev/null", "r")) == NULL) {
1758 +             mutt_perror ("Error opening /dev/null");
1759 +             return (0);
1760 +           }
1761 +       }
1762 + #else
1763         fp = s.fpout;
1764         fflush (fp);
1765         fseek (fp, 0, 0);
1766         fstat (fileno (fp), &st);
1767         lng = (long) st.st_size;
1768 + #endif
1769       }
1770       else
1771       {
1772 ***************
1773 *** 244,250 ****
1774 --- 277,288 ----
1775       if (option (OPTTHOROUGHSRC))
1776       {
1777         safe_fclose (&fp);
1778 + #ifdef HAVE_FMEMOPEN
1779 +       if(tempsize)
1780 +           FREE (&temp);
1781 + #else
1782         unlink (tempfile);
1783 + #endif
1784       }
1785     }
1786   
1787 *** mutt-1.5.24-orig/PATCHES    2015-08-30 12:06:38.000000000 -0500
1788 --- mutt-1.5.24/PATCHES 2015-11-11 09:39:02.000000000 -0600
1789 ***************
1790 *** 0 ****
1791 --- 1 ----
1792 + patch-1.5.24.sidebar.20151111.txt
1793 *** mutt-1.5.24-orig/protos.h   2015-08-30 12:06:38.000000000 -0500
1794 --- mutt-1.5.24/protos.h        2015-09-16 23:18:13.000000000 -0500
1795 ***************
1796 *** 36,41 ****
1797 --- 36,48 ----
1798     const char *pager_progress;
1799   };
1800   
1801 + struct sidebar_entry {
1802 +     char                box[SHORT_STRING];
1803 +     unsigned int        size;
1804 +     unsigned int        new;
1805 +     unsigned int        flagged;
1806 + };
1807
1808   void mutt_make_string_info (char *, size_t, const char *, struct hdr_format_info *, format_flag);
1809   
1810   int mutt_extract_token (BUFFER *, BUFFER *, int);
1811 *** mutt-1.5.24-orig/sidebar.c  1969-12-31 18:00:00.000000000 -0600
1812 --- mutt-1.5.24/sidebar.c       2015-11-11 09:38:45.000000000 -0600
1813 ***************
1814 *** 0 ****
1815 --- 1,410 ----
1816 + /*
1817 +  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1818 +  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1819 +  * 
1820 +  *     This program is free software; you can redistribute it and/or modify
1821 +  *     it under the terms of the GNU General Public License as published by
1822 +  *     the Free Software Foundation; either version 2 of the License, or
1823 +  *     (at your option) any later version.
1824 +  * 
1825 +  *     This program is distributed in the hope that it will be useful,
1826 +  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1827 +  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1828 +  *     GNU General Public License for more details.
1829 +  * 
1830 +  *     You should have received a copy of the GNU General Public License
1831 +  *     along with this program; if not, write to the Free Software
1832 +  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1833 +  */ 
1834
1835
1836 + #if HAVE_CONFIG_H
1837 + # include "config.h"
1838 + #endif
1839
1840 + #include "mutt.h"
1841 + #include "mutt_menu.h"
1842 + #include "mutt_curses.h"
1843 + #include "sidebar.h"
1844 + #include "buffy.h"
1845 + #include <libgen.h>
1846 + #include "keymap.h"
1847 + #include <stdbool.h>
1848
1849 + /*BUFFY *CurBuffy = 0;*/
1850 + static BUFFY *TopBuffy = 0;
1851 + static BUFFY *BottomBuffy = 0;
1852 + static int known_lines = 0;
1853
1854 + void calc_boundaries() {
1855
1856 +     BUFFY *tmp = Incoming;
1857
1858 +       int count = LINES - 2 - (option(OPTHELP) ? 1 : 0);
1859
1860 +       if ( known_lines != LINES ) {
1861 +               TopBuffy = BottomBuffy = 0;
1862 +               known_lines = LINES;
1863 +       }
1864 +       for ( ; tmp->next != 0; tmp = tmp->next )
1865 +               tmp->next->prev = tmp;
1866
1867 +       if ( TopBuffy == 0 && BottomBuffy == 0 )
1868 +               TopBuffy = Incoming;
1869 +       if ( BottomBuffy == 0 ) {
1870 +               BottomBuffy = TopBuffy;
1871 +               while ( --count && BottomBuffy->next )
1872 +                       BottomBuffy = BottomBuffy->next;
1873 +       }
1874 +       else if ( TopBuffy == CurBuffy->next ) {
1875 +               BottomBuffy = CurBuffy;
1876 +               tmp = BottomBuffy;
1877 +               while ( --count && tmp->prev)
1878 +                       tmp = tmp->prev;
1879 +               TopBuffy = tmp;
1880 +       }
1881 +       else if ( BottomBuffy == CurBuffy->prev ) {
1882 +               TopBuffy = CurBuffy;
1883 +               tmp = TopBuffy;
1884 +               while ( --count && tmp->next )
1885 +                       tmp = tmp->next;
1886 +               BottomBuffy = tmp;
1887 +       }
1888 + }
1889
1890 + static const char *
1891 + sidebar_format_str (char *dest,
1892 +                       size_t destlen,
1893 +                       size_t col,
1894 +                       char op,
1895 +                       const char *src,
1896 +                       const char *prefix,
1897 +                       const char *ifstring,
1898 +                       const char *elsestring,
1899 +                       unsigned long data,
1900 +                       format_flag flags)
1901 + {
1902 + /* casting from unsigned long - srsly?! */
1903 + struct sidebar_entry *sbe = (struct sidebar_entry *) data;
1904 + unsigned int optional;
1905 + char fmt[SHORT_STRING], buf[SHORT_STRING];
1906
1907 + optional = flags & M_FORMAT_OPTIONAL;
1908
1909 + switch(op) {
1910 +       case 'F':
1911 +               if(!optional) {
1912 +                       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1913 +                       snprintf (dest, destlen, fmt, sbe->flagged);
1914 +               } else if(sbe->flagged == 0) {
1915 +                       optional = 0;
1916 +               }
1917 +               break;
1918
1919 +       case '!':
1920 +               if(sbe->flagged == 0)
1921 +                       mutt_format_s(dest, destlen, prefix, "");
1922 +               if(sbe->flagged == 1)
1923 +                       mutt_format_s(dest, destlen, prefix, "!");
1924 +               if(sbe->flagged == 2)
1925 +                       mutt_format_s(dest, destlen, prefix, "!!");
1926 +               if(sbe->flagged > 2) {
1927 +                       snprintf (buf, sizeof (buf), "%d!", sbe->flagged);
1928 +                       mutt_format_s(dest, destlen, prefix, buf);
1929 +               }
1930 +               break;
1931
1932 +       case 'S':
1933 +                 if(!optional) {
1934 +                   snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1935 +                   snprintf (dest, destlen, fmt, sbe->size);
1936 +                 } else if (sbe->size == 0) {
1937 +                     optional = 0;
1938 +                 }
1939 +               break;
1940
1941 +       case 'N':
1942 +               if(!optional) {
1943 +                       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1944 +                       snprintf (dest, destlen, fmt, sbe->new);
1945 +               } else if(sbe->new == 0) {
1946 +                       optional = 0;
1947 +               }
1948 +               break;
1949
1950 +       case 'B':
1951 +               mutt_format_s(dest, destlen, prefix, sbe->box);
1952 +               break;
1953 +       }
1954
1955 +       if(optional)
1956 +               mutt_FormatString (dest, destlen, col, ifstring, sidebar_format_str, (unsigned long) sbe, flags);
1957 +       else if (flags & M_FORMAT_OPTIONAL)
1958 +               mutt_FormatString (dest, destlen, col, elsestring, sidebar_format_str, (unsigned long) sbe, flags);
1959
1960 +       return (src);
1961 + }
1962
1963 + char *make_sidebar_entry(char *box, unsigned int size, unsigned int new, unsigned int flagged) {
1964 +     static char *entry = 0;
1965 +     struct sidebar_entry sbe;
1966 +     int SBvisual;
1967
1968 +     SBvisual = SidebarWidth - strlen(SidebarDelim);
1969 +     if (SBvisual < 1)
1970 +         return NULL;
1971
1972 +     sbe.new = new;
1973 +     sbe.flagged = flagged;
1974 +     sbe.size = size;
1975 +     strncpy(sbe.box, box, 31);
1976
1977 +     safe_realloc(&entry, SBvisual + 2);
1978 +     entry[SBvisual + 1] = '\0';
1979
1980 +     mutt_FormatString (entry, SBvisual+1, 0, SidebarFormat, sidebar_format_str, (unsigned long) &sbe, 0);
1981
1982 +     return entry;
1983 + }
1984
1985 + void set_curbuffy(char buf[LONG_STRING])
1986 + {
1987 +   BUFFY* tmp = CurBuffy = Incoming;
1988
1989 +   if (!Incoming)
1990 +     return;
1991
1992 +   while(1) {
1993 +     if(!strcmp(tmp->path, buf) || !strcmp(tmp->realpath, buf)) {
1994 +       CurBuffy = tmp;
1995 +       break;
1996 +     }
1997
1998 +     if(tmp->next)
1999 +       tmp = tmp->next;
2000 +     else
2001 +       break;
2002 +   }
2003 + }
2004
2005 + int draw_sidebar(int menu) {
2006
2007 +       BUFFY *tmp;
2008 + #ifndef USE_SLANG_CURSES
2009 +         attr_t attrs;
2010 + #endif
2011 +         short delim_len = strlen(SidebarDelim);
2012 +         short color_pair;
2013
2014 +         static bool initialized = false;
2015 +         static int prev_show_value;
2016 +         static short saveSidebarWidth;
2017 +         int lines = 0;
2018 +         int SidebarHeight;
2019 +         
2020 +         if(option(OPTSTATUSONTOP) || option(OPTHELP))
2021 +                 lines++; /* either one will occupy the first line */
2022
2023 +         /* initialize first time */
2024 +         if(!initialized) {
2025 +                 prev_show_value = option(OPTSIDEBAR);
2026 +                 saveSidebarWidth = SidebarWidth;
2027 +                 if(!option(OPTSIDEBAR)) SidebarWidth = 0;
2028 +                 initialized = true;
2029 +         }
2030
2031 +         /* save or restore the value SidebarWidth */
2032 +         if(prev_show_value != option(OPTSIDEBAR)) {
2033 +                 if(prev_show_value && !option(OPTSIDEBAR)) {
2034 +                         saveSidebarWidth = SidebarWidth;
2035 +                         SidebarWidth = 0;
2036 +                 } else if(!prev_show_value && option(OPTSIDEBAR)) {
2037 +                         mutt_buffy_check(1); /* we probably have bad or no numbers */
2038 +                         SidebarWidth = saveSidebarWidth;
2039 +                 }
2040 +                 prev_show_value = option(OPTSIDEBAR);
2041 +         }
2042
2043
2044 + /*    if ( SidebarWidth == 0 ) return 0; */
2045 +        if (SidebarWidth > 0 && option (OPTSIDEBAR)
2046 +            && delim_len >= SidebarWidth) {
2047 +          unset_option (OPTSIDEBAR);
2048 +          /* saveSidebarWidth = SidebarWidth; */
2049 +          if (saveSidebarWidth > delim_len) {
2050 +            SidebarWidth = saveSidebarWidth;
2051 +            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
2052 +            sleep (2);
2053 +          } else {
2054 +            SidebarWidth = 0;
2055 +            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
2056 +            sleep (4); /* the advise to set a sane value should be seen long enough */
2057 +          }
2058 +          saveSidebarWidth = 0;
2059 +          return (0);
2060 +        }
2061
2062 +     if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
2063 +       if (SidebarWidth > 0) {
2064 +         saveSidebarWidth = SidebarWidth;
2065 +         SidebarWidth = 0;
2066 +       }
2067 +       unset_option(OPTSIDEBAR);
2068 +       return 0;
2069 +     }
2070
2071 +         /* get attributes for divider */
2072 +       SETCOLOR(MT_COLOR_STATUS);
2073 + #ifndef USE_SLANG_CURSES
2074 +         attr_get(&attrs, &color_pair, 0);
2075 + #else
2076 +         color_pair = attr_get();
2077 + #endif
2078 +       SETCOLOR(MT_COLOR_NORMAL);
2079
2080 +       /* draw the divider */
2081
2082 +       SidebarHeight =  LINES - 1;
2083 +       if(option(OPTHELP) || !option(OPTSTATUSONTOP))
2084 +               SidebarHeight--;
2085
2086 +       for ( ; lines < SidebarHeight; lines++ ) {
2087 +               move(lines, SidebarWidth - delim_len);
2088 +               addstr(NONULL(SidebarDelim));
2089 + #ifndef USE_SLANG_CURSES
2090 +                 mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
2091 + #endif
2092 +       }
2093
2094 +       if ( Incoming == 0 ) return 0;
2095 +         lines = 0;
2096 +         if(option(OPTSTATUSONTOP) || option(OPTHELP))
2097 +                 lines++; /* either one will occupy the first line */
2098
2099 +       if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
2100 +               calc_boundaries(menu);
2101 +       if ( CurBuffy == 0 ) CurBuffy = Incoming;
2102
2103 +       tmp = TopBuffy;
2104
2105 +       SETCOLOR(MT_COLOR_NORMAL);
2106
2107 +       for ( ; tmp && lines < SidebarHeight; tmp = tmp->next ) {
2108 +               if ( tmp == CurBuffy )
2109 +                       SETCOLOR(MT_COLOR_INDICATOR);
2110 +               else if ( tmp->msg_unread > 0 )
2111 +                       SETCOLOR(MT_COLOR_NEW);
2112 +               else if ( tmp->msg_flagged > 0 )
2113 +                       SETCOLOR(MT_COLOR_FLAGGED);
2114 +               else
2115 +                       SETCOLOR(MT_COLOR_NORMAL);
2116
2117 +               move( lines, 0 );
2118 +               if ( Context && Context->path &&
2119 +                         (!strcmp(tmp->path, Context->path)||
2120 +                        !strcmp(tmp->realpath, Context->path)) ) {
2121 +                       tmp->msg_unread = Context->unread;
2122 +                       tmp->msgcount = Context->msgcount;
2123 +                       tmp->msg_flagged = Context->flagged;
2124 +               }
2125 +               /* check whether Maildir is a prefix of the current folder's path */
2126 +               short maildir_is_prefix = 0;
2127 +               if ( (strlen(tmp->path) > strlen(Maildir)) &&
2128 +                       (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
2129 +                       maildir_is_prefix = 1;
2130 +               /* calculate depth of current folder and generate its display name with indented spaces */
2131 +               int sidebar_folder_depth = 0;
2132 +               char *sidebar_folder_name;
2133 +               sidebar_folder_name = option(OPTSIDEBARSHORTPATH) ? mutt_basename(tmp->path) : tmp->path + maildir_is_prefix*(strlen(Maildir) + ((Maildir[strlen(Maildir) - 1] == '/' || Maildir[strlen(Maildir) - 1] == '}') ? 0 : 1));
2134 +               if ( maildir_is_prefix && option(OPTSIDEBARFOLDERINDENT) ) {
2135 +                       char *tmp_folder_name;
2136 +                       int i;
2137 +                       tmp_folder_name = tmp->path + strlen(Maildir) + 1;
2138 +                       for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
2139 +                               if (tmp_folder_name[i] == '/'  || tmp_folder_name[i] == '.') sidebar_folder_depth++;
2140 +                       }   
2141 +                       if (sidebar_folder_depth > 0) {
2142 +                               if (option(OPTSIDEBARSHORTPATH)) {
2143 +                                       tmp_folder_name = strrchr(tmp->path, '.');
2144 +                                       if (tmp_folder_name == NULL)
2145 +                                               tmp_folder_name = mutt_basename(tmp->path);
2146 +                                       else
2147 +                                               tmp_folder_name++;
2148 +                               }
2149 +                               else
2150 +                                       tmp_folder_name = tmp->path + strlen(Maildir) + 1;
2151 +                               sidebar_folder_name = malloc(strlen(tmp_folder_name) + sidebar_folder_depth*strlen(NONULL(SidebarIndentStr)) + 1);
2152 +                               sidebar_folder_name[0]=0;
2153 +                               for (i=0; i < sidebar_folder_depth; i++)
2154 +                                       strncat(sidebar_folder_name, NONULL(SidebarIndentStr), strlen(NONULL(SidebarIndentStr)));
2155 +                               strncat(sidebar_folder_name, tmp_folder_name, strlen(tmp_folder_name));
2156 +                       }
2157 +               }
2158 +               printw( "%.*s", SidebarWidth - delim_len + 1,
2159 +                       make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
2160 +                       tmp->msg_unread, tmp->msg_flagged));
2161 +               if (sidebar_folder_depth > 0)
2162 +                       free(sidebar_folder_name);
2163 +               lines++;
2164 +       }
2165 +       SETCOLOR(MT_COLOR_NORMAL);
2166 +       for ( ; lines < SidebarHeight; lines++ ) {
2167 +               int i = 0;
2168 +               move( lines, 0 );
2169 +               for ( ; i < SidebarWidth - delim_len; i++ )
2170 +                       addch(' ');
2171 +       }
2172 +       return 0;
2173 + }
2174
2175
2176 + void set_buffystats(CONTEXT* Context)
2177 + {
2178 +         BUFFY *tmp = Incoming;
2179 +         while(tmp) {
2180 +                 if(Context && (!strcmp(tmp->path, Context->path) ||
2181 +                                !strcmp(tmp->realpath, Context->path))) {
2182 +                       tmp->msg_unread = Context->unread;
2183 +                       tmp->msgcount = Context->msgcount;
2184 +                       tmp->msg_flagged = Context->flagged;
2185 +                         break;
2186 +                 }
2187 +                 tmp = tmp->next;
2188 +         }
2189 + }
2190
2191 + void scroll_sidebar(int op, int menu)
2192 + {
2193 +         if(!SidebarWidth) return;
2194 +         if(!CurBuffy) return;
2195
2196 +       switch (op) {
2197 +               case OP_SIDEBAR_NEXT:
2198 +                       if ( CurBuffy->next == NULL ) return;
2199 +                       CurBuffy = CurBuffy->next;
2200 +                       break;
2201 +               case OP_SIDEBAR_PREV:
2202 +                       if ( CurBuffy->prev == NULL ) return;
2203 +                       CurBuffy = CurBuffy->prev;
2204 +                       break;
2205 +               case OP_SIDEBAR_SCROLL_UP:
2206 +                       CurBuffy = TopBuffy;
2207 +                       if ( CurBuffy != Incoming ) {
2208 +                               calc_boundaries(menu);
2209 +                               CurBuffy = CurBuffy->prev;
2210 +                       }
2211 +                       break;
2212 +               case OP_SIDEBAR_SCROLL_DOWN:
2213 +                       CurBuffy = BottomBuffy;
2214 +                       if ( CurBuffy->next ) {
2215 +                               calc_boundaries(menu);
2216 +                               CurBuffy = CurBuffy->next;
2217 +                       }
2218 +                       break;
2219 +               default:
2220 +                       return;
2221 +       }
2222 +       calc_boundaries(menu);
2223 +       draw_sidebar(menu);
2224 + }
2225
2226 *** mutt-1.5.24-orig/sidebar.h  1969-12-31 18:00:00.000000000 -0600
2227 --- mutt-1.5.24/sidebar.h       2015-09-16 23:18:13.000000000 -0500
2228 ***************
2229 *** 0 ****
2230 --- 1,36 ----
2231 + /*
2232 +  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
2233 +  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
2234 +  * 
2235 +  *     This program is free software; you can redistribute it and/or modify
2236 +  *     it under the terms of the GNU General Public License as published by
2237 +  *     the Free Software Foundation; either version 2 of the License, or
2238 +  *     (at your option) any later version.
2239 +  * 
2240 +  *     This program is distributed in the hope that it will be useful,
2241 +  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
2242 +  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2243 +  *     GNU General Public License for more details.
2244 +  * 
2245 +  *     You should have received a copy of the GNU General Public License
2246 +  *     along with this program; if not, write to the Free Software
2247 +  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
2248 +  */ 
2249
2250 + #ifndef SIDEBAR_H
2251 + #define SIDEBAR_H
2252
2253 + struct MBOX_LIST {
2254 +       char *path;
2255 +       int msgcount;
2256 +       int new;
2257 + } MBLIST;
2258
2259 + /* parameter is whether or not to go to the status line */
2260 + /* used for omitting the last | that covers up the status bar in the index */
2261 + int draw_sidebar(int);
2262 + void scroll_sidebar(int, int);
2263 + void set_curbuffy(char*);
2264 + void set_buffystats(CONTEXT*);
2265
2266 + #endif /* SIDEBAR_H */
2267 *** mutt-1.5.24-orig/doc/Muttrc 2015-08-30 12:24:53.000000000 -0500
2268 --- mutt-1.5.24/doc/Muttrc      2015-09-16 23:18:13.000000000 -0500
2269 ***************
2270 *** 657,662 ****
2271 --- 657,682 ----
2272   # $crypt_autosign, $crypt_replysign and $smime_is_default.
2273   # 
2274   # 
2275 + # set sidebar_visible=no
2276 + #
2277 + # Name: sidebar_visible
2278 + # Type: boolean
2279 + # Default: no
2280 + # 
2281 + # 
2282 + # This specifies whether or not to show sidebar (left-side list of folders).
2283 + # 
2284 + # 
2285 + # set sidebar_width=0
2286 + #
2287 + # Name: sidebar_width
2288 + # Type: number
2289 + # Default: 0
2290 + # 
2291 + # 
2292 + # The width of the sidebar.
2293 + # 
2294 + # 
2295   # set crypt_autosign=no
2296   #
2297   # Name: crypt_autosign
2298 *** mutt-1.5.24-orig/imap/imap.c        2015-08-30 12:06:38.000000000 -0500
2299 --- mutt-1.5.24/imap/imap.c     2015-09-16 23:18:13.000000000 -0500
2300 ***************
2301 *** 1523,1529 ****
2302   
2303       imap_munge_mbox_name (munged, sizeof (munged), name);
2304       snprintf (command, sizeof (command),
2305 !             "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
2306   
2307       if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2308       {
2309 --- 1523,1529 ----
2310   
2311       imap_munge_mbox_name (munged, sizeof (munged), name);
2312       snprintf (command, sizeof (command),
2313 !             "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
2314   
2315       if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2316       {
2317 *** mutt-1.5.24-orig/imap/command.c     2015-08-30 12:06:38.000000000 -0500
2318 --- mutt-1.5.24/imap/command.c  2015-09-16 23:18:13.000000000 -0500
2319 ***************
2320 *** 1012,1017 ****
2321 --- 1012,1024 ----
2322              opened */
2323           status->uidnext = oldun;
2324   
2325 +         /* Added to make the sidebar show the correct numbers */
2326 +         if (status->messages)
2327 +         {
2328 +           inc->msgcount = status->messages;
2329 +           inc->msg_unread = status->unseen;
2330 +         }
2331
2332           FREE (&value);
2333           return;
2334         }
This page took 0.323363 seconds and 3 git commands to generate.