View | Details | Raw Unified | Return to bug 188544
Collapse All | Expand All

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

Return to bug 188544