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

(-)./files/extra-patch-sidebar (-1408 / +1247 lines)
Lines 1-6 Link Here
1
--- orig/buffy.c.orig	2010-09-18 14:12:40.000000000 +0200
1
Based on Gentoo's updated version of the Mutt Sidebar patch,
2
+++ new/buffy.c	2010-09-18 14:17:36.000000000 +0200
2
rebased to apply to pristine Mutt sources.
3
@@ -161,6 +161,49 @@
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
24
--- mutt-1.5.22.orig/buffy.c	Mon Apr 22 07:14:53 2013
25
+++ mutt-1.5.22/buffy.c	Fri Oct 18 10:18:45 2013
26
@@ -161,6 +161,49 @@ void mutt_buffy_cleanup (const char *buf, struct stat 
4
   }
27
   }
5
 }
28
 }
6
 
29
 
Lines 50-56 Link Here
50
 BUFFY *mutt_find_mailbox (const char *path)
73
 BUFFY *mutt_find_mailbox (const char *path)
51
 {
74
 {
52
   BUFFY *tmp = NULL;
75
   BUFFY *tmp = NULL;
53
@@ -282,6 +325,7 @@
76
@@ -282,6 +325,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, uns
54
     else
77
     else
55
       (*tmp)->size = 0;
78
       (*tmp)->size = 0;
56
   }
79
   }
Lines 58-941 Link Here
58
   return 0;
81
   return 0;
59
 }
82
 }
60
 
83
 
61
@@ -371,12 +415,17 @@
84
@@ -340,6 +384,68 @@ static int buffy_maildir_hasnew (BUFFY* mailbox)
62
   return rc;
85
   return rc;
63
 }
86
 }
64
 
87
 
65
+#define STAT_CHECK_SIZE (sb.st_size > tmp->size)
88
+/* update message counts for the sidebar */
66
+#define STAT_CHECK_TIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
89
+void buffy_maildir_update (BUFFY* mailbox)
67
+#define STAT_CHECK (option(OPTCHECKMBOXSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_TIME)
90
+{
91
+  char path[_POSIX_PATH_MAX];
92
+  DIR *dirp;
93
+  struct dirent *de;
94
+  char *p;
95
+
96
+  mailbox->msgcount = 0;
97
+  mailbox->msg_unread = 0;
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
+}
68
+
170
+
69
 int mutt_buffy_check (int force)
171
 int mutt_buffy_check (int force)
70
 {
172
 {
71
   BUFFY *tmp;
173
   BUFFY *tmp;
72
   struct stat sb;
174
@@ -444,16 +564,19 @@ int mutt_buffy_check (int force)
73
   struct stat contex_sb;
74
   time_t t;
75
+  CONTEXT *ctx;
76
 
77
   sb.st_size=0;
78
   contex_sb.st_dev=0;
79
@@ -416,6 +465,8 @@
80
   
81
   for (tmp = Incoming; tmp; tmp = tmp->next)
82
   {
83
+    if ( tmp->new == 1 )
84
+       tmp->has_new = 1;
85
     if (tmp->magic != M_IMAP)
86
     {
87
       tmp->new = 0;
88
@@ -455,18 +506,122 @@
89
       {
175
       {
90
       case M_MBOX:
176
       case M_MBOX:
91
       case M_MMDF:
177
       case M_MMDF:
92
-	if (buffy_mbox_hasnew (tmp, &sb) > 0)
178
+	buffy_mbox_update (tmp);
93
-	  BuffyCount++;
179
 	if (buffy_mbox_hasnew (tmp, &sb) > 0)
94
-	break;
180
 	  BuffyCount++;
95
+        {
181
 	break;
96
+          if (STAT_CHECK || tmp->msgcount == 0)
97
+          {
98
+            BUFFY b = *tmp;
99
+            int msgcount = 0;
100
+            int msg_unread = 0;
101
+            /* parse the mailbox, to see how much mail there is */
102
+            ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
103
+            if(ctx)
104
+            {
105
+              msgcount = ctx->msgcount;
106
+              msg_unread = ctx->unread;
107
+              mx_close_mailbox(ctx, 0);
108
+            }
109
+            *tmp = b;
110
+            tmp->msgcount = msgcount;
111
+            tmp->msg_unread = msg_unread;
112
+            if(STAT_CHECK) {
113
+              tmp->has_new = tmp->new = 1;
114
+              BuffyCount++;
115
+            }
116
+          }
117
+          else if (option(OPTCHECKMBOXSIZE))
118
+          {
119
+            /* some other program has deleted mail from the folder */
120
+            tmp->size = (off_t) sb.st_size;
121
+          }
122
+          if (tmp->newly_created &&
123
+              (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
124
+            tmp->newly_created = 0;
125
+        }
126
+        break;
127
+
128
 
182
 
129
       case M_MAILDIR:
183
       case M_MAILDIR:
130
-	if (buffy_maildir_hasnew (tmp) > 0)
184
+	buffy_maildir_update (tmp);
131
-	  BuffyCount++;
185
 	if (buffy_maildir_hasnew (tmp) > 0)
132
+        { 
186
 	  BuffyCount++;
133
+        char path[_POSIX_PATH_MAX];
134
+        DIR *dirp;
135
+        struct dirent *de;
136
+        /* count new message */
137
+        snprintf (path, sizeof (path), "%s/new", tmp->path);
138
+        if ((dirp = opendir (path)) == NULL)
139
+        {
140
+          tmp->magic = 0;
141
+          break;
142
+        }
143
+        tmp->msgcount = 0;
144
+        tmp->msg_unread = 0;
145
+        tmp->msg_flagged = 0;
146
+        while ((de = readdir (dirp)) != NULL)
147
+        {
148
+          char *p;
149
+          if (*de->d_name != '.' &&
150
+              (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
151
+          {
152
+            tmp->has_new = tmp->new = 1;
153
+            tmp->msgcount++;
154
+            tmp->msg_unread++;
155
+          }
156
+        }
157
+        if(tmp->msg_unread)
158
+          BuffyCount++;
159
+
160
+        closedir (dirp);
161
+
162
+        /*
163
+         * count read messages (for folderlist (sidebar) we also need to count
164
+         * messages in cur so that we the total number of messages
165
+         */
166
+        snprintf (path, sizeof (path), "%s/cur", tmp->path);
167
+        if ((dirp = opendir (path)) == NULL)
168
+        {
169
+          tmp->magic = 0;
170
+          break;
171
+        }
172
+        while ((de = readdir (dirp)) != NULL)
173
+        {
174
+          char *p;
175
+          if (*de->d_name != '.') {
176
+                  if ((p = strstr (de->d_name, ":2,"))) {
177
+                          if (!strchr (p + 3, 'T')) {
178
+                                  tmp->msgcount++;
179
+                                  if ( !strchr (p + 3, 'S'))
180
+                                          tmp->msg_unread++;
181
+                                  if (strchr(p + 3, 'F'))
182
+                                          tmp->msg_flagged++;
183
+                          }
184
+                  } else
185
+                          tmp->msgcount++;
186
+          }
187
+        }
188
+        closedir (dirp);
189
+        } 
190
 	break;
187
 	break;
191
 
188
 
192
       case M_MH:
189
       case M_MH:
193
-	if ((tmp->new = mh_buffy (tmp->path)) > 0)
190
+	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged);
194
-	  BuffyCount++;
191
 	mh_buffy(tmp);
195
+        {
192
 	if (tmp->new)
196
+        DIR *dp;
193
 	  BuffyCount++;
197
+        char path[_POSIX_PATH_MAX];
194
diff -uNp -r mutt-1.5.22.orig/buffy.h mutt-1.5.22/buffy.h
198
+        struct dirent *de;
195
--- mutt-1.5.22.orig/buffy.h	Mon Apr 22 07:14:53 2013
199
+        if ((tmp->new = mh_buffy (tmp->path)) > 0)
196
+++ mutt-1.5.22/buffy.h	Fri Oct 18 10:18:45 2013
200
+          BuffyCount++;
197
@@ -25,7 +25,11 @@ typedef struct buffy_t
201
+
198
   char path[_POSIX_PATH_MAX];
202
+        if ((dp = opendir (path)) == NULL)
199
   off_t size;
203
+          break;
200
   struct buffy_t *next;
204
+        tmp->msgcount = 0;
201
+  struct buffy_t *prev;
205
+        while ((de = readdir (dp)))
202
   short new;			/* mailbox has new mail */
206
+        {
203
+  int msgcount;			/* total number of messages */
207
+          if (mh_valid_message (de->d_name))
204
+  int msg_unread;		/* number of unread messages */
208
+          {
205
+  int msg_flagged;		/* number of flagged messages */
209
+            tmp->msgcount++;
206
   short notified;		/* user has been notified */
210
+            tmp->has_new = tmp->new = 1;
207
   short magic;			/* mailbox type */
211
+          }
208
   short newly_created;		/* mbox or mmdf just popped into existence */
212
+        }
209
diff -uNp -r mutt-1.5.22.orig/color.c mutt-1.5.22/color.c
213
+        closedir (dp);
210
--- mutt-1.5.22.orig/color.c	Tue Jan 15 07:37:15 2013
214
+        }
211
+++ mutt-1.5.22/color.c	Fri Oct 18 10:19:53 2013
215
 	break;
212
@@ -93,6 +93,8 @@ static const struct mapping_t Fields[] =
216
       }
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
      {
353
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
354
- 	beep ();
355
+       if (mutt_buffy_notify ())
356
+       {
357
+         menu->redraw |= REDRAW_FULL;
358
+         if (option (OPTBEEPNEW))
359
+           beep ();
360
+       }
361
      }
362
      else
363
        do_buffy_notify = 1;
364
@@ -532,6 +538,7 @@ int mutt_index_menu (void)
365
     if (menu->redraw & REDRAW_FULL)
366
     {
367
       menu_redraw_full (menu);
368
+      draw_sidebar(menu->menu);
369
       mutt_show_error ();
217
     }
370
     }
218
*** mutt-1.5.20-orig/buffy.h	2009-04-30 00:36:16.000000000 -0500
371
 
219
--- mutt-1.5.20-patched/buffy.h	2009-06-19 22:07:04.000000000 -0500
372
@@ -554,9 +561,12 @@ int mutt_index_menu (void)
220
***************
373
 
221
*** 25,31 ****
374
       if (menu->redraw & REDRAW_STATUS)
222
--- 25,36 ----
223
    char path[_POSIX_PATH_MAX];
224
    off_t size;
225
    struct buffy_t *next;
226
+   struct buffy_t *prev;
227
    short new;			/* mailbox has new mail */
228
+   short has_new;		/* set it new if new and not read */
229
+   int msgcount;			/* total number of messages */
230
+   int msg_unread;		/* number of unread messages */
231
+   int msg_flagged;		/* number of flagged messages */
232
    short notified;		/* user has been notified */
233
    short magic;			/* mailbox type */
234
    short newly_created;		/* mbox or mmdf just popped into existence */
235
*** mutt-1.5.20-orig/color.c	2009-05-18 19:11:35.000000000 -0500
236
--- mutt-1.5.20-patched/color.c	2009-06-19 22:07:04.000000000 -0500
237
***************
238
*** 93,98 ****
239
--- 93,100 ----
240
    { "bold",		MT_COLOR_BOLD },
241
    { "underline",	MT_COLOR_UNDERLINE },
242
    { "index",		MT_COLOR_INDEX },
243
+   { "sidebar_new",	MT_COLOR_NEW },
244
+   { "sidebar_flagged",	MT_COLOR_FLAGGED },
245
    { NULL,		0 }
246
  };
247
  
248
*** mutt-1.5.20-orig/curs_main.c	2009-06-13 21:48:36.000000000 -0500
249
--- mutt-1.5.20-patched/curs_main.c	2009-06-19 22:07:04.000000000 -0500
250
***************
251
*** 26,32 ****
252
--- 26,34 ----
253
  #include "mailbox.h"
254
  #include "mapping.h"
255
  #include "sort.h"
256
+ #include "buffy.h"
257
  #include "mx.h"
258
+ #include "sidebar.h"
259
  
260
  #ifdef USE_POP
261
  #include "pop.h"
262
***************
263
*** 523,530 ****
264
         menu->redraw |= REDRAW_STATUS;
265
       if (do_buffy_notify)
266
       {
267
!        if (mutt_buffy_notify () && option (OPTBEEPNEW))
268
!  	beep ();
269
       }
270
       else
271
         do_buffy_notify = 1;
272
--- 525,536 ----
273
         menu->redraw |= REDRAW_STATUS;
274
       if (do_buffy_notify)
275
       {
375
       {
276
!        if (mutt_buffy_notify ())
376
+	DrawFullLine = 1;
277
!        {
377
 	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
278
!          menu->redraw |= REDRAW_FULL;
378
+	DrawFullLine = 0;
279
!          if (option (OPTBEEPNEW))
379
 	move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
280
!            beep ();
380
 	SETCOLOR (MT_COLOR_STATUS);
281
!        }
381
+	set_buffystats(Context);
282
       }
382
 	mutt_paddstr (COLS, buf);
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);
283
       else
393
       else
284
         do_buffy_notify = 1;
394
@@ -1070,6 +1080,7 @@ int mutt_index_menu (void)
285
***************
395
 	  menu->redraw = REDRAW_FULL;
286
*** 536,541 ****
396
 	break;
287
--- 542,548 ----
397
 
288
      if (menu->redraw & REDRAW_FULL)
398
+      case OP_SIDEBAR_OPEN:
289
      {
399
       case OP_MAIN_CHANGE_FOLDER:
290
        menu_redraw_full (menu);
400
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
291
+       draw_sidebar(menu->menu);
401
 
292
        mutt_show_error ();
402
@@ -1101,7 +1112,11 @@ int mutt_index_menu (void)
293
      }
403
 	{
294
  
404
 	  mutt_buffy (buf, sizeof (buf));
295
***************
405
 
296
*** 558,567 ****
406
-	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
297
--- 565,577 ----
407
+          if ( op == OP_SIDEBAR_OPEN ) {
298
  
408
+              if(!CurBuffy)
299
        if (menu->redraw & REDRAW_STATUS)
409
+                break;
300
        {
410
+            strncpy( buf, CurBuffy->path, sizeof(buf) );  
301
+         DrawFullLine = 1;
411
+	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
302
  	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
412
 	  {
303
+         DrawFullLine = 0;
413
 	    if (menu->menu == MENU_PAGER)
304
  	CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
414
 	    {
305
  	SETCOLOR (MT_COLOR_STATUS);
415
@@ -1119,6 +1134,7 @@ int mutt_index_menu (void)
306
          BKGDSET (MT_COLOR_STATUS);
416
 	}
307
+         set_buffystats(Context);
417
 
308
  	mutt_paddstr (COLS, buf);
418
 	mutt_expand_path (buf, sizeof (buf));
309
  	SETCOLOR (MT_COLOR_NORMAL);
419
+        set_curbuffy(buf);
310
          BKGDSET (MT_COLOR_NORMAL);
420
 	if (mx_get_magic (buf) <= 0)
311
***************
421
 	{
312
*** 575,581 ****
422
 	  mutt_error (_("%s is not a mailbox."), buf);
313
  	menu->oldcurrent = -1;
423
@@ -2209,6 +2225,12 @@ int mutt_index_menu (void)
314
  
424
 	mutt_what_key();
315
        if (option (OPTARROWCURSOR))
425
 	break;
316
! 	move (menu->current - menu->top + menu->offset, 2);
426
 
317
        else if (option (OPTBRAILLEFRIENDLY))
427
+      case OP_SIDEBAR_SCROLL_UP:
318
  	move (menu->current - menu->top + menu->offset, 0);
428
+      case OP_SIDEBAR_SCROLL_DOWN:
319
        else
429
+      case OP_SIDEBAR_NEXT:
320
--- 585,591 ----
430
+      case OP_SIDEBAR_PREV:
321
  	menu->oldcurrent = -1;
431
+        scroll_sidebar(op, menu->menu);
322
  
432
+        break;
323
        if (option (OPTARROWCURSOR))
433
       default:
324
! 	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
434
 	if (menu->menu == MENU_MAIN)
325
        else if (option (OPTBRAILLEFRIENDLY))
435
 	  km_error_key (MENU_MAIN);
326
  	move (menu->current - menu->top + menu->offset, 0);
436
diff -uNp -r mutt-1.5.22.orig/flags.c mutt-1.5.22/flags.c
327
        else
437
--- mutt-1.5.22.orig/flags.c	Sun Feb 21 22:10:41 2010
328
***************
438
+++ mutt-1.5.22/flags.c	Fri Oct 18 10:18:45 2013
329
*** 1055,1060 ****
439
@@ -22,8 +22,10 @@
330
--- 1065,1071 ----
440
 
331
  	  menu->redraw = REDRAW_FULL;
441
 #include "mutt.h"
332
  	break;
442
 #include "mutt_curses.h"
333
  
443
+#include "mutt_menu.h"
334
+       case OP_SIDEBAR_OPEN:
444
 #include "sort.h"
335
        case OP_MAIN_CHANGE_FOLDER:
445
 #include "mx.h"
336
        case OP_MAIN_NEXT_UNREAD_MAILBOX:
446
+#include "sidebar.h"
337
  
447
 
338
***************
448
 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
339
*** 1086,1092 ****
449
 {
340
  	{
450
@@ -263,6 +265,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag
341
  	  mutt_buffy (buf, sizeof (buf));
342
  
343
! 	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
344
  	  {
345
  	    if (menu->menu == MENU_PAGER)
346
  	    {
347
--- 1097,1107 ----
348
  	{
349
  	  mutt_buffy (buf, sizeof (buf));
350
  
351
!           if ( op == OP_SIDEBAR_OPEN ) {
352
!               if(!CurBuffy)
353
!                 break;
354
!             strncpy( buf, CurBuffy->path, sizeof(buf) );  
355
! 	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
356
  	  {
357
  	    if (menu->menu == MENU_PAGER)
358
  	    {
359
***************
360
*** 1104,1109 ****
361
--- 1119,1125 ----
362
  	}
363
  
364
  	mutt_expand_path (buf, sizeof (buf));
365
+         set_curbuffy(buf);
366
  	if (mx_get_magic (buf) <= 0)
367
  	{
368
  	  mutt_error (_("%s is not a mailbox."), buf);
369
***************
370
*** 2183,2188 ****
371
--- 2199,2210 ----
372
  	mutt_what_key();
373
  	break;
374
  
375
+       case OP_SIDEBAR_SCROLL_UP:
376
+       case OP_SIDEBAR_SCROLL_DOWN:
377
+       case OP_SIDEBAR_NEXT:
378
+       case OP_SIDEBAR_PREV:
379
+         scroll_sidebar(op, menu->menu);
380
+         break;
381
        default:
382
  	if (menu->menu == MENU_MAIN)
383
  	  km_error_key (MENU_MAIN);
384
*** mutt-1.5.20-orig/flags.c	2008-12-16 21:50:09.000000000 -0600
385
--- mutt-1.5.20-patched/flags.c	2009-06-19 22:07:04.000000000 -0500
386
***************
387
*** 22,29 ****
388
--- 22,31 ----
389
  
390
  #include "mutt.h"
391
  #include "mutt_curses.h"
392
+ #include "mutt_menu.h"
393
  #include "sort.h"
394
  #include "mx.h"
395
+ #include "sidebar.h"
396
  
397
  void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
398
  {
399
***************
400
*** 263,268 ****
401
--- 265,271 ----
402
     */
403
    if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
404
      h->searched = 0;
405
+ 	draw_sidebar(0);
406
  }
407
  
408
  void mutt_tag_set_flag (int flag, int bf)
409
*** mutt-1.5.20-orig/functions.h	2009-04-30 00:36:17.000000000 -0500
410
--- mutt-1.5.20-patched/functions.h	2009-06-19 22:07:04.000000000 -0500
411
***************
412
*** 168,173 ****
413
--- 168,178 ----
414
    { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
415
  
416
  
417
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
418
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
419
+  { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
420
+  { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
421
+  { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
422
    { NULL,			0,				NULL }
423
  };
424
  
425
***************
426
*** 268,273 ****
427
--- 273,283 ----
428
  
429
    { "what-key",		OP_WHAT_KEY,		NULL },
430
  
431
+   { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
432
+   { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
433
+   { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
434
+   { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
435
+   { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
436
    { NULL,		0,				NULL }
437
  };
438
  
439
*** mutt-1.5.20-orig/globals.h	2009-06-03 15:48:31.000000000 -0500
440
--- mutt-1.5.20-patched/globals.h	2009-06-19 22:07:04.000000000 -0500
441
***************
442
*** 117,122 ****
443
--- 117,123 ----
444
  WHERE char *SendCharset;
445
  WHERE char *Sendmail;
446
  WHERE char *Shell;
447
+ WHERE char *SidebarDelim;
448
  WHERE char *Signature;
449
  WHERE char *SimpleSearch;
450
  #if USE_SMTP
451
***************
452
*** 206,211 ****
453
--- 207,215 ----
454
  WHERE short ScoreThresholdRead;
455
  WHERE short ScoreThresholdFlag;
456
  
457
+ WHERE struct buffy_t *CurBuffy INITVAL(0);
458
+ WHERE short DrawFullLine INITVAL(0);
459
+ WHERE short SidebarWidth;
460
  #ifdef USE_IMAP
461
  WHERE short ImapKeepalive;
462
  WHERE short ImapPipelineDepth;
463
*** mutt-1.5.20-orig/init.h	2009-06-13 16:35:21.000000000 -0500
464
--- mutt-1.5.20-patched/init.h	2009-06-19 22:07:04.000000000 -0500
465
***************
466
*** 1941,1946 ****
467
--- 1941,1967 ----
468
    ** not used.
469
    ** (PGP only)
470
    */
451
    */
471
+   {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
452
   if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
472
+   /*
453
     h->searched = 0;
473
+   ** .pp
454
+	draw_sidebar(0);
474
+   ** This specifies the delimiter between the sidebar (if visible) and 
455
 }
475
+   ** other screens.
476
+   */
477
+   { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
478
+   /*
479
+   ** .pp
480
+   ** This specifies whether or not to show sidebar (left-side list of folders).
481
+   */
482
+   { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
483
+   /*
484
+   ** .pp
485
+   ** This specifies whether or not to sort the sidebar alphabetically.
486
+   */
487
+   { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
488
+   /*
489
+   ** .pp
490
+   ** The width of the sidebar.
491
+   */
492
    { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
493
    /*
494
    ** .pp
495
*** mutt-1.5.20-orig/mailbox.h	2009-04-30 00:36:17.000000000 -0500
496
--- mutt-1.5.20-patched/mailbox.h	2009-06-19 22:07:04.000000000 -0500
497
***************
498
*** 27,32 ****
499
--- 27,33 ----
500
  #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
501
  				* safe_fopen() for mbox-style folders.
502
  				*/
503
+ #define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
504
  
505
  /* mx_open_new_message() */
506
  #define M_ADD_FROM	1	/* add a From_ line */
507
--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
508
+++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
509
@@ -34,7 +34,7 @@
510
 	score.c send.c sendlib.c signal.c sort.c \
511
 	status.c system.c thread.c charset.c history.c lib.c \
512
 	muttlib.c editmsg.c mbyte.c \
513
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
514
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
515
 
456
 
516
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
457
 void mutt_tag_set_flag (int flag, int bf)
458
diff -uNp -r mutt-1.5.22.orig/functions.h mutt-1.5.22/functions.h
459
--- mutt-1.5.22.orig/functions.h	Sat Dec  3 19:10:04 2011
460
+++ mutt-1.5.22/functions.h	Fri Oct 18 10:18:45 2013
461
@@ -169,6 +169,11 @@ const struct binding_t OpMain[] = { /* map: index */
462
   { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
463
 
464
 
465
+ { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
466
+ { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
467
+ { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
468
+ { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
469
+ { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
470
   { NULL,			0,				NULL }
471
 };
517
 
472
 
518
--- orig/Makefile.in.orig	2010-09-18 13:23:19.000000000 +0200
473
@@ -272,6 +277,11 @@ const struct binding_t OpPager[] = { /* map: pager */
519
+++ new/Makefile.in	2010-09-18 13:27:19.000000000 +0200
520
@@ -89,7 +89,7 @@
521
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
522
 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
523
 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
524
-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
525
+	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
526
 am__objects_1 =
527
 am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1)
528
 nodist_mutt_OBJECTS = $(am__objects_2)
529
@@ -363,7 +363,7 @@
530
 	score.c send.c sendlib.c signal.c sort.c \
531
 	status.c system.c thread.c charset.c history.c lib.c \
532
 	muttlib.c editmsg.c mbyte.c \
533
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
534
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
535
 
474
 
536
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
475
   { "what-key",		OP_WHAT_KEY,		NULL },
537
 mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
538
@@ -397,7 +397,7 @@
539
 	README.SSL smime.h group.h \
540
 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
541
 	ChangeLog mkchangelog.sh mutt_idna.h \
542
-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in
543
+	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
544
 
476
 
545
 EXTRA_SCRIPTS = smime_keys
477
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
546
 mutt_dotlock_SOURCES = mutt_dotlock.c
478
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
547
*** mutt-1.5.20-orig/mbox.c	2009-06-10 23:29:41.000000000 -0500
479
+  { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
548
--- mutt-1.5.20-patched/mbox.c	2009-06-19 22:07:04.000000000 -0500
480
+  { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
549
***************
481
+  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
550
*** 100,105 ****
482
   { NULL,		0,				NULL }
551
--- 100,106 ----
483
 };
552
      mutt_perror (ctx->path);
484
 
553
      return (-1);
485
diff -uNp -r mutt-1.5.22.orig/globals.h mutt-1.5.22/globals.h
554
    }
486
--- mutt-1.5.22.orig/globals.h	Sat Dec  3 19:10:04 2011
555
+   ctx->atime = sb.st_atime;
487
+++ mutt-1.5.22/globals.h	Fri Oct 18 10:18:45 2013
556
    ctx->mtime = sb.st_mtime;
488
@@ -117,6 +117,7 @@ WHERE short SearchContext;
557
    ctx->size = sb.st_size;
489
 WHERE char *SendCharset;
558
  
490
 WHERE char *Sendmail;
559
***************
491
 WHERE char *Shell;
560
*** 255,260 ****
492
+WHERE char *SidebarDelim;
561
--- 256,262 ----
493
 WHERE char *Signature;
562
  
494
 WHERE char *SimpleSearch;
563
    ctx->size = sb.st_size;
495
 #if USE_SMTP
564
    ctx->mtime = sb.st_mtime;
496
@@ -208,6 +209,9 @@ WHERE short ScoreThresholdDelete;
565
+   ctx->atime = sb.st_atime;
497
 WHERE short ScoreThresholdRead;
566
  
498
 WHERE short ScoreThresholdFlag;
567
  #ifdef NFS_ATTRIBUTE_HACK
499
 
568
    if (sb.st_mtime > sb.st_atime)
500
+WHERE struct buffy_t *CurBuffy INITVAL(0);
569
*** mutt-1.5.20-orig/menu.c	2009-06-01 11:29:32.000000000 -0500
501
+WHERE short DrawFullLine INITVAL(0);
570
--- mutt-1.5.20-patched/menu.c	2009-06-19 22:07:04.000000000 -0500
502
+WHERE short SidebarWidth;
571
***************
503
 #ifdef USE_IMAP
572
*** 24,29 ****
504
 WHERE short ImapKeepalive;
573
--- 24,30 ----
505
 WHERE short ImapPipelineDepth;
574
  #include "mutt_curses.h"
506
diff -uNp -r mutt-1.5.22.orig/imap/command.c mutt-1.5.22/imap/command.c
575
  #include "mutt_menu.h"
507
--- mutt-1.5.22.orig/imap/command.c	Fri Oct 18 05:48:24 2013
576
  #include "mbyte.h"
508
+++ mutt-1.5.22/imap/command.c	Fri Oct 18 10:18:45 2013
577
+ #include "sidebar.h"
509
@@ -1012,6 +1012,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* 
578
  
510
 	     opened */
579
  #include <string.h>
511
 	  status->uidnext = oldun;
580
  #include <stdlib.h>
512
 
581
***************
513
+        /* Added to make the sidebar show the correct numbers */
582
*** 156,162 ****
514
+        if (status->messages)
583
  {
515
+        {
584
    char *scratch = safe_strdup (s);
516
+          inc->msgcount = status->messages;
585
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
517
+          inc->msg_unread = status->unseen;
586
!   int cols = COLS - shift;
518
+        }
587
  
519
+
588
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
520
         FREE (&value);
589
    s[n - 1] = 0;
521
         return;
590
--- 157,163 ----
522
       }
591
  {
523
diff -uNp -r mutt-1.5.22.orig/imap/imap.c mutt-1.5.22/imap/imap.c
592
    char *scratch = safe_strdup (s);
524
--- mutt-1.5.22.orig/imap/imap.c	Fri Oct 18 05:48:24 2013
593
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
525
+++ mutt-1.5.22/imap/imap.c	Fri Oct 18 10:18:45 2013
594
!   int cols = COLS - shift - SidebarWidth;
526
@@ -1514,7 +1514,7 @@ int imap_buffy_check (int force)
595
  
527
 
596
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
528
     imap_munge_mbox_name (munged, sizeof (munged), name);
597
    s[n - 1] = 0;
529
     snprintf (command, sizeof (command),
598
***************
530
-	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
599
*** 207,212 ****
531
+	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
600
--- 208,214 ----
532
 
601
    char buf[LONG_STRING];
533
     if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
602
    int i;
534
     {
603
  
535
diff -uNp -r mutt-1.5.22.orig/init.h mutt-1.5.22/init.h
604
+   draw_sidebar(1);
536
--- mutt-1.5.22.orig/init.h	Tue Jan 15 07:37:15 2013
605
    for (i = menu->top; i < menu->top + menu->pagelen; i++)
537
+++ mutt-1.5.22/init.h	Fri Oct 18 10:18:45 2013
606
    {
538
@@ -1966,6 +1966,27 @@ struct option_t MuttVars[] = {
607
      if (i < menu->max)
539
   ** not used.
608
***************
540
   ** (PGP only)
609
*** 217,223 ****
610
        if (option (OPTARROWCURSOR))
611
        {
612
          attrset (menu->color (i));
613
! 	CLEARLINE (i - menu->top + menu->offset);
614
  
615
  	if (i == menu->current)
616
  	{
617
--- 219,225 ----
618
        if (option (OPTARROWCURSOR))
619
        {
620
          attrset (menu->color (i));
621
! 	CLEARLINE_WIN (i - menu->top + menu->offset);
622
  
623
  	if (i == menu->current)
624
  	{
625
***************
626
*** 246,259 ****
627
  	  BKGDSET (MT_COLOR_INDICATOR);
628
  	}
629
  
630
! 	CLEARLINE (i - menu->top + menu->offset);
631
  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
632
          SETCOLOR (MT_COLOR_NORMAL);
633
          BKGDSET (MT_COLOR_NORMAL);
634
        }
635
      }
636
      else
637
!       CLEARLINE (i - menu->top + menu->offset);
638
    }
639
    menu->redraw = 0;
640
  }
641
--- 248,261 ----
642
  	  BKGDSET (MT_COLOR_INDICATOR);
643
  	}
644
  
645
! 	CLEARLINE_WIN (i - menu->top + menu->offset);
646
  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
647
          SETCOLOR (MT_COLOR_NORMAL);
648
          BKGDSET (MT_COLOR_NORMAL);
649
        }
650
      }
651
      else
652
!       CLEARLINE_WIN (i - menu->top + menu->offset);
653
    }
654
    menu->redraw = 0;
655
  }
656
***************
657
*** 268,274 ****
658
      return;
659
    }
660
    
661
!   move (menu->oldcurrent + menu->offset - menu->top, 0);
662
    SETCOLOR (MT_COLOR_NORMAL);
663
    BKGDSET (MT_COLOR_NORMAL);
664
  
665
--- 270,276 ----
666
      return;
667
    }
668
    
669
!   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
670
    SETCOLOR (MT_COLOR_NORMAL);
671
    BKGDSET (MT_COLOR_NORMAL);
672
  
673
***************
674
*** 283,295 ****
675
        clrtoeol ();
676
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
677
        menu_pad_string (buf, sizeof (buf));
678
!       move (menu->oldcurrent + menu->offset - menu->top, 3);
679
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
680
        SETCOLOR (MT_COLOR_NORMAL);
681
      }
682
  
683
      /* now draw it in the new location */
684
!     move (menu->current + menu->offset - menu->top, 0);
685
      attrset (menu->color (menu->current));
686
      ADDCOLOR (MT_COLOR_INDICATOR);
687
      addstr ("->");
688
--- 285,297 ----
689
        clrtoeol ();
690
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
691
        menu_pad_string (buf, sizeof (buf));
692
!       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
693
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
694
        SETCOLOR (MT_COLOR_NORMAL);
695
      }
696
  
697
      /* now draw it in the new location */
698
!     move (menu->current + menu->offset - menu->top, SidebarWidth);
699
      attrset (menu->color (menu->current));
700
      ADDCOLOR (MT_COLOR_INDICATOR);
701
      addstr ("->");
702
***************
703
*** 310,316 ****
704
      attrset (menu->color (menu->current));
705
      ADDCOLOR (MT_COLOR_INDICATOR);
706
      BKGDSET (MT_COLOR_INDICATOR);
707
!     CLEARLINE (menu->current - menu->top + menu->offset);
708
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
709
      SETCOLOR (MT_COLOR_NORMAL);
710
      BKGDSET (MT_COLOR_NORMAL);
711
--- 312,318 ----
712
      attrset (menu->color (menu->current));
713
      ADDCOLOR (MT_COLOR_INDICATOR);
714
      BKGDSET (MT_COLOR_INDICATOR);
715
!     CLEARLINE_WIN (menu->current - menu->top + menu->offset);
716
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
717
      SETCOLOR (MT_COLOR_NORMAL);
718
      BKGDSET (MT_COLOR_NORMAL);
719
***************
720
*** 322,328 ****
721
  {
722
    char buf[LONG_STRING];
723
    
724
!   move (menu->current + menu->offset - menu->top, 0);
725
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
726
    menu_pad_string (buf, sizeof (buf));
727
  
728
--- 324,330 ----
729
  {
730
    char buf[LONG_STRING];
731
    
732
!   move (menu->current + menu->offset - menu->top, SidebarWidth);
733
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
734
    menu_pad_string (buf, sizeof (buf));
735
  
736
***************
737
*** 876,882 ****
738
      
739
      
740
      if (option (OPTARROWCURSOR))
741
!       move (menu->current - menu->top + menu->offset, 2);
742
      else if (option (OPTBRAILLEFRIENDLY))
743
        move (menu->current - menu->top + menu->offset, 0);
744
      else
745
--- 878,884 ----
746
      
747
      
748
      if (option (OPTARROWCURSOR))
749
!       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
750
      else if (option (OPTBRAILLEFRIENDLY))
751
        move (menu->current - menu->top + menu->offset, 0);
752
      else
753
*** mutt-1.5.20-orig/mutt_curses.h	2008-11-11 13:55:47.000000000 -0600
754
--- mutt-1.5.20-patched/mutt_curses.h	2009-06-19 22:07:04.000000000 -0500
755
***************
756
*** 64,69 ****
757
--- 64,70 ----
758
  #undef lines
759
  #endif /* lines */
760
  
761
+ #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
762
  #define CLEARLINE(x) move(x,0), clrtoeol()
763
  #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
764
  #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
765
***************
766
*** 126,131 ****
767
--- 127,134 ----
768
    MT_COLOR_BOLD,
769
    MT_COLOR_UNDERLINE,
770
    MT_COLOR_INDEX,
771
+   MT_COLOR_NEW,
772
+   MT_COLOR_FLAGGED,
773
    MT_COLOR_MAX
774
  };
775
  
776
*** mutt-1.5.20-orig/mutt.h	2009-06-12 17:15:42.000000000 -0500
777
--- mutt-1.5.20-patched/mutt.h	2009-06-19 22:07:04.000000000 -0500
778
***************
779
*** 418,423 ****
780
--- 418,425 ----
781
    OPTSAVEEMPTY,
782
    OPTSAVENAME,
783
    OPTSCORE,
784
+   OPTSIDEBAR,
785
+   OPTSIDEBARSORT,
786
    OPTSIGDASHES,
787
    OPTSIGONTOP,
788
    OPTSORTRE,
789
***************
790
*** 854,859 ****
791
--- 856,862 ----
792
  {
793
    char *path;
794
    FILE *fp;
795
+   time_t atime;
796
    time_t mtime;
797
    off_t size;
798
    off_t vsize;
799
***************
800
*** 888,893 ****
801
--- 891,897 ----
802
    unsigned int quiet : 1;	/* inhibit status messages? */
803
    unsigned int collapsed : 1;   /* are all threads collapsed? */
804
    unsigned int closing : 1;	/* mailbox is being closed */
805
+   unsigned int peekonly : 1;	/* just taking a glance, revert atime */
806
  
807
    /* driver hooks */
808
    void *data;			/* driver specific data */
809
*** mutt-1.5.20-orig/muttlib.c	2009-05-18 19:11:35.000000000 -0500
810
--- mutt-1.5.20-patched/muttlib.c	2009-06-19 22:07:04.000000000 -0500
811
***************
812
*** 1232,1237 ****
813
--- 1232,1239 ----
814
  	  pl = pw = 1;
815
  
816
  	/* see if there's room to add content, else ignore */
817
+         if ( DrawFullLine )
818
+         {
819
  	if ((col < COLS && wlen < destlen) || soft)
820
  	{
821
  	  int pad;
822
***************
823
*** 1274,1279 ****
824
--- 1276,1327 ----
825
  	  col += wid;
826
  	  src += pl;
827
  	}
828
+         }
829
+         else
830
+         {
831
+ 	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
832
+         {
833
+ 	  int pad;
834
+ 
835
+ 	  /* get contents after padding */
836
+ 	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
837
+ 	  len = mutt_strlen (buf);
838
+ 	  wid = mutt_strwidth (buf);
839
+ 
840
+ 	  /* try to consume as many columns as we can, if we don't have
841
+ 	   * memory for that, use as much memory as possible */
842
+ 	  pad = (COLS - SidebarWidth - col - wid) / pw;
843
+ 	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
844
+ 	    pad = ((signed)(destlen - wlen - len)) / pl;
845
+ 	  if (pad > 0)
846
+ 	  {
847
+ 	    while (pad--)
848
+ 	    {
849
+ 	      memcpy (wptr, src, pl);
850
+ 	      wptr += pl;
851
+ 	      wlen += pl;
852
+ 	      col += pw;
853
+ 	    }
854
+ 	  }
855
+ 	  else if (soft && pad < 0)
856
+ 	  {
857
+ 	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
858
+ 	    *wptr = 0;
859
+ 	    /* make sure right part is at most as wide as display */
860
+ 	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
861
+ 	    /* truncate left so that right part fits completely in */
862
+ 	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
863
+ 	    wptr = dest + wlen;
864
+ 	  }
865
+ 	  if (len + wlen > destlen)
866
+ 	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
867
+ 	  memcpy (wptr, buf, len);
868
+ 	  wptr += len;
869
+ 	  wlen += len;
870
+ 	  col += wid;
871
+ 	  src += pl;
872
+ 	}
873
+         }
874
  	break; /* skip rest of input */
875
        }
876
        else if (ch == '|')
877
*** mutt-1.5.20-orig/mx.c	2009-06-10 23:29:41.000000000 -0500
878
--- mutt-1.5.20-patched/mx.c	2009-06-19 22:07:04.000000000 -0500
879
***************
880
*** 581,586 ****
881
--- 581,587 ----
882
   *		M_APPEND	open mailbox for appending
883
   *		M_READONLY	open mailbox in read-only mode
884
   *		M_QUIET		only print error messages
885
+  *		M_PEEK		revert atime where applicable
886
   *	ctx	if non-null, context struct to use
887
   */
541
   */
888
  CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
542
+  {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
889
***************
543
+  /*
890
*** 603,608 ****
544
+  ** .pp
891
--- 604,611 ----
545
+  ** This specifies the delimiter between the sidebar (if visible) and 
892
      ctx->quiet = 1;
546
+  ** other screens.
893
    if (flags & M_READONLY)
547
+  */
894
      ctx->readonly = 1;
548
+  { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
895
+   if (flags & M_PEEK)
549
+  /*
896
+     ctx->peekonly = 1;
550
+  ** .pp
897
  
551
+  ** This specifies whether or not to show sidebar (left-side list of folders).
898
    if (flags & (M_APPEND|M_NEWFOLDER))
552
+  */
899
    {
553
+  { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
900
***************
554
+  /*
901
*** 702,710 ****
555
+  ** .pp
902
--- 705,725 ----
556
+  ** This specifies whether or not to sort the sidebar alphabetically.
903
  void mx_fastclose_mailbox (CONTEXT *ctx)
557
+  */
904
  {
558
+  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
905
    int i;
559
+  /*
906
+ #ifndef BUFFY_SIZE
560
+  ** .pp
907
+   struct utimbuf ut;
561
+  ** The width of the sidebar.
908
+ #endif
562
+  */
909
  
563
   { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
910
    if(!ctx) 
564
   /*
911
      return;
565
   ** .pp
912
+ #ifndef BUFFY_SIZE
566
diff -uNp -r mutt-1.5.22.orig/mailbox.h mutt-1.5.22/mailbox.h
913
+   /* fix up the times so buffy won't get confused */
567
--- mutt-1.5.22.orig/mailbox.h	Sun Feb 21 22:10:41 2010
914
+   if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
568
+++ mutt-1.5.22/mailbox.h	Fri Oct 18 10:18:45 2013
915
+   {
569
@@ -27,6 +27,7 @@
916
+     ut.actime = ctx->atime;
570
 #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
917
+     ut.modtime = ctx->mtime;
571
 				* safe_fopen() for mbox-style folders.
918
+     utime (ctx->path, &ut); 
572
 				*/
919
+   }
573
+#define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
920
+ #endif
574
 
921
  
575
 /* mx_open_new_message() */
922
    if (ctx->mx_close)
576
 #define M_ADD_FROM	1	/* add a From_ line */
923
      ctx->mx_close (ctx);
577
diff -uNp -r mutt-1.5.22.orig/mbox.c mutt-1.5.22/mbox.c
924
*** mutt-1.5.20-orig/OPS	2009-05-13 00:01:13.000000000 -0500
578
--- mutt-1.5.22.orig/mbox.c	Fri Oct 18 05:48:24 2013
925
--- mutt-1.5.20-patched/OPS	2009-06-19 22:07:04.000000000 -0500
579
+++ mutt-1.5.22/mbox.c	Fri Oct 18 10:18:45 2013
926
***************
580
@@ -100,6 +100,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
927
*** 178,180 ****
581
     mutt_perror (ctx->path);
928
--- 178,185 ----
582
     return (-1);
929
  OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
583
   }
930
  OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
584
+  ctx->atime = sb.st_atime;
931
  OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
585
   ctx->mtime = sb.st_mtime;
932
+ OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
586
   ctx->size = sb.st_size;
933
+ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
587
 
934
+ OP_SIDEBAR_NEXT "go down to next mailbox"
588
@@ -251,6 +252,7 @@ int mbox_parse_mailbox (CONTEXT *ctx)
935
+ OP_SIDEBAR_PREV "go to previous mailbox"
589
 
936
+ OP_SIDEBAR_OPEN "open hilighted mailbox"
590
   ctx->size = sb.st_size;
937
--- orig/pager.c.orig	2010-09-18 13:23:19.000000000 +0200
591
   ctx->mtime = sb.st_mtime;
938
+++ new/pager.c	2010-09-18 14:03:08.000000000 +0200
592
+  ctx->atime = sb.st_atime;
593
 
594
 #ifdef NFS_ATTRIBUTE_HACK
595
   if (sb.st_mtime > sb.st_atime)
596
diff -uNp -r mutt-1.5.22.orig/menu.c mutt-1.5.22/menu.c
597
--- mutt-1.5.22.orig/menu.c	Tue Jan 15 07:37:15 2013
598
+++ mutt-1.5.22/menu.c	Fri Oct 18 10:18:45 2013
599
@@ -24,6 +24,7 @@
600
 #include "mutt_curses.h"
601
 #include "mutt_menu.h"
602
 #include "mbyte.h"
603
+#include "sidebar.h"
604
 
605
 extern size_t UngetCount;
606
 
607
@@ -186,7 +187,7 @@ static void menu_pad_string (char *s, size_t n)
608
 {
609
   char *scratch = safe_strdup (s);
610
   int shift = option (OPTARROWCURSOR) ? 3 : 0;
611
-  int cols = COLS - shift;
612
+  int cols = COLS - shift - SidebarWidth;
613
 
614
   mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
615
   s[n - 1] = 0;
616
@@ -239,6 +240,7 @@ void menu_redraw_index (MUTTMENU *menu)
617
   int do_color;
618
   int attr;
619
 
620
+  draw_sidebar(1);
621
   for (i = menu->top; i < menu->top + menu->pagelen; i++)
622
   {
623
     if (i < menu->max)
624
@@ -249,7 +251,7 @@ void menu_redraw_index (MUTTMENU *menu)
625
       menu_pad_string (buf, sizeof (buf));
626
 
627
       ATTRSET(attr);
628
-      move(i - menu->top + menu->offset, 0);
629
+      move(i - menu->top + menu->offset, SidebarWidth);
630
       do_color = 1;
631
 
632
       if (i == menu->current)
633
@@ -272,7 +274,7 @@ void menu_redraw_index (MUTTMENU *menu)
634
     else
635
     {
636
       NORMAL_COLOR;
637
-      CLEARLINE(i - menu->top + menu->offset);
638
+      CLEARLINE_WIN(i - menu->top + menu->offset);
639
     }
640
   }
641
   NORMAL_COLOR;
642
@@ -289,7 +291,7 @@ void menu_redraw_motion (MUTTMENU *menu)
643
     return;
644
   }
645
   
646
-  move (menu->oldcurrent + menu->offset - menu->top, 0);
647
+  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
648
   ATTRSET(menu->color (menu->oldcurrent));
649
 
650
   if (option (OPTARROWCURSOR))
651
@@ -301,13 +303,13 @@ void menu_redraw_motion (MUTTMENU *menu)
652
     {
653
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
654
       menu_pad_string (buf, sizeof (buf));
655
-      move (menu->oldcurrent + menu->offset - menu->top, 3);
656
+      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
657
       print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
658
     }
659
 
660
     /* now draw it in the new location */
661
     SETCOLOR(MT_COLOR_INDICATOR);
662
-    mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
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
   
680
-  move (menu->current + menu->offset - menu->top, 0);
681
+  move (menu->current + menu->offset - menu->top, SidebarWidth);
682
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
683
   menu_pad_string (buf, sizeof (buf));
684
 
685
@@ -872,7 +874,7 @@ int mutt_menuLoop (MUTTMENU *menu)
686
     
687
     
688
     if (option (OPTARROWCURSOR))
689
-      move (menu->current - menu->top + menu->offset, 2);
690
+      move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
691
     else if (option (OPTBRAILLEFRIENDLY))
692
       move (menu->current - menu->top + menu->offset, 0);
693
     else
694
diff -uNp -r mutt-1.5.22.orig/mh.c mutt-1.5.22/mh.c
695
--- mutt-1.5.22.orig/mh.c	Mon Apr 22 07:14:53 2013
696
+++ mutt-1.5.22/mh.c	Fri Oct 18 10:18:45 2013
697
@@ -295,6 +295,28 @@ void mh_buffy(BUFFY *b)
698
   mhs_free_sequences (&mhs);
699
 }
700
 
701
+void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged)
702
+{
703
+  int i;
704
+  struct mh_sequences mhs;
705
+  memset (&mhs, 0, sizeof (mhs));
706
+
707
+  if (mh_read_sequences (&mhs, path) < 0)
708
+    return;
709
+
710
+  msgcount = 0;
711
+  msg_unread = 0;
712
+  msg_flagged = 0;
713
+  for (i = 0; i <= mhs.max; i++)
714
+    msgcount++;
715
+  if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
716
+    msg_unread++;
717
+  }
718
+  if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
719
+    msg_flagged++;
720
+  mhs_free_sequences (&mhs);
721
+}
722
+
723
 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
724
 {
725
   int fd;
726
diff -uNp -r mutt-1.5.22.orig/mutt.h mutt-1.5.22/mutt.h
727
--- mutt-1.5.22.orig/mutt.h	Fri Oct 18 05:48:24 2013
728
+++ mutt-1.5.22/mutt.h	Fri Oct 18 10:18:45 2013
729
@@ -420,6 +420,8 @@ enum
730
   OPTSAVEEMPTY,
731
   OPTSAVENAME,
732
   OPTSCORE,
733
+  OPTSIDEBAR,
734
+  OPTSIDEBARSORT,
735
   OPTSIGDASHES,
736
   OPTSIGONTOP,
737
   OPTSORTRE,
738
@@ -860,6 +862,7 @@ typedef struct _context
739
 {
740
   char *path;
741
   FILE *fp;
742
+  time_t atime;
743
   time_t mtime;
744
   off_t size;
745
   off_t vsize;
746
@@ -894,6 +897,7 @@ typedef struct _context
747
   unsigned int quiet : 1;	/* inhibit status messages? */
748
   unsigned int collapsed : 1;   /* are all threads collapsed? */
749
   unsigned int closing : 1;	/* mailbox is being closed */
750
+  unsigned int peekonly : 1;	/* just taking a glance, revert atime */
751
 
752
   /* driver hooks */
753
   void *data;			/* driver specific data */
754
diff -uNp -r mutt-1.5.22.orig/mutt_curses.h mutt-1.5.22/mutt_curses.h
755
--- mutt-1.5.22.orig/mutt_curses.h	Tue Jan 15 07:37:15 2013
756
+++ mutt-1.5.22/mutt_curses.h	Fri Oct 18 10:22:32 2013
757
@@ -64,6 +64,7 @@
758
 #undef lines
759
 #endif /* lines */
760
 
761
+#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
762
 #define CLEARLINE(x) move(x,0), clrtoeol()
763
 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
764
 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
765
@@ -120,6 +121,8 @@ enum
766
   MT_COLOR_BOLD,
767
   MT_COLOR_UNDERLINE,
768
   MT_COLOR_INDEX,
769
+  MT_COLOR_NEW,
770
+  MT_COLOR_FLAGGED,
771
   MT_COLOR_MAX
772
 };
773
 
774
diff -uNp -r mutt-1.5.22.orig/muttlib.c mutt-1.5.22/muttlib.c
775
--- mutt-1.5.22.orig/muttlib.c	Fri Oct 18 05:48:24 2013
776
+++ mutt-1.5.22/muttlib.c	Fri Oct 18 10:18:45 2013
777
@@ -1286,6 +1286,8 @@ void mutt_FormatString (char *dest,		/* output buffer 
778
 	  pl = pw = 1;
779
 
780
 	/* see if there's room to add content, else ignore */
781
+        if ( DrawFullLine )
782
+        {
783
 	if ((col < COLS && wlen < destlen) || soft)
784
 	{
785
 	  int pad;
786
@@ -1329,6 +1331,52 @@ void mutt_FormatString (char *dest,		/* output buffer 
787
 	  col += wid;
788
 	  src += pl;
789
 	}
790
+        }
791
+        else
792
+        {
793
+	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
794
+        {
795
+	  int pad;
796
+
797
+	  /* get contents after padding */
798
+	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
799
+	  len = mutt_strlen (buf);
800
+	  wid = mutt_strwidth (buf);
801
+
802
+	  /* try to consume as many columns as we can, if we don't have
803
+	   * memory for that, use as much memory as possible */
804
+	  pad = (COLS - SidebarWidth - col - wid) / pw;
805
+	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
806
+	    pad = ((signed)(destlen - wlen - len)) / pl;
807
+	  if (pad > 0)
808
+	  {
809
+	    while (pad--)
810
+	    {
811
+	      memcpy (wptr, src, pl);
812
+	      wptr += pl;
813
+	      wlen += pl;
814
+	      col += pw;
815
+	    }
816
+	  }
817
+	  else if (soft && pad < 0)
818
+	  {
819
+	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
820
+	    *wptr = 0;
821
+	    /* make sure right part is at most as wide as display */
822
+	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
823
+	    /* truncate left so that right part fits completely in */
824
+	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
825
+	    wptr = dest + wlen;
826
+	  }
827
+	  if (len + wlen > destlen)
828
+	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
829
+	  memcpy (wptr, buf, len);
830
+	  wptr += len;
831
+	  wlen += len;
832
+	  col += wid;
833
+	  src += pl;
834
+	}
835
+        }
836
 	break; /* skip rest of input */
837
       }
838
       else if (ch == '|')
839
diff -uNp -r mutt-1.5.22.orig/mx.c mutt-1.5.22/mx.c
840
--- mutt-1.5.22.orig/mx.c	Fri Oct 18 05:48:24 2013
841
+++ mutt-1.5.22/mx.c	Fri Oct 18 10:18:45 2013
842
@@ -580,6 +580,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int f
843
  *		M_APPEND	open mailbox for appending
844
  *		M_READONLY	open mailbox in read-only mode
845
  *		M_QUIET		only print error messages
846
+ *		M_PEEK		revert atime where applicable
847
  *	ctx	if non-null, context struct to use
848
  */
849
 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
850
@@ -602,6 +603,8 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
851
     ctx->quiet = 1;
852
   if (flags & M_READONLY)
853
     ctx->readonly = 1;
854
+  if (flags & M_PEEK)
855
+    ctx->peekonly = 1;
856
 
857
   if (flags & (M_APPEND|M_NEWFOLDER))
858
   {
859
@@ -701,9 +704,21 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
860
 void mx_fastclose_mailbox (CONTEXT *ctx)
861
 {
862
   int i;
863
+#ifndef BUFFY_SIZE
864
+  struct utimbuf ut;
865
+#endif
866
 
867
   if(!ctx) 
868
     return;
869
+#ifndef BUFFY_SIZE
870
+  /* fix up the times so buffy won't get confused */
871
+  if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
872
+  {
873
+    ut.actime = ctx->atime;
874
+    ut.modtime = ctx->mtime;
875
+    utime (ctx->path, &ut); 
876
+  }
877
+#endif
878
 
879
   /* never announce that a mailbox we've just left has new mail. #3290
880
    * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
881
diff -uNp -r mutt-1.5.22.orig/mx.h mutt-1.5.22/mx.h
882
--- mutt-1.5.22.orig/mx.h	Mon Apr 22 07:14:53 2013
883
+++ mutt-1.5.22/mx.h	Fri Oct 18 10:18:45 2013
884
@@ -57,6 +57,7 @@ void mbox_reset_atime (CONTEXT *, struct stat *);
885
 int mh_read_dir (CONTEXT *, const char *);
886
 int mh_sync_mailbox (CONTEXT *, int *);
887
 int mh_check_mailbox (CONTEXT *, int *);
888
+void mh_buffy_update (const char *, int *, int *, int *);
889
 int mh_check_empty (const char *);
890
 
891
 int maildir_read_dir (CONTEXT *);
892
diff -uNp -r mutt-1.5.22.orig/pager.c mutt-1.5.22/pager.c
893
--- mutt-1.5.22.orig/pager.c	Mon Apr 22 07:17:32 2013
894
+++ mutt-1.5.22/pager.c	Fri Oct 18 10:18:45 2013
939
@@ -29,6 +29,7 @@
895
@@ -29,6 +29,7 @@
940
 #include "pager.h"
896
 #include "pager.h"
941
 #include "attach.h"
897
 #include "attach.h"
Lines 944-958 Link Here
944
 
900
 
945
 #include "mutt_crypt.h"
901
 #include "mutt_crypt.h"
946
 
902
 
947
@@ -1104,6 +1105,7 @@
903
@@ -1095,6 +1096,7 @@ static int format_line (struct line_t **lineInfo, int 
948
   if (check_attachment_marker ((char *)buf) == 0)
904
   wchar_t wc;
949
     wrap_cols = COLS;
905
   mbstate_t mbstate;
950
 
906
   int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
951
+  wrap_cols -= SidebarWidth;
907
+  wrap_cols -= SidebarWidth;
952
   /* FIXME: this should come from lineInfo */
953
   memset(&mbstate, 0, sizeof(mbstate));
954
 
908
 
955
@@ -1778,7 +1780,7 @@
909
   if (check_attachment_marker ((char *)buf) == 0)
910
     wrap_cols = COLS;
911
@@ -1746,7 +1748,7 @@ mutt_pager (const char *banner, const char *fname, int
956
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
912
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
957
     {
913
     {
958
       do {
914
       do {
Lines 961-967 Link Here
961
 	curline = oldtopline = topline;
917
 	curline = oldtopline = topline;
962
 	lines = 0;
918
 	lines = 0;
963
 	force_redraw = 0;
919
 	force_redraw = 0;
964
@@ -1791,6 +1793,7 @@
920
@@ -1759,6 +1761,7 @@ mutt_pager (const char *banner, const char *fname, int
965
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
921
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
966
 	    lines++;
922
 	    lines++;
967
 	  curline++;
923
 	  curline++;
Lines 969-988 Link Here
969
 	}
925
 	}
970
 	last_offset = lineInfo[curline].offset;
926
 	last_offset = lineInfo[curline].offset;
971
       } while (force_redraw);
927
       } while (force_redraw);
972
@@ -1804,6 +1807,7 @@
928
@@ -1771,6 +1774,7 @@ mutt_pager (const char *banner, const char *fname, int
973
 	  addch ('~');
929
 	  addch ('~');
974
 	addch ('\n');
930
 	addch ('\n');
975
 	lines++;
931
 	lines++;
976
+  	move(lines + bodyoffset, SidebarWidth);
932
+  	move(lines + bodyoffset, SidebarWidth);
977
       }
933
       }
978
       /* We are going to update the pager status bar, so it isn't
934
       NORMAL_COLOR;
979
        * necessary to reset to normal color now. */
935
 
980
@@ -1827,21 +1831,21 @@
936
@@ -1799,17 +1803,17 @@ mutt_pager (const char *banner, const char *fname, int
981
       /* print out the pager status bar */
982
       SETCOLOR (MT_COLOR_STATUS);
983
       BKGDSET (MT_COLOR_STATUS);
984
-      CLEARLINE (statusoffset);
985
+      CLEARLINE_WIN (statusoffset);
986
 
937
 
987
       if (IsHeader (extra) || IsMsgAttach (extra))
938
       if (IsHeader (extra) || IsMsgAttach (extra))
988
       {
939
       {
Lines 1001-1009 Link Here
1001
-	mutt_paddstr (COLS, bn);
952
-	mutt_paddstr (COLS, bn);
1002
+	mutt_paddstr (COLS-SidebarWidth, bn);
953
+	mutt_paddstr (COLS-SidebarWidth, bn);
1003
       }
954
       }
1004
       BKGDSET (MT_COLOR_NORMAL);
955
       NORMAL_COLOR;
1005
       SETCOLOR (MT_COLOR_NORMAL);
956
     }
1006
@@ -1852,18 +1856,23 @@
957
@@ -1819,16 +1823,21 @@ mutt_pager (const char *banner, const char *fname, int
1007
       /* redraw the pager_index indicator, because the
958
       /* redraw the pager_index indicator, because the
1008
        * flags for this message might have changed. */
959
        * flags for this message might have changed. */
1009
       menu_redraw_current (index);
960
       menu_redraw_current (index);
Lines 1015-1025 Link Here
1015
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
966
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
1016
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
967
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
1017
       SETCOLOR (MT_COLOR_STATUS);
968
       SETCOLOR (MT_COLOR_STATUS);
1018
       BKGDSET (MT_COLOR_STATUS);
1019
-      mutt_paddstr (COLS, buffer);
969
-      mutt_paddstr (COLS, buffer);
1020
+      mutt_paddstr (COLS-SidebarWidth, buffer);
970
+      mutt_paddstr (COLS-SidebarWidth, buffer);
1021
       SETCOLOR (MT_COLOR_NORMAL);
971
       NORMAL_COLOR;
1022
       BKGDSET (MT_COLOR_NORMAL);
1023
     }
972
     }
1024
 
973
 
1025
+    /* if we're not using the index, update every time */
974
+    /* if we're not using the index, update every time */
Lines 1029-1433 Link Here
1029
     redraw = 0;
978
     redraw = 0;
1030
 
979
 
1031
     if (option(OPTBRAILLEFRIENDLY)) {
980
     if (option(OPTBRAILLEFRIENDLY)) {
1032
@@ -2852,6 +2861,13 @@
981
@@ -2762,6 +2771,13 @@ search_next:
982
       case OP_WHAT_KEY:
1033
 	mutt_what_key ();
983
 	mutt_what_key ();
1034
 	break;
984
 	break;
1035
 
985
+
1036
+      case OP_SIDEBAR_SCROLL_UP:
986
+      case OP_SIDEBAR_SCROLL_UP:
1037
+      case OP_SIDEBAR_SCROLL_DOWN:
987
+      case OP_SIDEBAR_SCROLL_DOWN:
1038
+      case OP_SIDEBAR_NEXT:
988
+      case OP_SIDEBAR_NEXT:
1039
+      case OP_SIDEBAR_PREV:
989
+      case OP_SIDEBAR_PREV:
1040
+	scroll_sidebar(ch, MENU_PAGER);
990
+	scroll_sidebar(ch, MENU_PAGER);
1041
+ 	break;
991
+ 	break;
1042
+
992
 
1043
       default:
993
       default:
1044
 	ch = -1;
994
 	ch = -1;
1045
 	break;
995
diff -uNp -r mutt-1.5.22.orig/sidebar.c mutt-1.5.22/sidebar.c
1046
*** mutt-1.5.20-orig/PATCHES	2008-11-11 13:55:46.000000000 -0600
996
--- mutt-1.5.22.orig/sidebar.c	Thu Jan  1 01:00:00 1970
1047
--- mutt-1.5.20-patched/PATCHES	2009-06-19 22:20:31.000000000 -0500
997
+++ mutt-1.5.22/sidebar.c	Fri Oct 18 10:18:45 2013
1048
***************
998
@@ -0,0 +1,333 @@
1049
*** 0 ****
999
+/*
1050
--- 1 ----
1000
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1051
+ patch-1.5.20.sidebar.20090619.txt
1001
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1052
*** mutt-1.5.20-orig/sidebar.c	1969-12-31 18:00:00.000000000 -0600
1002
+ * 
1053
--- mutt-1.5.20-patched/sidebar.c	2009-06-19 22:07:04.000000000 -0500
1003
+ *     This program is free software; you can redistribute it and/or modify
1054
***************
1004
+ *     it under the terms of the GNU General Public License as published by
1055
*** 0 ****
1005
+ *     the Free Software Foundation; either version 2 of the License, or
1056
--- 1,333 ----
1006
+ *     (at your option) any later version.
1057
+ /*
1007
+ * 
1058
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1008
+ *     This program is distributed in the hope that it will be useful,
1059
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1009
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1060
+  * 
1010
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1061
+  *     This program is free software; you can redistribute it and/or modify
1011
+ *     GNU General Public License for more details.
1062
+  *     it under the terms of the GNU General Public License as published by
1012
+ * 
1063
+  *     the Free Software Foundation; either version 2 of the License, or
1013
+ *     You should have received a copy of the GNU General Public License
1064
+  *     (at your option) any later version.
1014
+ *     along with this program; if not, write to the Free Software
1065
+  * 
1015
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1066
+  *     This program is distributed in the hope that it will be useful,
1016
+ */ 
1067
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1017
+
1068
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1018
+
1069
+  *     GNU General Public License for more details.
1019
+#if HAVE_CONFIG_H
1070
+  * 
1020
+# include "config.h"
1071
+  *     You should have received a copy of the GNU General Public License
1021
+#endif
1072
+  *     along with this program; if not, write to the Free Software
1022
+
1073
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1023
+#include "mutt.h"
1074
+  */ 
1024
+#include "mutt_menu.h"
1075
+ 
1025
+#include "mutt_curses.h"
1076
+ 
1026
+#include "sidebar.h"
1077
+ #if HAVE_CONFIG_H
1027
+#include "buffy.h"
1078
+ # include "config.h"
1028
+#include <libgen.h>
1079
+ #endif
1029
+#include "keymap.h"
1080
+ 
1030
+#include <stdbool.h>
1081
+ #include "mutt.h"
1031
+
1082
+ #include "mutt_menu.h"
1032
+/*BUFFY *CurBuffy = 0;*/
1083
+ #include "mutt_curses.h"
1033
+static BUFFY *TopBuffy = 0;
1084
+ #include "sidebar.h"
1034
+static BUFFY *BottomBuffy = 0;
1085
+ #include "buffy.h"
1035
+static int known_lines = 0;
1086
+ #include <libgen.h>
1036
+
1087
+ #include "keymap.h"
1037
+static int quick_log10(int n)
1088
+ #include <stdbool.h>
1038
+{
1089
+ 
1039
+        char string[32];
1090
+ /*BUFFY *CurBuffy = 0;*/
1040
+        sprintf(string, "%d", n);
1091
+ static BUFFY *TopBuffy = 0;
1041
+        return strlen(string);
1092
+ static BUFFY *BottomBuffy = 0;
1042
+}
1093
+ static int known_lines = 0;
1043
+
1094
+ 
1044
+void calc_boundaries (int menu)
1095
+ static int quick_log10(int n)
1045
+{
1096
+ {
1046
+	BUFFY *tmp = Incoming;
1097
+         char string[32];
1047
+
1098
+         sprintf(string, "%d", n);
1048
+	if ( known_lines != LINES ) {
1099
+         return strlen(string);
1049
+		TopBuffy = BottomBuffy = 0;
1100
+ }
1050
+		known_lines = LINES;
1101
+ 
1051
+	}
1102
+ void calc_boundaries (int menu)
1052
+	for ( ; tmp->next != 0; tmp = tmp->next )
1103
+ {
1053
+		tmp->next->prev = tmp;
1104
+ 	BUFFY *tmp = Incoming;
1054
+
1105
+ 
1055
+	if ( TopBuffy == 0 && BottomBuffy == 0 )
1106
+ 	if ( known_lines != LINES ) {
1056
+		TopBuffy = Incoming;
1107
+ 		TopBuffy = BottomBuffy = 0;
1057
+	if ( BottomBuffy == 0 ) {
1108
+ 		known_lines = LINES;
1058
+		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1109
+ 	}
1059
+		BottomBuffy = TopBuffy;
1110
+ 	for ( ; tmp->next != 0; tmp = tmp->next )
1060
+		while ( --count && BottomBuffy->next )
1111
+ 		tmp->next->prev = tmp;
1061
+			BottomBuffy = BottomBuffy->next;
1112
+ 
1062
+	}
1113
+ 	if ( TopBuffy == 0 && BottomBuffy == 0 )
1063
+	else if ( TopBuffy == CurBuffy->next ) {
1114
+ 		TopBuffy = Incoming;
1064
+		int count = LINES - 2 - (menu != MENU_PAGER);
1115
+ 	if ( BottomBuffy == 0 ) {
1065
+		BottomBuffy = CurBuffy;
1116
+ 		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1066
+		tmp = BottomBuffy;
1117
+ 		BottomBuffy = TopBuffy;
1067
+		while ( --count && tmp->prev)
1118
+ 		while ( --count && BottomBuffy->next )
1068
+			tmp = tmp->prev;
1119
+ 			BottomBuffy = BottomBuffy->next;
1069
+		TopBuffy = tmp;
1120
+ 	}
1070
+	}
1121
+ 	else if ( TopBuffy == CurBuffy->next ) {
1071
+	else if ( BottomBuffy == CurBuffy->prev ) {
1122
+ 		int count = LINES - 2 - (menu != MENU_PAGER);
1072
+		int count = LINES - 2 - (menu != MENU_PAGER);
1123
+ 		BottomBuffy = CurBuffy;
1073
+		TopBuffy = CurBuffy;
1124
+ 		tmp = BottomBuffy;
1074
+		tmp = TopBuffy;
1125
+ 		while ( --count && tmp->prev)
1075
+		while ( --count && tmp->next )
1126
+ 			tmp = tmp->prev;
1076
+			tmp = tmp->next;
1127
+ 		TopBuffy = tmp;
1077
+		BottomBuffy = tmp;
1128
+ 	}
1078
+	}
1129
+ 	else if ( BottomBuffy == CurBuffy->prev ) {
1079
+}
1130
+ 		int count = LINES - 2 - (menu != MENU_PAGER);
1080
+
1131
+ 		TopBuffy = CurBuffy;
1081
+char *make_sidebar_entry(char *box, int size, int new, int flagged)
1132
+ 		tmp = TopBuffy;
1082
+{
1133
+ 		while ( --count && tmp->next )
1083
+	static char *entry = 0;
1134
+ 			tmp = tmp->next;
1084
+	char *c;
1135
+ 		BottomBuffy = tmp;
1085
+	int i = 0;
1136
+ 	}
1086
+	int delim_len = strlen(SidebarDelim);
1137
+ }
1087
+
1138
+ 
1088
+	c = realloc(entry, SidebarWidth - delim_len + 2);
1139
+ char *make_sidebar_entry(char *box, int size, int new, int flagged)
1089
+	if ( c ) entry = c;
1140
+ {
1090
+	entry[SidebarWidth - delim_len + 1] = 0;
1141
+ 	static char *entry = 0;
1091
+	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1142
+ 	char *c;
1092
+	i = strlen(box);
1143
+ 	int i = 0;
1093
+	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1144
+ 	int delim_len = strlen(SidebarDelim);
1094
+
1145
+ 
1095
+        if (size == -1)
1146
+ 	c = realloc(entry, SidebarWidth - delim_len + 2);
1096
+                sprintf(entry + SidebarWidth - delim_len - 3, "?");
1147
+ 	if ( c ) entry = c;
1097
+        else if ( new ) {
1148
+ 	entry[SidebarWidth - delim_len + 1] = 0;
1098
+          if (flagged > 0) {
1149
+ 	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1099
+              sprintf(
1150
+ 	i = strlen(box);
1100
+		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1151
+ 	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1101
+		        "% d(%d)[%d]", size, new, flagged);
1152
+ 
1153
+         if (size == -1)
1154
+                 sprintf(entry + SidebarWidth - delim_len - 3, "?");
1155
+         else if ( new ) {
1156
+           if (flagged > 0) {
1157
+               sprintf(
1158
+ 		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1159
+ 		        "% d(%d)[%d]", size, new, flagged);
1160
+           } else {
1161
+               sprintf(
1162
+                       entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1163
+                       "% d(%d)", size, new);
1164
+           }
1165
+         } else if (flagged > 0) {
1166
+               sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1167
+         } else {
1168
+               sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1169
+         }
1170
+ 	return entry;
1171
+ }
1172
+ 
1173
+ void set_curbuffy(char buf[LONG_STRING])
1174
+ {
1175
+   BUFFY* tmp = CurBuffy = Incoming;
1176
+ 
1177
+   if (!Incoming)
1178
+     return;
1179
+ 
1180
+   while(1) {
1181
+     if(!strcmp(tmp->path, buf)) {
1182
+       CurBuffy = tmp;
1183
+       break;
1184
+     }
1185
+ 
1186
+     if(tmp->next)
1187
+       tmp = tmp->next;
1188
+     else
1189
+       break;
1190
+   }
1191
+ }
1192
+ 
1193
+ int draw_sidebar(int menu) {
1194
+ 
1195
+ 	int lines = option(OPTHELP) ? 1 : 0;
1196
+ 	BUFFY *tmp;
1197
+ #ifndef USE_SLANG_CURSES
1198
+         attr_t attrs;
1199
+ #endif
1200
+         short delim_len = strlen(SidebarDelim);
1201
+         short color_pair;
1202
+ 
1203
+         static bool initialized = false;
1204
+         static int prev_show_value;
1205
+         static short saveSidebarWidth;
1206
+ 
1207
+         /* initialize first time */
1208
+         if(!initialized) {
1209
+                 prev_show_value = option(OPTSIDEBAR);
1210
+                 saveSidebarWidth = SidebarWidth;
1211
+                 if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1212
+                 initialized = true;
1213
+         }
1214
+ 
1215
+         /* save or restore the value SidebarWidth */
1216
+         if(prev_show_value != option(OPTSIDEBAR)) {
1217
+                 if(prev_show_value && !option(OPTSIDEBAR)) {
1218
+                         saveSidebarWidth = SidebarWidth;
1219
+                         SidebarWidth = 0;
1220
+                 } else if(!prev_show_value && option(OPTSIDEBAR)) {
1221
+                         SidebarWidth = saveSidebarWidth;
1222
+                 }
1223
+                 prev_show_value = option(OPTSIDEBAR);
1224
+         }
1225
+ 
1226
+ 
1227
+ //	if ( SidebarWidth == 0 ) return 0;
1228
+        if (SidebarWidth > 0 && option (OPTSIDEBAR)
1229
+            && delim_len >= SidebarWidth) {
1230
+          unset_option (OPTSIDEBAR);
1231
+          /* saveSidebarWidth = SidebarWidth; */
1232
+          if (saveSidebarWidth > delim_len) {
1233
+            SidebarWidth = saveSidebarWidth;
1234
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1235
+            sleep (2);
1236
+          } else {
1102
+          } else {
1237
+            SidebarWidth = 0;
1103
+              sprintf(
1238
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1104
+                      entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1239
+            sleep (4); /* the advise to set a sane value should be seen long enough */
1105
+                      "% d(%d)", size, new);
1240
+          }
1106
+          }
1241
+          saveSidebarWidth = 0;
1107
+        } else if (flagged > 0) {
1242
+          return (0);
1108
+              sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1109
+        } else {
1110
+              sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1243
+        }
1111
+        }
1244
+ 
1112
+	return entry;
1245
+     if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1113
+}
1246
+       if (SidebarWidth > 0) {
1114
+
1247
+         saveSidebarWidth = SidebarWidth;
1115
+void set_curbuffy(char buf[LONG_STRING])
1248
+         SidebarWidth = 0;
1116
+{
1249
+       }
1117
+  BUFFY* tmp = CurBuffy = Incoming;
1250
+       unset_option(OPTSIDEBAR);
1118
+
1251
+       return 0;
1119
+  if (!Incoming)
1252
+     }
1120
+    return;
1253
+ 
1121
+
1254
+         /* get attributes for divider */
1122
+  while(1) {
1255
+ 	SETCOLOR(MT_COLOR_STATUS);
1123
+    if(!strcmp(tmp->path, buf)) {
1256
+ #ifndef USE_SLANG_CURSES
1124
+      CurBuffy = tmp;
1257
+         attr_get(&attrs, &color_pair, 0);
1125
+      break;
1258
+ #else
1126
+    }
1259
+         color_pair = attr_get();
1127
+
1260
+ #endif
1128
+    if(tmp->next)
1261
+ 	SETCOLOR(MT_COLOR_NORMAL);
1129
+      tmp = tmp->next;
1262
+ 
1130
+    else
1263
+ 	/* draw the divider */
1131
+      break;
1264
+ 
1132
+  }
1265
+ 	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1133
+}
1266
+ 		move(lines, SidebarWidth - delim_len);
1134
+
1267
+ 		addstr(NONULL(SidebarDelim));
1135
+int draw_sidebar(int menu) {
1268
+ #ifndef USE_SLANG_CURSES
1136
+
1269
+                 mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1137
+	int lines = option(OPTHELP) ? 1 : 0;
1270
+ #endif
1138
+	BUFFY *tmp;
1271
+ 	}
1139
+#ifndef USE_SLANG_CURSES
1272
+ 
1140
+        attr_t attrs;
1273
+ 	if ( Incoming == 0 ) return 0;
1141
+#endif
1274
+ 	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1142
+        short delim_len = strlen(SidebarDelim);
1275
+ 
1143
+        short color_pair;
1276
+ 	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1144
+
1277
+ 		calc_boundaries(menu);
1145
+        static bool initialized = false;
1278
+ 	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1146
+        static int prev_show_value;
1279
+ 
1147
+        static short saveSidebarWidth;
1280
+ 	tmp = TopBuffy;
1148
+
1281
+ 
1149
+        /* initialize first time */
1282
+ 	SETCOLOR(MT_COLOR_NORMAL);
1150
+        if(!initialized) {
1283
+ 
1151
+                prev_show_value = option(OPTSIDEBAR);
1284
+ 	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1152
+                saveSidebarWidth = SidebarWidth;
1285
+ 		if ( tmp == CurBuffy )
1153
+                if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1286
+ 			SETCOLOR(MT_COLOR_INDICATOR);
1154
+                initialized = true;
1287
+ 		else if ( tmp->msg_unread > 0 )
1155
+        }
1288
+ 			SETCOLOR(MT_COLOR_NEW);
1156
+
1289
+ 		else if ( tmp->msg_flagged > 0 )
1157
+        /* save or restore the value SidebarWidth */
1290
+ 		        SETCOLOR(MT_COLOR_FLAGGED);
1158
+        if(prev_show_value != option(OPTSIDEBAR)) {
1291
+ 		else
1159
+                if(prev_show_value && !option(OPTSIDEBAR)) {
1292
+ 			SETCOLOR(MT_COLOR_NORMAL);
1160
+                        saveSidebarWidth = SidebarWidth;
1293
+ 
1161
+                        SidebarWidth = 0;
1294
+ 		move( lines, 0 );
1162
+                } else if(!prev_show_value && option(OPTSIDEBAR)) {
1295
+ 		if ( Context && !strcmp( tmp->path, Context->path ) ) {
1163
+                        SidebarWidth = saveSidebarWidth;
1296
+ 			tmp->msg_unread = Context->unread;
1164
+                }
1297
+ 			tmp->msgcount = Context->msgcount;
1165
+                prev_show_value = option(OPTSIDEBAR);
1298
+ 			tmp->msg_flagged = Context->flagged;
1166
+        }
1299
+ 		}
1167
+
1300
+ 		// check whether Maildir is a prefix of the current folder's path
1168
+
1301
+ 		short maildir_is_prefix = 0;
1169
+//	if ( SidebarWidth == 0 ) return 0;
1302
+ 		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1170
+       if (SidebarWidth > 0 && option (OPTSIDEBAR)
1303
+ 			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1171
+           && delim_len >= SidebarWidth) {
1304
+         		maildir_is_prefix = 1;
1172
+         unset_option (OPTSIDEBAR);
1305
+ 		// calculate depth of current folder and generate its display name with indented spaces
1173
+         /* saveSidebarWidth = SidebarWidth; */
1306
+ 		int sidebar_folder_depth = 0;
1174
+         if (saveSidebarWidth > delim_len) {
1307
+ 		char *sidebar_folder_name;
1175
+           SidebarWidth = saveSidebarWidth;
1308
+ 		sidebar_folder_name = basename(tmp->path);
1176
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1309
+ 		if ( maildir_is_prefix ) {
1177
+           sleep (2);
1310
+ 			char *tmp_folder_name;
1178
+         } else {
1311
+ 			int i;
1179
+           SidebarWidth = 0;
1312
+ 			tmp_folder_name = tmp->path + strlen(Maildir);
1180
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1313
+ 			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1181
+           sleep (4); /* the advise to set a sane value should be seen long enough */
1314
+ 				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1315
+ 			}   
1316
+ 			if (sidebar_folder_depth > 0) {
1317
+ 				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1318
+ 				for (i=0; i < sidebar_folder_depth; i++)
1319
+ 					sidebar_folder_name[i]=' ';
1320
+ 				sidebar_folder_name[i]=0;
1321
+ 				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1322
+ 			}
1323
+ 		}
1324
+ 		printw( "%.*s", SidebarWidth - delim_len + 1,
1325
+ 			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1326
+ 			tmp->msg_unread, tmp->msg_flagged));
1327
+ 		if (sidebar_folder_depth > 0)
1328
+ 		        free(sidebar_folder_name);
1329
+ 		lines++;
1330
+ 	}
1331
+ 	SETCOLOR(MT_COLOR_NORMAL);
1332
+ 	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1333
+ 		int i = 0;
1334
+ 		move( lines, 0 );
1335
+ 		for ( ; i < SidebarWidth - delim_len; i++ )
1336
+ 			addch(' ');
1337
+ 	}
1338
+ 	return 0;
1339
+ }
1340
+ 
1341
+ 
1342
+ void set_buffystats(CONTEXT* Context)
1343
+ {
1344
+         BUFFY *tmp = Incoming;
1345
+         while(tmp) {
1346
+                 if(Context && !strcmp(tmp->path, Context->path)) {
1347
+ 			tmp->msg_unread = Context->unread;
1348
+ 			tmp->msgcount = Context->msgcount;
1349
+                         break;
1350
+                 }
1351
+                 tmp = tmp->next;
1352
+         }
1182
+         }
1353
+ }
1183
+         saveSidebarWidth = 0;
1354
+ 
1184
+         return (0);
1355
+ void scroll_sidebar(int op, int menu)
1185
+       }
1356
+ {
1186
+
1357
+         if(!SidebarWidth) return;
1187
+    if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1358
+         if(!CurBuffy) return;
1188
+      if (SidebarWidth > 0) {
1359
+ 
1189
+        saveSidebarWidth = SidebarWidth;
1360
+ 	switch (op) {
1190
+        SidebarWidth = 0;
1361
+ 		case OP_SIDEBAR_NEXT:
1191
+      }
1362
+ 			if ( CurBuffy->next == NULL ) return;
1192
+      unset_option(OPTSIDEBAR);
1363
+ 			CurBuffy = CurBuffy->next;
1193
+      return 0;
1364
+ 			break;
1194
+    }
1365
+ 		case OP_SIDEBAR_PREV:
1195
+
1366
+ 			if ( CurBuffy->prev == NULL ) return;
1196
+        /* get attributes for divider */
1367
+ 			CurBuffy = CurBuffy->prev;
1197
+	SETCOLOR(MT_COLOR_STATUS);
1368
+ 			break;
1198
+#ifndef USE_SLANG_CURSES
1369
+ 		case OP_SIDEBAR_SCROLL_UP:
1199
+        attr_get(&attrs, &color_pair, 0);
1370
+ 			CurBuffy = TopBuffy;
1200
+#else
1371
+ 			if ( CurBuffy != Incoming ) {
1201
+        color_pair = attr_get();
1372
+ 				calc_boundaries(menu);
1202
+#endif
1373
+ 				CurBuffy = CurBuffy->prev;
1203
+	SETCOLOR(MT_COLOR_NORMAL);
1374
+ 			}
1204
+
1375
+ 			break;
1205
+	/* draw the divider */
1376
+ 		case OP_SIDEBAR_SCROLL_DOWN:
1206
+
1377
+ 			CurBuffy = BottomBuffy;
1207
+	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1378
+ 			if ( CurBuffy->next ) {
1208
+		move(lines, SidebarWidth - delim_len);
1379
+ 				calc_boundaries(menu);
1209
+		addstr(NONULL(SidebarDelim));
1380
+ 				CurBuffy = CurBuffy->next;
1210
+#ifndef USE_SLANG_CURSES
1381
+ 			}
1211
+                mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1382
+ 			break;
1212
+#endif
1383
+ 		default:
1213
+	}
1384
+ 			return;
1214
+
1385
+ 	}
1215
+	if ( Incoming == 0 ) return 0;
1386
+ 	calc_boundaries(menu);
1216
+	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1387
+ 	draw_sidebar(menu);
1217
+
1388
+ }
1218
+	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1389
+ 
1219
+		calc_boundaries(menu);
1390
*** mutt-1.5.20-orig/sidebar.h	1969-12-31 18:00:00.000000000 -0600
1220
+	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1391
--- mutt-1.5.20-patched/sidebar.h	2009-06-19 22:07:04.000000000 -0500
1221
+
1392
***************
1222
+	tmp = TopBuffy;
1393
*** 0 ****
1223
+
1394
--- 1,36 ----
1224
+	SETCOLOR(MT_COLOR_NORMAL);
1395
+ /*
1225
+
1396
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1226
+	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1397
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1227
+		if ( tmp == CurBuffy )
1398
+  * 
1228
+			SETCOLOR(MT_COLOR_INDICATOR);
1399
+  *     This program is free software; you can redistribute it and/or modify
1229
+		else if ( tmp->msg_unread > 0 )
1400
+  *     it under the terms of the GNU General Public License as published by
1230
+			SETCOLOR(MT_COLOR_NEW);
1401
+  *     the Free Software Foundation; either version 2 of the License, or
1231
+		else if ( tmp->msg_flagged > 0 )
1402
+  *     (at your option) any later version.
1232
+		        SETCOLOR(MT_COLOR_FLAGGED);
1403
+  * 
1233
+		else
1404
+  *     This program is distributed in the hope that it will be useful,
1234
+			SETCOLOR(MT_COLOR_NORMAL);
1405
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1235
+
1406
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1236
+		move( lines, 0 );
1407
+  *     GNU General Public License for more details.
1237
+		if ( Context && !strcmp( tmp->path, Context->path ) ) {
1408
+  * 
1238
+			tmp->msg_unread = Context->unread;
1409
+  *     You should have received a copy of the GNU General Public License
1239
+			tmp->msgcount = Context->msgcount;
1410
+  *     along with this program; if not, write to the Free Software
1240
+			tmp->msg_flagged = Context->flagged;
1411
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1241
+		}
1412
+  */ 
1242
+		// check whether Maildir is a prefix of the current folder's path
1413
+ 
1243
+		short maildir_is_prefix = 0;
1414
+ #ifndef SIDEBAR_H
1244
+		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1415
+ #define SIDEBAR_H
1245
+			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1416
+ 
1246
+        		maildir_is_prefix = 1;
1417
+ struct MBOX_LIST {
1247
+		// calculate depth of current folder and generate its display name with indented spaces
1418
+ 	char *path;
1248
+		int sidebar_folder_depth = 0;
1419
+ 	int msgcount;
1249
+		char *sidebar_folder_name;
1420
+ 	int new;
1250
+		sidebar_folder_name = basename(tmp->path);
1421
+ } MBLIST;
1251
+		if ( maildir_is_prefix ) {
1422
+ 
1252
+			char *tmp_folder_name;
1423
+ /* parameter is whether or not to go to the status line */
1253
+			int i;
1424
+ /* used for omitting the last | that covers up the status bar in the index */
1254
+			tmp_folder_name = tmp->path + strlen(Maildir);
1425
+ int draw_sidebar(int);
1255
+			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1426
+ void scroll_sidebar(int, int);
1256
+				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1427
+ void set_curbuffy(char*);
1257
+			}   
1428
+ void set_buffystats(CONTEXT*);
1258
+			if (sidebar_folder_depth > 0) {
1429
+ 
1259
+				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1430
+ #endif /* SIDEBAR_H */
1260
+				for (i=0; i < sidebar_folder_depth; i++)
1261
+					sidebar_folder_name[i]=' ';
1262
+				sidebar_folder_name[i]=0;
1263
+				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1264
+			}
1265
+		}
1266
+		printw( "%.*s", SidebarWidth - delim_len + 1,
1267
+			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1268
+			tmp->msg_unread, tmp->msg_flagged));
1269
+		if (sidebar_folder_depth > 0)
1270
+		        free(sidebar_folder_name);
1271
+		lines++;
1272
+	}
1273
+	SETCOLOR(MT_COLOR_NORMAL);
1274
+	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1275
+		int i = 0;
1276
+		move( lines, 0 );
1277
+		for ( ; i < SidebarWidth - delim_len; i++ )
1278
+			addch(' ');
1279
+	}
1280
+	return 0;
1281
+}
1282
+
1283
+
1284
+void set_buffystats(CONTEXT* Context)
1285
+{
1286
+        BUFFY *tmp = Incoming;
1287
+        while(tmp) {
1288
+                if(Context && !strcmp(tmp->path, Context->path)) {
1289
+			tmp->msg_unread = Context->unread;
1290
+			tmp->msgcount = Context->msgcount;
1291
+                        break;
1292
+                }
1293
+                tmp = tmp->next;
1294
+        }
1295
+}
1296
+
1297
+void scroll_sidebar(int op, int menu)
1298
+{
1299
+        if(!SidebarWidth) return;
1300
+        if(!CurBuffy) return;
1301
+
1302
+	switch (op) {
1303
+		case OP_SIDEBAR_NEXT:
1304
+			if ( CurBuffy->next == NULL ) return;
1305
+			CurBuffy = CurBuffy->next;
1306
+			break;
1307
+		case OP_SIDEBAR_PREV:
1308
+			if ( CurBuffy->prev == NULL ) return;
1309
+			CurBuffy = CurBuffy->prev;
1310
+			break;
1311
+		case OP_SIDEBAR_SCROLL_UP:
1312
+			CurBuffy = TopBuffy;
1313
+			if ( CurBuffy != Incoming ) {
1314
+				calc_boundaries(menu);
1315
+				CurBuffy = CurBuffy->prev;
1316
+			}
1317
+			break;
1318
+		case OP_SIDEBAR_SCROLL_DOWN:
1319
+			CurBuffy = BottomBuffy;
1320
+			if ( CurBuffy->next ) {
1321
+				calc_boundaries(menu);
1322
+				CurBuffy = CurBuffy->next;
1323
+			}
1324
+			break;
1325
+		default:
1326
+			return;
1327
+	}
1328
+	calc_boundaries(menu);
1329
+	draw_sidebar(menu);
1330
+}
1331
+
1332
diff -uNp -r mutt-1.5.22.orig/sidebar.h mutt-1.5.22/sidebar.h
1333
--- mutt-1.5.22.orig/sidebar.h	Thu Jan  1 01:00:00 1970
1334
+++ mutt-1.5.22/sidebar.h	Fri Oct 18 10:18:45 2013
1335
@@ -0,0 +1,36 @@
1336
+/*
1337
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1338
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1339
+ * 
1340
+ *     This program is free software; you can redistribute it and/or modify
1341
+ *     it under the terms of the GNU General Public License as published by
1342
+ *     the Free Software Foundation; either version 2 of the License, or
1343
+ *     (at your option) any later version.
1344
+ * 
1345
+ *     This program is distributed in the hope that it will be useful,
1346
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1347
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1348
+ *     GNU General Public License for more details.
1349
+ * 
1350
+ *     You should have received a copy of the GNU General Public License
1351
+ *     along with this program; if not, write to the Free Software
1352
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1353
+ */ 
1354
+
1355
+#ifndef SIDEBAR_H
1356
+#define SIDEBAR_H
1357
+
1358
+struct MBOX_LIST {
1359
+	char *path;
1360
+	int msgcount;
1361
+	int new;
1362
+} MBLIST;
1363
+
1364
+/* parameter is whether or not to go to the status line */
1365
+/* used for omitting the last | that covers up the status bar in the index */
1366
+int draw_sidebar(int);
1367
+void scroll_sidebar(int, int);
1368
+void set_curbuffy(char*);
1369
+void set_buffystats(CONTEXT*);
1370
+
1371
+#endif /* SIDEBAR_H */
1372
--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
1373
+++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
1374
@@ -34,7 +34,7 @@
1375
 	score.c send.c sendlib.c signal.c sort.c \
1376
 	status.c system.c thread.c charset.c history.c lib.c \
1377
 	muttlib.c editmsg.c mbyte.c \
1378
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1379
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
1380
 
1381
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
1382
 
1383
--- orig/Makefile.in.orig	2013-10-25 08:23:07.000000000 +0200
1384
+++ new/Makefile.in	2013-10-25 08:26:20.000000000 +0200
1385
@@ -133,7 +133,7 @@
1386
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
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
1431
*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
1412
*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
1432
--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
1413
--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
1433
***************
1414
***************
Lines 1459-1603 Link Here
1459
  # set crypt_autosign=no
1440
  # set crypt_autosign=no
1460
  #
1441
  #
1461
  # Name: crypt_autosign
1442
  # Name: crypt_autosign
1462
*** mutt-1.5.20-orig/imap/imap.c	2009-06-14 12:19:16.000000000 -0500
1463
--- mutt-1.5.20-patched/imap/imap.c	2009-06-19 22:07:04.000000000 -0500
1464
***************
1465
*** 1521,1527 ****
1466
  
1467
      imap_munge_mbox_name (munged, sizeof (munged), name);
1468
      snprintf (command, sizeof (command),
1469
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
1470
  
1471
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
1472
      {
1473
--- 1521,1527 ----
1474
  
1475
      imap_munge_mbox_name (munged, sizeof (munged), name);
1476
      snprintf (command, sizeof (command),
1477
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
1478
  
1479
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
1480
      {
1481
*** mutt-1.5.20-orig/imap/command.c	2009-01-05 20:58:31.000000000 -0600
1482
--- mutt-1.5.20-patched/imap/command.c	2009-06-19 22:07:04.000000000 -0500
1483
***************
1484
*** 1009,1014 ****
1485
--- 1009,1021 ----
1486
  	     opened */
1487
  	  status->uidnext = oldun;
1488
  
1489
+         /* Added to make the sidebar show the correct numbers */
1490
+         if (status->messages)
1491
+         {
1492
+           inc->msgcount = status->messages;
1493
+           inc->msg_unread = status->unseen;
1494
+         }
1495
+ 
1496
          FREE (&value);
1497
          return;
1498
        }
1499
--- orig/compose.c.orig	2010-04-14 20:50:19.000000000 +0200
1500
+++ new/compose.c	2010-09-18 15:29:09.000000000 +0200
1501
@@ -72,7 +72,7 @@
1502
 
1503
 #define HDR_XOFFSET 10
1504
 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1505
-#define W (COLS - HDR_XOFFSET)
1506
+#define W (COLS - HDR_XOFFSET - SidebarWidth)
1507
 
1508
 static char *Prompts[] =
1509
 {
1510
@@ -112,7 +112,7 @@
1511
 {
1512
   int off = 0;
1513
 
1514
-  mvaddstr (HDR_CRYPT, 0, "Security: ");
1515
+  mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
1516
 
1517
   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
1518
   {
1519
@@ -144,7 +144,7 @@
1520
   }
1521
 
1522
   clrtoeol ();
1523
-  move (HDR_CRYPTINFO, 0);
1524
+  move (HDR_CRYPTINFO, SidebarWidth);
1525
   clrtoeol ();
1526
 
1527
   if ((WithCrypto & APPLICATION_PGP)
1528
@@ -161,7 +161,7 @@
1529
       && (msg->security & ENCRYPT)
1530
       && SmimeCryptAlg
1531
       && *SmimeCryptAlg) {
1532
-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
1533
+      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
1534
 		NONULL(SmimeCryptAlg));
1535
       off = 20;
1536
   }
1537
@@ -190,7 +190,7 @@
1538
     if (t && t[0] == '0' && t[1] == '\0')
1539
       t = "<random>";
1540
     
1541
-    if (c + mutt_strlen (t) + 2 >= COLS)
1542
+    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
1543
       break;
1544
 
1545
     addstr (NONULL(t));
1546
@@ -242,7 +242,7 @@
1547
 
1548
   buf[0] = 0;
1549
   rfc822_write_address (buf, sizeof (buf), addr, 1);
1550
-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
1551
+  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
1552
   mutt_paddstr (W, buf);
1553
 }
1554
 
1555
@@ -252,10 +252,10 @@
1556
   draw_envelope_addr (HDR_TO, msg->env->to);
1557
   draw_envelope_addr (HDR_CC, msg->env->cc);
1558
   draw_envelope_addr (HDR_BCC, msg->env->bcc);
1559
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1560
+  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1561
   mutt_paddstr (W, NONULL (msg->env->subject));
1562
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1563
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
1564
+  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
1565
   mutt_paddstr (W, fcc);
1566
 
1567
   if (WithCrypto)
1568
@@ -266,7 +266,7 @@
1569
 #endif
1570
 
1571
   SETCOLOR (MT_COLOR_STATUS);
1572
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
1573
+  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
1574
   BKGDSET (MT_COLOR_STATUS);
1575
   clrtoeol ();
1576
 
1577
@@ -304,7 +304,7 @@
1578
   /* redraw the expanded list so the user can see the result */
1579
   buf[0] = 0;
1580
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
1581
-  move (line, HDR_XOFFSET);
1582
+  move (line, HDR_XOFFSET+SidebarWidth);
1583
   mutt_paddstr (W, buf);
1584
   
1585
   return 0;
1586
@@ -549,7 +549,7 @@
1587
 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
1588
 	{
1589
 	  mutt_str_replace (&msg->env->subject, buf);
1590
-	  move (HDR_SUBJECT, HDR_XOFFSET);
1591
+	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
1592
 	  clrtoeol ();
1593
 	  if (msg->env->subject)
1594
 	    mutt_paddstr (W, msg->env->subject);
1595
@@ -566,7 +566,7 @@
1596
 	{
1597
 	  strfcpy (fcc, buf, fcclen);
1598
 	  mutt_pretty_mailbox (fcc, fcclen);
1599
-	  move (HDR_FCC, HDR_XOFFSET);
1600
+	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
1601
 	  mutt_paddstr (W, fcc);
1602
 	  fccSet = 1;
1603
 	}
(-)./files/extra-patch-sidebar-nntp (-1421 / +1261 lines)
Lines 1-6 Link Here
1
--- orig/buffy.c.orig	2010-09-18 14:12:40.000000000 +0200
1
Based on Gentoo's updated version of the Mutt Sidebar patch,
2
+++ new/buffy.c	2010-09-18 14:17:36.000000000 +0200
2
rebased to apply to pristine Mutt sources.
3
@@ -161,6 +161,49 @@
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
24
--- mutt-1.5.22.orig/buffy.c	Mon Apr 22 07:14:53 2013
25
+++ mutt-1.5.22/buffy.c	Fri Oct 18 10:18:45 2013
26
@@ -161,6 +161,49 @@ void mutt_buffy_cleanup (const char *buf, struct stat 
4
   }
27
   }
5
 }
28
 }
6
 
29
 
Lines 50-56 Link Here
50
 BUFFY *mutt_find_mailbox (const char *path)
73
 BUFFY *mutt_find_mailbox (const char *path)
51
 {
74
 {
52
   BUFFY *tmp = NULL;
75
   BUFFY *tmp = NULL;
53
@@ -282,6 +325,7 @@
76
@@ -282,6 +325,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, uns
54
     else
77
     else
55
       (*tmp)->size = 0;
78
       (*tmp)->size = 0;
56
   }
79
   }
Lines 58-941 Link Here
58
   return 0;
81
   return 0;
59
 }
82
 }
60
 
83
 
61
@@ -371,12 +415,17 @@
84
@@ -340,6 +384,68 @@ static int buffy_maildir_hasnew (BUFFY* mailbox)
62
   return rc;
85
   return rc;
63
 }
86
 }
64
 
87
 
65
+#define STAT_CHECK_SIZE (sb.st_size > tmp->size)
88
+/* update message counts for the sidebar */
66
+#define STAT_CHECK_TIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
89
+void buffy_maildir_update (BUFFY* mailbox)
67
+#define STAT_CHECK (option(OPTCHECKMBOXSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_TIME)
90
+{
91
+  char path[_POSIX_PATH_MAX];
92
+  DIR *dirp;
93
+  struct dirent *de;
94
+  char *p;
95
+
96
+  mailbox->msgcount = 0;
97
+  mailbox->msg_unread = 0;
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
+}
68
+
170
+
69
 int mutt_buffy_check (int force)
171
 int mutt_buffy_check (int force)
70
 {
172
 {
71
   BUFFY *tmp;
173
   BUFFY *tmp;
72
   struct stat sb;
174
@@ -444,16 +564,19 @@ int mutt_buffy_check (int force)
73
   struct stat contex_sb;
74
   time_t t;
75
+  CONTEXT *ctx;
76
 
77
   sb.st_size=0;
78
   contex_sb.st_dev=0;
79
@@ -416,6 +465,8 @@
80
   
81
   for (tmp = Incoming; tmp; tmp = tmp->next)
82
   {
83
+    if ( tmp->new == 1 )
84
+       tmp->has_new = 1;
85
     if (tmp->magic != M_IMAP)
86
     {
87
       tmp->new = 0;
88
@@ -455,18 +506,122 @@
89
       {
175
       {
90
       case M_MBOX:
176
       case M_MBOX:
91
       case M_MMDF:
177
       case M_MMDF:
92
-	if (buffy_mbox_hasnew (tmp, &sb) > 0)
178
+	buffy_mbox_update (tmp);
93
-	  BuffyCount++;
179
 	if (buffy_mbox_hasnew (tmp, &sb) > 0)
94
-	break;
180
 	  BuffyCount++;
95
+        {
181
 	break;
96
+          if (STAT_CHECK || tmp->msgcount == 0)
97
+          {
98
+            BUFFY b = *tmp;
99
+            int msgcount = 0;
100
+            int msg_unread = 0;
101
+            /* parse the mailbox, to see how much mail there is */
102
+            ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
103
+            if(ctx)
104
+            {
105
+              msgcount = ctx->msgcount;
106
+              msg_unread = ctx->unread;
107
+              mx_close_mailbox(ctx, 0);
108
+            }
109
+            *tmp = b;
110
+            tmp->msgcount = msgcount;
111
+            tmp->msg_unread = msg_unread;
112
+            if(STAT_CHECK) {
113
+              tmp->has_new = tmp->new = 1;
114
+              BuffyCount++;
115
+            }
116
+          }
117
+          else if (option(OPTCHECKMBOXSIZE))
118
+          {
119
+            /* some other program has deleted mail from the folder */
120
+            tmp->size = (off_t) sb.st_size;
121
+          }
122
+          if (tmp->newly_created &&
123
+              (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
124
+            tmp->newly_created = 0;
125
+        }
126
+        break;
127
+
128
 
182
 
129
       case M_MAILDIR:
183
       case M_MAILDIR:
130
-	if (buffy_maildir_hasnew (tmp) > 0)
184
+	buffy_maildir_update (tmp);
131
-	  BuffyCount++;
185
 	if (buffy_maildir_hasnew (tmp) > 0)
132
+        { 
186
 	  BuffyCount++;
133
+        char path[_POSIX_PATH_MAX];
134
+        DIR *dirp;
135
+        struct dirent *de;
136
+        /* count new message */
137
+        snprintf (path, sizeof (path), "%s/new", tmp->path);
138
+        if ((dirp = opendir (path)) == NULL)
139
+        {
140
+          tmp->magic = 0;
141
+          break;
142
+        }
143
+        tmp->msgcount = 0;
144
+        tmp->msg_unread = 0;
145
+        tmp->msg_flagged = 0;
146
+        while ((de = readdir (dirp)) != NULL)
147
+        {
148
+          char *p;
149
+          if (*de->d_name != '.' &&
150
+              (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
151
+          {
152
+            tmp->has_new = tmp->new = 1;
153
+            tmp->msgcount++;
154
+            tmp->msg_unread++;
155
+          }
156
+        }
157
+        if(tmp->msg_unread)
158
+          BuffyCount++;
159
+
160
+        closedir (dirp);
161
+
162
+        /*
163
+         * count read messages (for folderlist (sidebar) we also need to count
164
+         * messages in cur so that we the total number of messages
165
+         */
166
+        snprintf (path, sizeof (path), "%s/cur", tmp->path);
167
+        if ((dirp = opendir (path)) == NULL)
168
+        {
169
+          tmp->magic = 0;
170
+          break;
171
+        }
172
+        while ((de = readdir (dirp)) != NULL)
173
+        {
174
+          char *p;
175
+          if (*de->d_name != '.') {
176
+                  if ((p = strstr (de->d_name, ":2,"))) {
177
+                          if (!strchr (p + 3, 'T')) {
178
+                                  tmp->msgcount++;
179
+                                  if ( !strchr (p + 3, 'S'))
180
+                                          tmp->msg_unread++;
181
+                                  if (strchr(p + 3, 'F'))
182
+                                          tmp->msg_flagged++;
183
+                          }
184
+                  } else
185
+                          tmp->msgcount++;
186
+          }
187
+        }
188
+        closedir (dirp);
189
+        } 
190
 	break;
187
 	break;
191
 
188
 
192
       case M_MH:
189
       case M_MH:
193
-	if ((tmp->new = mh_buffy (tmp->path)) > 0)
190
+	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged);
194
-	  BuffyCount++;
191
 	mh_buffy(tmp);
195
+        {
192
 	if (tmp->new)
196
+        DIR *dp;
193
 	  BuffyCount++;
197
+        char path[_POSIX_PATH_MAX];
194
diff -uNp -r mutt-1.5.22.orig/buffy.h mutt-1.5.22/buffy.h
198
+        struct dirent *de;
195
--- mutt-1.5.22.orig/buffy.h	Mon Apr 22 07:14:53 2013
199
+        if ((tmp->new = mh_buffy (tmp->path)) > 0)
196
+++ mutt-1.5.22/buffy.h	Fri Oct 18 10:18:45 2013
200
+          BuffyCount++;
197
@@ -25,7 +25,11 @@ typedef struct buffy_t
201
+
198
   char path[_POSIX_PATH_MAX];
202
+        if ((dp = opendir (path)) == NULL)
199
   off_t size;
203
+          break;
200
   struct buffy_t *next;
204
+        tmp->msgcount = 0;
201
+  struct buffy_t *prev;
205
+        while ((de = readdir (dp)))
202
   short new;			/* mailbox has new mail */
206
+        {
203
+  int msgcount;			/* total number of messages */
207
+          if (mh_valid_message (de->d_name))
204
+  int msg_unread;		/* number of unread messages */
208
+          {
205
+  int msg_flagged;		/* number of flagged messages */
209
+            tmp->msgcount++;
206
   short notified;		/* user has been notified */
210
+            tmp->has_new = tmp->new = 1;
207
   short magic;			/* mailbox type */
211
+          }
208
   short newly_created;		/* mbox or mmdf just popped into existence */
212
+        }
209
diff -uNp -r mutt-1.5.22.orig/color.c mutt-1.5.22/color.c
213
+        closedir (dp);
210
--- mutt-1.5.22.orig/color.c	Tue Jan 15 07:37:15 2013
214
+        }
211
+++ mutt-1.5.22/color.c	Fri Oct 18 10:19:53 2013
215
 	break;
212
@@ -93,6 +93,8 @@ static const struct mapping_t Fields[] =
216
       }
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.orig	2013-10-25 08:31:26.000000000 +0200
223
+++ mutt-1.5.22/compose.c	2013-10-25 08:44:32.000000000 +0200
224
@@ -83,7 +83,7 @@
225
 
226
 #define HDR_XOFFSET 14
227
 #define TITLE_FMT "%14s" /* 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
@@ -144,7 +144,7 @@
234
 
235
 static void redraw_crypt_lines (HEADER *msg)
236
 {
237
-  mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: ");
238
+  mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
239
 
240
   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
241
   {
242
@@ -176,7 +176,7 @@
243
   }
244
 
245
   clrtoeol ();
246
-  move (HDR_CRYPTINFO, 0);
247
+  move (HDR_CRYPTINFO, SidebarWidth);
248
   clrtoeol ();
249
 
250
   if ((WithCrypto & APPLICATION_PGP)
251
@@ -194,7 +194,7 @@
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
@@ -207,7 +207,7 @@
261
   int c;
262
   char *t;
263
 
264
-  mvprintw (HDR_MIX, 0, TITLE_FMT, "Mix: ");
265
+  mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, "Mix: ");
266
 
267
   if (!chain)
268
   {
269
@@ -222,7 +222,7 @@
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
@@ -274,7 +274,7 @@
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
@@ -292,21 +292,21 @@
288
   }
289
   else
290
   {
291
-    mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
292
+    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
293
     mutt_paddstr (W, NONULL (msg->env->newsgroups));
294
-    mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
295
+    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
296
     mutt_paddstr (W, NONULL (msg->env->followup_to));
297
     if (option (OPTXCOMMENTTO))
298
     {
299
-      mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
300
+      mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
301
       mutt_paddstr (W, NONULL (msg->env->x_comment_to));
217
     }
302
     }
218
*** mutt-1.5.20-orig/buffy.h	2009-04-30 00:36:16.000000000 -0500
303
   }
219
--- mutt-1.5.20-patched/buffy.h	2009-06-19 22:07:04.000000000 -0500
304
 #endif
220
***************
305
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
221
*** 25,31 ****
306
+  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
222
--- 25,36 ----
307
   mutt_paddstr (W, NONULL (msg->env->subject));
223
    char path[_POSIX_PATH_MAX];
308
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
224
    off_t size;
309
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
225
    struct buffy_t *next;
310
+  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
226
+   struct buffy_t *prev;
311
   mutt_paddstr (W, fcc);
227
    short new;			/* mailbox has new mail */
312
 
228
+   short has_new;		/* set it new if new and not read */
313
   if (WithCrypto)
229
+   int msgcount;			/* total number of messages */
314
@@ -317,7 +317,7 @@
230
+   int msg_unread;		/* number of unread messages */
315
 #endif
231
+   int msg_flagged;		/* number of flagged messages */
316
 
232
    short notified;		/* user has been notified */
317
   SETCOLOR (MT_COLOR_STATUS);
233
    short magic;			/* mailbox type */
318
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
234
    short newly_created;		/* mbox or mmdf just popped into existence */
319
+  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
235
*** mutt-1.5.20-orig/color.c	2009-05-18 19:11:35.000000000 -0500
320
   clrtoeol ();
236
--- mutt-1.5.20-patched/color.c	2009-06-19 22:07:04.000000000 -0500
321
 
237
***************
322
   NORMAL_COLOR;
238
*** 93,98 ****
323
@@ -353,7 +353,7 @@
239
--- 93,100 ----
324
   /* redraw the expanded list so the user can see the result */
240
    { "bold",		MT_COLOR_BOLD },
325
   buf[0] = 0;
241
    { "underline",	MT_COLOR_UNDERLINE },
326
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
242
    { "index",		MT_COLOR_INDEX },
327
-  move (line, HDR_XOFFSET);
243
+   { "sidebar_new",	MT_COLOR_NEW },
328
+  move (line, HDR_XOFFSET+SidebarWidth);
244
+   { "sidebar_flagged",	MT_COLOR_FLAGGED },
329
   mutt_paddstr (W, buf);
245
    { NULL,		0 }
330
   
246
  };
331
   return 0;
247
  
332
@@ -685,7 +685,7 @@
248
*** mutt-1.5.20-orig/curs_main.c	2009-06-13 21:48:36.000000000 -0500
333
 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
249
--- mutt-1.5.20-patched/curs_main.c	2009-06-19 22:07:04.000000000 -0500
334
 	{
250
***************
335
 	  mutt_str_replace (&msg->env->subject, buf);
251
*** 26,32 ****
336
-	  move (HDR_SUBJECT, HDR_XOFFSET);
252
--- 26,34 ----
337
+	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
253
  #include "mailbox.h"
338
 	  if (msg->env->subject)
254
  #include "mapping.h"
339
 	    mutt_paddstr (W, msg->env->subject);
255
  #include "sort.h"
340
 	  else
256
+ #include "buffy.h"
341
@@ -703,7 +703,7 @@
257
  #include "mx.h"
342
 	{
258
+ #include "sidebar.h"
343
 	  strfcpy (fcc, buf, fcclen);
259
  
344
 	  mutt_pretty_mailbox (fcc, fcclen);
260
  #ifdef USE_POP
345
-	  move (HDR_FCC, HDR_XOFFSET);
261
  #include "pop.h"
346
+	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
262
***************
347
 	  mutt_paddstr (W, fcc);
263
*** 523,530 ****
348
 	  fccSet = 1;
264
         menu->redraw |= REDRAW_STATUS;
349
 	}
265
       if (do_buffy_notify)
350
diff -uNp -r mutt-1.5.22.orig/curs_main.c mutt-1.5.22/curs_main.c
266
       {
351
--- mutt-1.5.22.orig/curs_main.c	Tue Jan 15 07:37:15 2013
267
!        if (mutt_buffy_notify () && option (OPTBEEPNEW))
352
+++ mutt-1.5.22/curs_main.c	Fri Oct 18 10:18:45 2013
268
!  	beep ();
353
@@ -26,7 +26,9 @@
269
       }
354
 #include "mailbox.h"
270
       else
355
 #include "mapping.h"
271
         do_buffy_notify = 1;
356
 #include "sort.h"
272
--- 525,536 ----
357
+#include "buffy.h"
273
         menu->redraw |= REDRAW_STATUS;
358
 #include "mx.h"
274
       if (do_buffy_notify)
359
+#include "sidebar.h"
275
       {
360
 
276
!        if (mutt_buffy_notify ())
361
 #ifdef USE_POP
277
!        {
362
 #include "pop.h"
278
!          menu->redraw |= REDRAW_FULL;
363
@@ -519,8 +521,12 @@ int mutt_index_menu (void)
279
!          if (option (OPTBEEPNEW))
364
        menu->redraw |= REDRAW_STATUS;
280
!            beep ();
365
      if (do_buffy_notify)
281
!        }
282
       }
283
       else
284
         do_buffy_notify = 1;
285
***************
286
*** 536,541 ****
287
--- 542,548 ----
288
      if (menu->redraw & REDRAW_FULL)
289
      {
366
      {
290
        menu_redraw_full (menu);
367
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
291
+       draw_sidebar(menu->menu);
368
- 	beep ();
292
        mutt_show_error ();
369
+       if (mutt_buffy_notify ())
370
+       {
371
+         menu->redraw |= REDRAW_FULL;
372
+         if (option (OPTBEEPNEW))
373
+           beep ();
374
+       }
293
      }
375
      }
294
  
376
      else
295
***************
377
        do_buffy_notify = 1;
296
*** 558,567 ****
378
@@ -532,6 +538,7 @@ int mutt_index_menu (void)
297
--- 565,577 ----
379
     if (menu->redraw & REDRAW_FULL)
298
  
380
     {
299
        if (menu->redraw & REDRAW_STATUS)
381
       menu_redraw_full (menu);
300
        {
382
+      draw_sidebar(menu->menu);
301
+         DrawFullLine = 1;
383
       mutt_show_error ();
302
  	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
384
     }
303
+         DrawFullLine = 0;
385
 
304
  	CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
386
@@ -554,9 +561,12 @@ int mutt_index_menu (void)
305
  	SETCOLOR (MT_COLOR_STATUS);
387
 
306
          BKGDSET (MT_COLOR_STATUS);
388
       if (menu->redraw & REDRAW_STATUS)
307
+         set_buffystats(Context);
389
       {
308
  	mutt_paddstr (COLS, buf);
390
+	DrawFullLine = 1;
309
  	SETCOLOR (MT_COLOR_NORMAL);
391
 	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
310
          BKGDSET (MT_COLOR_NORMAL);
392
+	DrawFullLine = 0;
311
***************
393
 	move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
312
*** 575,581 ****
394
 	SETCOLOR (MT_COLOR_STATUS);
313
  	menu->oldcurrent = -1;
395
+	set_buffystats(Context);
314
  
396
 	mutt_paddstr (COLS, buf);
315
        if (option (OPTARROWCURSOR))
397
 	NORMAL_COLOR;
316
! 	move (menu->current - menu->top + menu->offset, 2);
398
 	menu->redraw &= ~REDRAW_STATUS;
317
        else if (option (OPTBRAILLEFRIENDLY))
399
@@ -569,7 +579,7 @@ int mutt_index_menu (void)
318
  	move (menu->current - menu->top + menu->offset, 0);
400
 	menu->oldcurrent = -1;
319
        else
401
 
320
--- 585,591 ----
402
       if (option (OPTARROWCURSOR))
321
  	menu->oldcurrent = -1;
403
-	move (menu->current - menu->top + menu->offset, 2);
322
  
404
+	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
323
        if (option (OPTARROWCURSOR))
405
       else if (option (OPTBRAILLEFRIENDLY))
324
! 	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
406
 	move (menu->current - menu->top + menu->offset, 0);
325
        else if (option (OPTBRAILLEFRIENDLY))
407
       else
326
  	move (menu->current - menu->top + menu->offset, 0);
408
@@ -1070,6 +1080,7 @@ int mutt_index_menu (void)
327
        else
409
 	  menu->redraw = REDRAW_FULL;
328
***************
410
 	break;
329
*** 1055,1060 ****
411
 
330
--- 1065,1071 ----
412
+      case OP_SIDEBAR_OPEN:
331
  	  menu->redraw = REDRAW_FULL;
413
       case OP_MAIN_CHANGE_FOLDER:
332
  	break;
414
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
333
  
415
 
334
+       case OP_SIDEBAR_OPEN:
416
@@ -1101,7 +1112,11 @@ int mutt_index_menu (void)
335
        case OP_MAIN_CHANGE_FOLDER:
417
 	{
336
        case OP_MAIN_NEXT_UNREAD_MAILBOX:
418
 	  mutt_buffy (buf, sizeof (buf));
337
  
419
 
338
***************
420
-	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
339
*** 1086,1092 ****
421
+          if ( op == OP_SIDEBAR_OPEN ) {
340
  	{
422
+              if(!CurBuffy)
341
  	  mutt_buffy (buf, sizeof (buf));
423
+                break;
342
  
424
+            strncpy( buf, CurBuffy->path, sizeof(buf) );  
343
! 	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
425
+	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
344
  	  {
426
 	  {
345
  	    if (menu->menu == MENU_PAGER)
427
 	    if (menu->menu == MENU_PAGER)
346
  	    {
428
 	    {
347
--- 1097,1107 ----
429
@@ -1119,6 +1134,7 @@ int mutt_index_menu (void)
348
  	{
430
 	}
349
  	  mutt_buffy (buf, sizeof (buf));
431
 
350
  
432
 	mutt_expand_path (buf, sizeof (buf));
351
!           if ( op == OP_SIDEBAR_OPEN ) {
433
+        set_curbuffy(buf);
352
!               if(!CurBuffy)
434
 	if (mx_get_magic (buf) <= 0)
353
!                 break;
435
 	{
354
!             strncpy( buf, CurBuffy->path, sizeof(buf) );  
436
 	  mutt_error (_("%s is not a mailbox."), buf);
355
! 	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
437
@@ -2209,6 +2225,12 @@ int mutt_index_menu (void)
356
  	  {
438
 	mutt_what_key();
357
  	    if (menu->menu == MENU_PAGER)
439
 	break;
358
  	    {
440
 
359
***************
441
+      case OP_SIDEBAR_SCROLL_UP:
360
*** 1104,1109 ****
442
+      case OP_SIDEBAR_SCROLL_DOWN:
361
--- 1119,1125 ----
443
+      case OP_SIDEBAR_NEXT:
362
  	}
444
+      case OP_SIDEBAR_PREV:
363
  
445
+        scroll_sidebar(op, menu->menu);
364
  	mutt_expand_path (buf, sizeof (buf));
446
+        break;
365
+         set_curbuffy(buf);
447
       default:
366
  	if (mx_get_magic (buf) <= 0)
448
 	if (menu->menu == MENU_MAIN)
367
  	{
449
 	  km_error_key (MENU_MAIN);
368
  	  mutt_error (_("%s is not a mailbox."), buf);
450
diff -uNp -r mutt-1.5.22.orig/flags.c mutt-1.5.22/flags.c
369
***************
451
--- mutt-1.5.22.orig/flags.c	Sun Feb 21 22:10:41 2010
370
*** 2183,2188 ****
452
+++ mutt-1.5.22/flags.c	Fri Oct 18 10:18:45 2013
371
--- 2199,2210 ----
453
@@ -22,8 +22,10 @@
372
  	mutt_what_key();
454
 
373
  	break;
455
 #include "mutt.h"
374
  
456
 #include "mutt_curses.h"
375
+       case OP_SIDEBAR_SCROLL_UP:
457
+#include "mutt_menu.h"
376
+       case OP_SIDEBAR_SCROLL_DOWN:
458
 #include "sort.h"
377
+       case OP_SIDEBAR_NEXT:
459
 #include "mx.h"
378
+       case OP_SIDEBAR_PREV:
460
+#include "sidebar.h"
379
+         scroll_sidebar(op, menu->menu);
461
 
380
+         break;
462
 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
381
        default:
463
 {
382
  	if (menu->menu == MENU_MAIN)
464
@@ -263,6 +265,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag
383
  	  km_error_key (MENU_MAIN);
384
*** mutt-1.5.20-orig/flags.c	2008-12-16 21:50:09.000000000 -0600
385
--- mutt-1.5.20-patched/flags.c	2009-06-19 22:07:04.000000000 -0500
386
***************
387
*** 22,29 ****
388
--- 22,31 ----
389
  
390
  #include "mutt.h"
391
  #include "mutt_curses.h"
392
+ #include "mutt_menu.h"
393
  #include "sort.h"
394
  #include "mx.h"
395
+ #include "sidebar.h"
396
  
397
  void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
398
  {
399
***************
400
*** 263,268 ****
401
--- 265,271 ----
402
     */
403
    if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
404
      h->searched = 0;
405
+ 	draw_sidebar(0);
406
  }
407
  
408
  void mutt_tag_set_flag (int flag, int bf)
409
*** mutt-1.5.20-orig/functions.h	2009-04-30 00:36:17.000000000 -0500
410
--- mutt-1.5.20-patched/functions.h	2009-06-19 22:07:04.000000000 -0500
411
***************
412
*** 168,173 ****
413
--- 168,178 ----
414
    { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
415
  
416
  
417
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
418
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
419
+  { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
420
+  { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
421
+  { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
422
    { NULL,			0,				NULL }
423
  };
424
  
425
***************
426
*** 268,273 ****
427
--- 273,283 ----
428
  
429
    { "what-key",		OP_WHAT_KEY,		NULL },
430
  
431
+   { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
432
+   { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
433
+   { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
434
+   { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
435
+   { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
436
    { NULL,		0,				NULL }
437
  };
438
  
439
*** mutt-1.5.20-orig/globals.h	2009-06-03 15:48:31.000000000 -0500
440
--- mutt-1.5.20-patched/globals.h	2009-06-19 22:07:04.000000000 -0500
441
***************
442
*** 117,122 ****
443
--- 117,123 ----
444
  WHERE char *SendCharset;
445
  WHERE char *Sendmail;
446
  WHERE char *Shell;
447
+ WHERE char *SidebarDelim;
448
  WHERE char *Signature;
449
  WHERE char *SimpleSearch;
450
  #if USE_SMTP
451
***************
452
*** 206,211 ****
453
--- 207,215 ----
454
  WHERE short ScoreThresholdRead;
455
  WHERE short ScoreThresholdFlag;
456
  
457
+ WHERE struct buffy_t *CurBuffy INITVAL(0);
458
+ WHERE short DrawFullLine INITVAL(0);
459
+ WHERE short SidebarWidth;
460
  #ifdef USE_IMAP
461
  WHERE short ImapKeepalive;
462
  WHERE short ImapPipelineDepth;
463
*** mutt-1.5.20-orig/init.h	2009-06-13 16:35:21.000000000 -0500
464
--- mutt-1.5.20-patched/init.h	2009-06-19 22:07:04.000000000 -0500
465
***************
466
*** 1941,1946 ****
467
--- 1941,1967 ----
468
    ** not used.
469
    ** (PGP only)
470
    */
465
    */
471
+   {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
466
   if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
472
+   /*
467
     h->searched = 0;
473
+   ** .pp
468
+	draw_sidebar(0);
474
+   ** This specifies the delimiter between the sidebar (if visible) and 
469
 }
475
+   ** other screens.
476
+   */
477
+   { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
478
+   /*
479
+   ** .pp
480
+   ** This specifies whether or not to show sidebar (left-side list of folders).
481
+   */
482
+   { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
483
+   /*
484
+   ** .pp
485
+   ** This specifies whether or not to sort the sidebar alphabetically.
486
+   */
487
+   { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
488
+   /*
489
+   ** .pp
490
+   ** The width of the sidebar.
491
+   */
492
    { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
493
    /*
494
    ** .pp
495
*** mutt-1.5.20-orig/mailbox.h	2009-04-30 00:36:17.000000000 -0500
496
--- mutt-1.5.20-patched/mailbox.h	2009-06-19 22:07:04.000000000 -0500
497
***************
498
*** 27,32 ****
499
--- 27,33 ----
500
  #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
501
  				* safe_fopen() for mbox-style folders.
502
  				*/
503
+ #define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
504
  
505
  /* mx_open_new_message() */
506
  #define M_ADD_FROM	1	/* add a From_ line */
507
--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
508
+++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
509
@@ -34,7 +34,7 @@
510
 	score.c send.c sendlib.c signal.c sort.c \
511
 	status.c system.c thread.c charset.c history.c lib.c \
512
 	muttlib.c editmsg.c mbyte.c \
513
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
514
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
515
 
470
 
516
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
471
 void mutt_tag_set_flag (int flag, int bf)
472
diff -uNp -r mutt-1.5.22.orig/functions.h mutt-1.5.22/functions.h
473
--- mutt-1.5.22.orig/functions.h	Sat Dec  3 19:10:04 2011
474
+++ mutt-1.5.22/functions.h	Fri Oct 18 10:18:45 2013
475
@@ -169,6 +169,11 @@ const struct binding_t OpMain[] = { /* map: index */
476
   { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
477
 
478
 
479
+ { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
480
+ { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
481
+ { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
482
+ { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
483
+ { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
484
   { NULL,			0,				NULL }
485
 };
517
 
486
 
518
--- orig/Makefile.in.orig	2010-09-18 13:23:19.000000000 +0200
487
@@ -272,6 +277,11 @@ const struct binding_t OpPager[] = { /* map: pager */
519
+++ new/Makefile.in	2010-09-18 13:27:19.000000000 +0200
520
@@ -89,7 +89,7 @@
521
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
522
 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
523
 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
524
-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
525
+	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
526
 am__objects_1 =
527
 am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1)
528
 nodist_mutt_OBJECTS = $(am__objects_2)
529
@@ -363,7 +363,7 @@
530
 	score.c send.c sendlib.c signal.c sort.c \
531
 	status.c system.c thread.c charset.c history.c lib.c \
532
 	muttlib.c editmsg.c mbyte.c \
533
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
534
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
535
 
488
 
536
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
489
   { "what-key",		OP_WHAT_KEY,		NULL },
537
 mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
538
@@ -397,7 +397,7 @@
539
 	README.SSL smime.h group.h \
540
 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
541
 	ChangeLog mkchangelog.sh mutt_idna.h \
542
-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in
543
+	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
544
 
490
 
545
 EXTRA_SCRIPTS = smime_keys
491
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
546
 mutt_dotlock_SOURCES = mutt_dotlock.c
492
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
547
*** mutt-1.5.20-orig/mbox.c	2009-06-10 23:29:41.000000000 -0500
493
+  { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
548
--- mutt-1.5.20-patched/mbox.c	2009-06-19 22:07:04.000000000 -0500
494
+  { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
549
***************
495
+  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
550
*** 100,105 ****
496
   { NULL,		0,				NULL }
551
--- 100,106 ----
497
 };
552
      mutt_perror (ctx->path);
498
 
553
      return (-1);
499
diff -uNp -r mutt-1.5.22.orig/globals.h mutt-1.5.22/globals.h
554
    }
500
--- mutt-1.5.22.orig/globals.h	Sat Dec  3 19:10:04 2011
555
+   ctx->atime = sb.st_atime;
501
+++ mutt-1.5.22/globals.h	Fri Oct 18 10:18:45 2013
556
    ctx->mtime = sb.st_mtime;
502
@@ -117,6 +117,7 @@ WHERE short SearchContext;
557
    ctx->size = sb.st_size;
503
 WHERE char *SendCharset;
558
  
504
 WHERE char *Sendmail;
559
***************
505
 WHERE char *Shell;
560
*** 255,260 ****
506
+WHERE char *SidebarDelim;
561
--- 256,262 ----
507
 WHERE char *Signature;
562
  
508
 WHERE char *SimpleSearch;
563
    ctx->size = sb.st_size;
509
 #if USE_SMTP
564
    ctx->mtime = sb.st_mtime;
510
@@ -208,6 +209,9 @@ WHERE short ScoreThresholdDelete;
565
+   ctx->atime = sb.st_atime;
511
 WHERE short ScoreThresholdRead;
566
  
512
 WHERE short ScoreThresholdFlag;
567
  #ifdef NFS_ATTRIBUTE_HACK
513
 
568
    if (sb.st_mtime > sb.st_atime)
514
+WHERE struct buffy_t *CurBuffy INITVAL(0);
569
*** mutt-1.5.20-orig/menu.c	2009-06-01 11:29:32.000000000 -0500
515
+WHERE short DrawFullLine INITVAL(0);
570
--- mutt-1.5.20-patched/menu.c	2009-06-19 22:07:04.000000000 -0500
516
+WHERE short SidebarWidth;
571
***************
517
 #ifdef USE_IMAP
572
*** 24,29 ****
518
 WHERE short ImapKeepalive;
573
--- 24,30 ----
519
 WHERE short ImapPipelineDepth;
574
  #include "mutt_curses.h"
520
diff -uNp -r mutt-1.5.22.orig/imap/command.c mutt-1.5.22/imap/command.c
575
  #include "mutt_menu.h"
521
--- mutt-1.5.22.orig/imap/command.c	Fri Oct 18 05:48:24 2013
576
  #include "mbyte.h"
522
+++ mutt-1.5.22/imap/command.c	Fri Oct 18 10:18:45 2013
577
+ #include "sidebar.h"
523
@@ -1012,6 +1012,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* 
578
  
524
 	     opened */
579
  #include <string.h>
525
 	  status->uidnext = oldun;
580
  #include <stdlib.h>
526
 
581
***************
527
+        /* Added to make the sidebar show the correct numbers */
582
*** 156,162 ****
528
+        if (status->messages)
583
  {
529
+        {
584
    char *scratch = safe_strdup (s);
530
+          inc->msgcount = status->messages;
585
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
531
+          inc->msg_unread = status->unseen;
586
!   int cols = COLS - shift;
532
+        }
587
  
533
+
588
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
534
         FREE (&value);
589
    s[n - 1] = 0;
535
         return;
590
--- 157,163 ----
536
       }
591
  {
537
diff -uNp -r mutt-1.5.22.orig/imap/imap.c mutt-1.5.22/imap/imap.c
592
    char *scratch = safe_strdup (s);
538
--- mutt-1.5.22.orig/imap/imap.c	Fri Oct 18 05:48:24 2013
593
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
539
+++ mutt-1.5.22/imap/imap.c	Fri Oct 18 10:18:45 2013
594
!   int cols = COLS - shift - SidebarWidth;
540
@@ -1514,7 +1514,7 @@ int imap_buffy_check (int force)
595
  
541
 
596
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
542
     imap_munge_mbox_name (munged, sizeof (munged), name);
597
    s[n - 1] = 0;
543
     snprintf (command, sizeof (command),
598
***************
544
-	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
599
*** 207,212 ****
545
+	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
600
--- 208,214 ----
546
 
601
    char buf[LONG_STRING];
547
     if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
602
    int i;
548
     {
603
  
549
diff -uNp -r mutt-1.5.22.orig/init.h mutt-1.5.22/init.h
604
+   draw_sidebar(1);
550
--- mutt-1.5.22.orig/init.h	Tue Jan 15 07:37:15 2013
605
    for (i = menu->top; i < menu->top + menu->pagelen; i++)
551
+++ mutt-1.5.22/init.h	Fri Oct 18 10:18:45 2013
606
    {
552
@@ -1966,6 +1966,27 @@ struct option_t MuttVars[] = {
607
      if (i < menu->max)
553
   ** not used.
608
***************
554
   ** (PGP only)
609
*** 217,223 ****
610
        if (option (OPTARROWCURSOR))
611
        {
612
          attrset (menu->color (i));
613
! 	CLEARLINE (i - menu->top + menu->offset);
614
  
615
  	if (i == menu->current)
616
  	{
617
--- 219,225 ----
618
        if (option (OPTARROWCURSOR))
619
        {
620
          attrset (menu->color (i));
621
! 	CLEARLINE_WIN (i - menu->top + menu->offset);
622
  
623
  	if (i == menu->current)
624
  	{
625
***************
626
*** 246,259 ****
627
  	  BKGDSET (MT_COLOR_INDICATOR);
628
  	}
629
  
630
! 	CLEARLINE (i - menu->top + menu->offset);
631
  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
632
          SETCOLOR (MT_COLOR_NORMAL);
633
          BKGDSET (MT_COLOR_NORMAL);
634
        }
635
      }
636
      else
637
!       CLEARLINE (i - menu->top + menu->offset);
638
    }
639
    menu->redraw = 0;
640
  }
641
--- 248,261 ----
642
  	  BKGDSET (MT_COLOR_INDICATOR);
643
  	}
644
  
645
! 	CLEARLINE_WIN (i - menu->top + menu->offset);
646
  	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
647
          SETCOLOR (MT_COLOR_NORMAL);
648
          BKGDSET (MT_COLOR_NORMAL);
649
        }
650
      }
651
      else
652
!       CLEARLINE_WIN (i - menu->top + menu->offset);
653
    }
654
    menu->redraw = 0;
655
  }
656
***************
657
*** 268,274 ****
658
      return;
659
    }
660
    
661
!   move (menu->oldcurrent + menu->offset - menu->top, 0);
662
    SETCOLOR (MT_COLOR_NORMAL);
663
    BKGDSET (MT_COLOR_NORMAL);
664
  
665
--- 270,276 ----
666
      return;
667
    }
668
    
669
!   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
670
    SETCOLOR (MT_COLOR_NORMAL);
671
    BKGDSET (MT_COLOR_NORMAL);
672
  
673
***************
674
*** 283,295 ****
675
        clrtoeol ();
676
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
677
        menu_pad_string (buf, sizeof (buf));
678
!       move (menu->oldcurrent + menu->offset - menu->top, 3);
679
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
680
        SETCOLOR (MT_COLOR_NORMAL);
681
      }
682
  
683
      /* now draw it in the new location */
684
!     move (menu->current + menu->offset - menu->top, 0);
685
      attrset (menu->color (menu->current));
686
      ADDCOLOR (MT_COLOR_INDICATOR);
687
      addstr ("->");
688
--- 285,297 ----
689
        clrtoeol ();
690
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
691
        menu_pad_string (buf, sizeof (buf));
692
!       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
693
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
694
        SETCOLOR (MT_COLOR_NORMAL);
695
      }
696
  
697
      /* now draw it in the new location */
698
!     move (menu->current + menu->offset - menu->top, SidebarWidth);
699
      attrset (menu->color (menu->current));
700
      ADDCOLOR (MT_COLOR_INDICATOR);
701
      addstr ("->");
702
***************
703
*** 310,316 ****
704
      attrset (menu->color (menu->current));
705
      ADDCOLOR (MT_COLOR_INDICATOR);
706
      BKGDSET (MT_COLOR_INDICATOR);
707
!     CLEARLINE (menu->current - menu->top + menu->offset);
708
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
709
      SETCOLOR (MT_COLOR_NORMAL);
710
      BKGDSET (MT_COLOR_NORMAL);
711
--- 312,318 ----
712
      attrset (menu->color (menu->current));
713
      ADDCOLOR (MT_COLOR_INDICATOR);
714
      BKGDSET (MT_COLOR_INDICATOR);
715
!     CLEARLINE_WIN (menu->current - menu->top + menu->offset);
716
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
717
      SETCOLOR (MT_COLOR_NORMAL);
718
      BKGDSET (MT_COLOR_NORMAL);
719
***************
720
*** 322,328 ****
721
  {
722
    char buf[LONG_STRING];
723
    
724
!   move (menu->current + menu->offset - menu->top, 0);
725
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
726
    menu_pad_string (buf, sizeof (buf));
727
  
728
--- 324,330 ----
729
  {
730
    char buf[LONG_STRING];
731
    
732
!   move (menu->current + menu->offset - menu->top, SidebarWidth);
733
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
734
    menu_pad_string (buf, sizeof (buf));
735
  
736
***************
737
*** 876,882 ****
738
      
739
      
740
      if (option (OPTARROWCURSOR))
741
!       move (menu->current - menu->top + menu->offset, 2);
742
      else if (option (OPTBRAILLEFRIENDLY))
743
        move (menu->current - menu->top + menu->offset, 0);
744
      else
745
--- 878,884 ----
746
      
747
      
748
      if (option (OPTARROWCURSOR))
749
!       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
750
      else if (option (OPTBRAILLEFRIENDLY))
751
        move (menu->current - menu->top + menu->offset, 0);
752
      else
753
*** mutt-1.5.20-orig/mutt_curses.h	2008-11-11 13:55:47.000000000 -0600
754
--- mutt-1.5.20-patched/mutt_curses.h	2009-06-19 22:07:04.000000000 -0500
755
***************
756
*** 64,69 ****
757
--- 64,70 ----
758
  #undef lines
759
  #endif /* lines */
760
  
761
+ #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
762
  #define CLEARLINE(x) move(x,0), clrtoeol()
763
  #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
764
  #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
765
***************
766
*** 126,131 ****
767
--- 127,134 ----
768
    MT_COLOR_BOLD,
769
    MT_COLOR_UNDERLINE,
770
    MT_COLOR_INDEX,
771
+   MT_COLOR_NEW,
772
+   MT_COLOR_FLAGGED,
773
    MT_COLOR_MAX
774
  };
775
  
776
*** mutt-1.5.20-orig/mutt.h	2009-06-12 17:15:42.000000000 -0500
777
--- mutt-1.5.20-patched/mutt.h	2009-06-19 22:07:04.000000000 -0500
778
***************
779
*** 418,423 ****
780
--- 418,425 ----
781
    OPTSAVEEMPTY,
782
    OPTSAVENAME,
783
    OPTSCORE,
784
+   OPTSIDEBAR,
785
+   OPTSIDEBARSORT,
786
    OPTSIGDASHES,
787
    OPTSIGONTOP,
788
    OPTSORTRE,
789
***************
790
*** 854,859 ****
791
--- 856,862 ----
792
  {
793
    char *path;
794
    FILE *fp;
795
+   time_t atime;
796
    time_t mtime;
797
    off_t size;
798
    off_t vsize;
799
***************
800
*** 888,893 ****
801
--- 891,897 ----
802
    unsigned int quiet : 1;	/* inhibit status messages? */
803
    unsigned int collapsed : 1;   /* are all threads collapsed? */
804
    unsigned int closing : 1;	/* mailbox is being closed */
805
+   unsigned int peekonly : 1;	/* just taking a glance, revert atime */
806
  
807
    /* driver hooks */
808
    void *data;			/* driver specific data */
809
*** mutt-1.5.20-orig/muttlib.c	2009-05-18 19:11:35.000000000 -0500
810
--- mutt-1.5.20-patched/muttlib.c	2009-06-19 22:07:04.000000000 -0500
811
***************
812
*** 1232,1237 ****
813
--- 1232,1239 ----
814
  	  pl = pw = 1;
815
  
816
  	/* see if there's room to add content, else ignore */
817
+         if ( DrawFullLine )
818
+         {
819
  	if ((col < COLS && wlen < destlen) || soft)
820
  	{
821
  	  int pad;
822
***************
823
*** 1274,1279 ****
824
--- 1276,1327 ----
825
  	  col += wid;
826
  	  src += pl;
827
  	}
828
+         }
829
+         else
830
+         {
831
+ 	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
832
+         {
833
+ 	  int pad;
834
+ 
835
+ 	  /* get contents after padding */
836
+ 	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
837
+ 	  len = mutt_strlen (buf);
838
+ 	  wid = mutt_strwidth (buf);
839
+ 
840
+ 	  /* try to consume as many columns as we can, if we don't have
841
+ 	   * memory for that, use as much memory as possible */
842
+ 	  pad = (COLS - SidebarWidth - col - wid) / pw;
843
+ 	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
844
+ 	    pad = ((signed)(destlen - wlen - len)) / pl;
845
+ 	  if (pad > 0)
846
+ 	  {
847
+ 	    while (pad--)
848
+ 	    {
849
+ 	      memcpy (wptr, src, pl);
850
+ 	      wptr += pl;
851
+ 	      wlen += pl;
852
+ 	      col += pw;
853
+ 	    }
854
+ 	  }
855
+ 	  else if (soft && pad < 0)
856
+ 	  {
857
+ 	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
858
+ 	    *wptr = 0;
859
+ 	    /* make sure right part is at most as wide as display */
860
+ 	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
861
+ 	    /* truncate left so that right part fits completely in */
862
+ 	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
863
+ 	    wptr = dest + wlen;
864
+ 	  }
865
+ 	  if (len + wlen > destlen)
866
+ 	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
867
+ 	  memcpy (wptr, buf, len);
868
+ 	  wptr += len;
869
+ 	  wlen += len;
870
+ 	  col += wid;
871
+ 	  src += pl;
872
+ 	}
873
+         }
874
  	break; /* skip rest of input */
875
        }
876
        else if (ch == '|')
877
*** mutt-1.5.20-orig/mx.c	2009-06-10 23:29:41.000000000 -0500
878
--- mutt-1.5.20-patched/mx.c	2009-06-19 22:07:04.000000000 -0500
879
***************
880
*** 581,586 ****
881
--- 581,587 ----
882
   *		M_APPEND	open mailbox for appending
883
   *		M_READONLY	open mailbox in read-only mode
884
   *		M_QUIET		only print error messages
885
+  *		M_PEEK		revert atime where applicable
886
   *	ctx	if non-null, context struct to use
887
   */
555
   */
888
  CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
556
+  {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
889
***************
557
+  /*
890
*** 603,608 ****
558
+  ** .pp
891
--- 604,611 ----
559
+  ** This specifies the delimiter between the sidebar (if visible) and 
892
      ctx->quiet = 1;
560
+  ** other screens.
893
    if (flags & M_READONLY)
561
+  */
894
      ctx->readonly = 1;
562
+  { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
895
+   if (flags & M_PEEK)
563
+  /*
896
+     ctx->peekonly = 1;
564
+  ** .pp
897
  
565
+  ** This specifies whether or not to show sidebar (left-side list of folders).
898
    if (flags & (M_APPEND|M_NEWFOLDER))
566
+  */
899
    {
567
+  { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
900
***************
568
+  /*
901
*** 702,710 ****
569
+  ** .pp
902
--- 705,725 ----
570
+  ** This specifies whether or not to sort the sidebar alphabetically.
903
  void mx_fastclose_mailbox (CONTEXT *ctx)
571
+  */
904
  {
572
+  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
905
    int i;
573
+  /*
906
+ #ifndef BUFFY_SIZE
574
+  ** .pp
907
+   struct utimbuf ut;
575
+  ** The width of the sidebar.
908
+ #endif
576
+  */
909
  
577
   { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
910
    if(!ctx) 
578
   /*
911
      return;
579
   ** .pp
912
+ #ifndef BUFFY_SIZE
580
diff -uNp -r mutt-1.5.22.orig/mailbox.h mutt-1.5.22/mailbox.h
913
+   /* fix up the times so buffy won't get confused */
581
--- mutt-1.5.22.orig/mailbox.h	Sun Feb 21 22:10:41 2010
914
+   if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
582
+++ mutt-1.5.22/mailbox.h	Fri Oct 18 10:18:45 2013
915
+   {
583
@@ -27,6 +27,7 @@
916
+     ut.actime = ctx->atime;
584
 #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
917
+     ut.modtime = ctx->mtime;
585
 				* safe_fopen() for mbox-style folders.
918
+     utime (ctx->path, &ut); 
586
 				*/
919
+   }
587
+#define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
920
+ #endif
588
 
921
  
589
 /* mx_open_new_message() */
922
    if (ctx->mx_close)
590
 #define M_ADD_FROM	1	/* add a From_ line */
923
      ctx->mx_close (ctx);
591
diff -uNp -r mutt-1.5.22.orig/mbox.c mutt-1.5.22/mbox.c
924
*** mutt-1.5.20-orig/OPS	2009-05-13 00:01:13.000000000 -0500
592
--- mutt-1.5.22.orig/mbox.c	Fri Oct 18 05:48:24 2013
925
--- mutt-1.5.20-patched/OPS	2009-06-19 22:07:04.000000000 -0500
593
+++ mutt-1.5.22/mbox.c	Fri Oct 18 10:18:45 2013
926
***************
594
@@ -100,6 +100,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
927
*** 178,180 ****
595
     mutt_perror (ctx->path);
928
--- 178,185 ----
596
     return (-1);
929
  OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
597
   }
930
  OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
598
+  ctx->atime = sb.st_atime;
931
  OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
599
   ctx->mtime = sb.st_mtime;
932
+ OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
600
   ctx->size = sb.st_size;
933
+ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
601
 
934
+ OP_SIDEBAR_NEXT "go down to next mailbox"
602
@@ -251,6 +252,7 @@ int mbox_parse_mailbox (CONTEXT *ctx)
935
+ OP_SIDEBAR_PREV "go to previous mailbox"
603
 
936
+ OP_SIDEBAR_OPEN "open hilighted mailbox"
604
   ctx->size = sb.st_size;
937
--- orig/pager.c.orig	2010-09-18 13:23:19.000000000 +0200
605
   ctx->mtime = sb.st_mtime;
938
+++ new/pager.c	2010-09-18 14:03:08.000000000 +0200
606
+  ctx->atime = sb.st_atime;
607
 
608
 #ifdef NFS_ATTRIBUTE_HACK
609
   if (sb.st_mtime > sb.st_atime)
610
diff -uNp -r mutt-1.5.22.orig/menu.c mutt-1.5.22/menu.c
611
--- mutt-1.5.22.orig/menu.c	Tue Jan 15 07:37:15 2013
612
+++ mutt-1.5.22/menu.c	Fri Oct 18 10:18:45 2013
613
@@ -24,6 +24,7 @@
614
 #include "mutt_curses.h"
615
 #include "mutt_menu.h"
616
 #include "mbyte.h"
617
+#include "sidebar.h"
618
 
619
 extern size_t UngetCount;
620
 
621
@@ -186,7 +187,7 @@ static void menu_pad_string (char *s, size_t n)
622
 {
623
   char *scratch = safe_strdup (s);
624
   int shift = option (OPTARROWCURSOR) ? 3 : 0;
625
-  int cols = COLS - shift;
626
+  int cols = COLS - shift - SidebarWidth;
627
 
628
   mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
629
   s[n - 1] = 0;
630
@@ -239,6 +240,7 @@ void menu_redraw_index (MUTTMENU *menu)
631
   int do_color;
632
   int attr;
633
 
634
+  draw_sidebar(1);
635
   for (i = menu->top; i < menu->top + menu->pagelen; i++)
636
   {
637
     if (i < menu->max)
638
@@ -249,7 +251,7 @@ void menu_redraw_index (MUTTMENU *menu)
639
       menu_pad_string (buf, sizeof (buf));
640
 
641
       ATTRSET(attr);
642
-      move(i - menu->top + menu->offset, 0);
643
+      move(i - menu->top + menu->offset, SidebarWidth);
644
       do_color = 1;
645
 
646
       if (i == menu->current)
647
@@ -272,7 +274,7 @@ void menu_redraw_index (MUTTMENU *menu)
648
     else
649
     {
650
       NORMAL_COLOR;
651
-      CLEARLINE(i - menu->top + menu->offset);
652
+      CLEARLINE_WIN(i - menu->top + menu->offset);
653
     }
654
   }
655
   NORMAL_COLOR;
656
@@ -289,7 +291,7 @@ void menu_redraw_motion (MUTTMENU *menu)
657
     return;
658
   }
659
   
660
-  move (menu->oldcurrent + menu->offset - menu->top, 0);
661
+  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
662
   ATTRSET(menu->color (menu->oldcurrent));
663
 
664
   if (option (OPTARROWCURSOR))
665
@@ -301,13 +303,13 @@ void menu_redraw_motion (MUTTMENU *menu)
666
     {
667
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
668
       menu_pad_string (buf, sizeof (buf));
669
-      move (menu->oldcurrent + menu->offset - menu->top, 3);
670
+      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
671
       print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
672
     }
673
 
674
     /* now draw it in the new location */
675
     SETCOLOR(MT_COLOR_INDICATOR);
676
-    mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
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
   
694
-  move (menu->current + menu->offset - menu->top, 0);
695
+  move (menu->current + menu->offset - menu->top, SidebarWidth);
696
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
697
   menu_pad_string (buf, sizeof (buf));
698
 
699
@@ -872,7 +874,7 @@ int mutt_menuLoop (MUTTMENU *menu)
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
939
@@ -29,6 +29,7 @@
909
@@ -29,6 +29,7 @@
940
 #include "pager.h"
910
 #include "pager.h"
941
 #include "attach.h"
911
 #include "attach.h"
Lines 944-958 Link Here
944
 
914
 
945
 #include "mutt_crypt.h"
915
 #include "mutt_crypt.h"
946
 
916
 
947
@@ -1104,6 +1105,7 @@
917
@@ -1095,6 +1096,7 @@ static int format_line (struct line_t **lineInfo, int 
948
   if (check_attachment_marker ((char *)buf) == 0)
918
   wchar_t wc;
949
     wrap_cols = COLS;
919
   mbstate_t mbstate;
950
 
920
   int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
951
+  wrap_cols -= SidebarWidth;
921
+  wrap_cols -= SidebarWidth;
952
   /* FIXME: this should come from lineInfo */
953
   memset(&mbstate, 0, sizeof(mbstate));
954
 
922
 
955
@@ -1778,7 +1780,7 @@
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
956
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
926
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
957
     {
927
     {
958
       do {
928
       do {
Lines 961-967 Link Here
961
 	curline = oldtopline = topline;
931
 	curline = oldtopline = topline;
962
 	lines = 0;
932
 	lines = 0;
963
 	force_redraw = 0;
933
 	force_redraw = 0;
964
@@ -1791,6 +1793,7 @@
934
@@ -1759,6 +1761,7 @@ mutt_pager (const char *banner, const char *fname, int
965
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
935
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
966
 	    lines++;
936
 	    lines++;
967
 	  curline++;
937
 	  curline++;
Lines 969-988 Link Here
969
 	}
939
 	}
970
 	last_offset = lineInfo[curline].offset;
940
 	last_offset = lineInfo[curline].offset;
971
       } while (force_redraw);
941
       } while (force_redraw);
972
@@ -1804,6 +1807,7 @@
942
@@ -1771,6 +1774,7 @@ mutt_pager (const char *banner, const char *fname, int
973
 	  addch ('~');
943
 	  addch ('~');
974
 	addch ('\n');
944
 	addch ('\n');
975
 	lines++;
945
 	lines++;
976
+  	move(lines + bodyoffset, SidebarWidth);
946
+  	move(lines + bodyoffset, SidebarWidth);
977
       }
947
       }
978
       /* We are going to update the pager status bar, so it isn't
948
       NORMAL_COLOR;
979
        * necessary to reset to normal color now. */
949
 
980
@@ -1827,21 +1831,21 @@
950
@@ -1799,17 +1803,17 @@ mutt_pager (const char *banner, const char *fname, int
981
       /* print out the pager status bar */
982
       SETCOLOR (MT_COLOR_STATUS);
983
       BKGDSET (MT_COLOR_STATUS);
984
-      CLEARLINE (statusoffset);
985
+      CLEARLINE_WIN (statusoffset);
986
 
951
 
987
       if (IsHeader (extra) || IsMsgAttach (extra))
952
       if (IsHeader (extra) || IsMsgAttach (extra))
988
       {
953
       {
Lines 1001-1009 Link Here
1001
-	mutt_paddstr (COLS, bn);
966
-	mutt_paddstr (COLS, bn);
1002
+	mutt_paddstr (COLS-SidebarWidth, bn);
967
+	mutt_paddstr (COLS-SidebarWidth, bn);
1003
       }
968
       }
1004
       BKGDSET (MT_COLOR_NORMAL);
969
       NORMAL_COLOR;
1005
       SETCOLOR (MT_COLOR_NORMAL);
970
     }
1006
@@ -1852,18 +1856,23 @@
971
@@ -1819,16 +1823,21 @@ mutt_pager (const char *banner, const char *fname, int
1007
       /* redraw the pager_index indicator, because the
972
       /* redraw the pager_index indicator, because the
1008
        * flags for this message might have changed. */
973
        * flags for this message might have changed. */
1009
       menu_redraw_current (index);
974
       menu_redraw_current (index);
Lines 1015-1025 Link Here
1015
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
980
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
1016
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
981
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
1017
       SETCOLOR (MT_COLOR_STATUS);
982
       SETCOLOR (MT_COLOR_STATUS);
1018
       BKGDSET (MT_COLOR_STATUS);
1019
-      mutt_paddstr (COLS, buffer);
983
-      mutt_paddstr (COLS, buffer);
1020
+      mutt_paddstr (COLS-SidebarWidth, buffer);
984
+      mutt_paddstr (COLS-SidebarWidth, buffer);
1021
       SETCOLOR (MT_COLOR_NORMAL);
985
       NORMAL_COLOR;
1022
       BKGDSET (MT_COLOR_NORMAL);
1023
     }
986
     }
1024
 
987
 
1025
+    /* if we're not using the index, update every time */
988
+    /* if we're not using the index, update every time */
Lines 1029-1433 Link Here
1029
     redraw = 0;
992
     redraw = 0;
1030
 
993
 
1031
     if (option(OPTBRAILLEFRIENDLY)) {
994
     if (option(OPTBRAILLEFRIENDLY)) {
1032
@@ -2852,6 +2861,13 @@
995
@@ -2762,6 +2771,13 @@ search_next:
996
       case OP_WHAT_KEY:
1033
 	mutt_what_key ();
997
 	mutt_what_key ();
1034
 	break;
998
 	break;
1035
 
999
+
1036
+      case OP_SIDEBAR_SCROLL_UP:
1000
+      case OP_SIDEBAR_SCROLL_UP:
1037
+      case OP_SIDEBAR_SCROLL_DOWN:
1001
+      case OP_SIDEBAR_SCROLL_DOWN:
1038
+      case OP_SIDEBAR_NEXT:
1002
+      case OP_SIDEBAR_NEXT:
1039
+      case OP_SIDEBAR_PREV:
1003
+      case OP_SIDEBAR_PREV:
1040
+	scroll_sidebar(ch, MENU_PAGER);
1004
+	scroll_sidebar(ch, MENU_PAGER);
1041
+ 	break;
1005
+ 	break;
1042
+
1006
 
1043
       default:
1007
       default:
1044
 	ch = -1;
1008
 	ch = -1;
1045
 	break;
1009
diff -uNp -r mutt-1.5.22.orig/sidebar.c mutt-1.5.22/sidebar.c
1046
*** mutt-1.5.20-orig/PATCHES	2008-11-11 13:55:46.000000000 -0600
1010
--- mutt-1.5.22.orig/sidebar.c	Thu Jan  1 01:00:00 1970
1047
--- mutt-1.5.20-patched/PATCHES	2009-06-19 22:20:31.000000000 -0500
1011
+++ mutt-1.5.22/sidebar.c	Fri Oct 18 10:18:45 2013
1048
***************
1012
@@ -0,0 +1,333 @@
1049
*** 0 ****
1013
+/*
1050
--- 1 ----
1014
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1051
+ patch-1.5.20.sidebar.20090619.txt
1015
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1052
*** mutt-1.5.20-orig/sidebar.c	1969-12-31 18:00:00.000000000 -0600
1016
+ * 
1053
--- mutt-1.5.20-patched/sidebar.c	2009-06-19 22:07:04.000000000 -0500
1017
+ *     This program is free software; you can redistribute it and/or modify
1054
***************
1018
+ *     it under the terms of the GNU General Public License as published by
1055
*** 0 ****
1019
+ *     the Free Software Foundation; either version 2 of the License, or
1056
--- 1,333 ----
1020
+ *     (at your option) any later version.
1057
+ /*
1021
+ * 
1058
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1022
+ *     This program is distributed in the hope that it will be useful,
1059
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1023
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1060
+  * 
1024
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1061
+  *     This program is free software; you can redistribute it and/or modify
1025
+ *     GNU General Public License for more details.
1062
+  *     it under the terms of the GNU General Public License as published by
1026
+ * 
1063
+  *     the Free Software Foundation; either version 2 of the License, or
1027
+ *     You should have received a copy of the GNU General Public License
1064
+  *     (at your option) any later version.
1028
+ *     along with this program; if not, write to the Free Software
1065
+  * 
1029
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1066
+  *     This program is distributed in the hope that it will be useful,
1030
+ */ 
1067
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1031
+
1068
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1032
+
1069
+  *     GNU General Public License for more details.
1033
+#if HAVE_CONFIG_H
1070
+  * 
1034
+# include "config.h"
1071
+  *     You should have received a copy of the GNU General Public License
1035
+#endif
1072
+  *     along with this program; if not, write to the Free Software
1036
+
1073
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1037
+#include "mutt.h"
1074
+  */ 
1038
+#include "mutt_menu.h"
1075
+ 
1039
+#include "mutt_curses.h"
1076
+ 
1040
+#include "sidebar.h"
1077
+ #if HAVE_CONFIG_H
1041
+#include "buffy.h"
1078
+ # include "config.h"
1042
+#include <libgen.h>
1079
+ #endif
1043
+#include "keymap.h"
1080
+ 
1044
+#include <stdbool.h>
1081
+ #include "mutt.h"
1045
+
1082
+ #include "mutt_menu.h"
1046
+/*BUFFY *CurBuffy = 0;*/
1083
+ #include "mutt_curses.h"
1047
+static BUFFY *TopBuffy = 0;
1084
+ #include "sidebar.h"
1048
+static BUFFY *BottomBuffy = 0;
1085
+ #include "buffy.h"
1049
+static int known_lines = 0;
1086
+ #include <libgen.h>
1050
+
1087
+ #include "keymap.h"
1051
+static int quick_log10(int n)
1088
+ #include <stdbool.h>
1052
+{
1089
+ 
1053
+        char string[32];
1090
+ /*BUFFY *CurBuffy = 0;*/
1054
+        sprintf(string, "%d", n);
1091
+ static BUFFY *TopBuffy = 0;
1055
+        return strlen(string);
1092
+ static BUFFY *BottomBuffy = 0;
1056
+}
1093
+ static int known_lines = 0;
1057
+
1094
+ 
1058
+void calc_boundaries (int menu)
1095
+ static int quick_log10(int n)
1059
+{
1096
+ {
1060
+	BUFFY *tmp = Incoming;
1097
+         char string[32];
1061
+
1098
+         sprintf(string, "%d", n);
1062
+	if ( known_lines != LINES ) {
1099
+         return strlen(string);
1063
+		TopBuffy = BottomBuffy = 0;
1100
+ }
1064
+		known_lines = LINES;
1101
+ 
1065
+	}
1102
+ void calc_boundaries (int menu)
1066
+	for ( ; tmp->next != 0; tmp = tmp->next )
1103
+ {
1067
+		tmp->next->prev = tmp;
1104
+ 	BUFFY *tmp = Incoming;
1068
+
1105
+ 
1069
+	if ( TopBuffy == 0 && BottomBuffy == 0 )
1106
+ 	if ( known_lines != LINES ) {
1070
+		TopBuffy = Incoming;
1107
+ 		TopBuffy = BottomBuffy = 0;
1071
+	if ( BottomBuffy == 0 ) {
1108
+ 		known_lines = LINES;
1072
+		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1109
+ 	}
1073
+		BottomBuffy = TopBuffy;
1110
+ 	for ( ; tmp->next != 0; tmp = tmp->next )
1074
+		while ( --count && BottomBuffy->next )
1111
+ 		tmp->next->prev = tmp;
1075
+			BottomBuffy = BottomBuffy->next;
1112
+ 
1076
+	}
1113
+ 	if ( TopBuffy == 0 && BottomBuffy == 0 )
1077
+	else if ( TopBuffy == CurBuffy->next ) {
1114
+ 		TopBuffy = Incoming;
1078
+		int count = LINES - 2 - (menu != MENU_PAGER);
1115
+ 	if ( BottomBuffy == 0 ) {
1079
+		BottomBuffy = CurBuffy;
1116
+ 		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1080
+		tmp = BottomBuffy;
1117
+ 		BottomBuffy = TopBuffy;
1081
+		while ( --count && tmp->prev)
1118
+ 		while ( --count && BottomBuffy->next )
1082
+			tmp = tmp->prev;
1119
+ 			BottomBuffy = BottomBuffy->next;
1083
+		TopBuffy = tmp;
1120
+ 	}
1084
+	}
1121
+ 	else if ( TopBuffy == CurBuffy->next ) {
1085
+	else if ( BottomBuffy == CurBuffy->prev ) {
1122
+ 		int count = LINES - 2 - (menu != MENU_PAGER);
1086
+		int count = LINES - 2 - (menu != MENU_PAGER);
1123
+ 		BottomBuffy = CurBuffy;
1087
+		TopBuffy = CurBuffy;
1124
+ 		tmp = BottomBuffy;
1088
+		tmp = TopBuffy;
1125
+ 		while ( --count && tmp->prev)
1089
+		while ( --count && tmp->next )
1126
+ 			tmp = tmp->prev;
1090
+			tmp = tmp->next;
1127
+ 		TopBuffy = tmp;
1091
+		BottomBuffy = tmp;
1128
+ 	}
1092
+	}
1129
+ 	else if ( BottomBuffy == CurBuffy->prev ) {
1093
+}
1130
+ 		int count = LINES - 2 - (menu != MENU_PAGER);
1094
+
1131
+ 		TopBuffy = CurBuffy;
1095
+char *make_sidebar_entry(char *box, int size, int new, int flagged)
1132
+ 		tmp = TopBuffy;
1096
+{
1133
+ 		while ( --count && tmp->next )
1097
+	static char *entry = 0;
1134
+ 			tmp = tmp->next;
1098
+	char *c;
1135
+ 		BottomBuffy = tmp;
1099
+	int i = 0;
1136
+ 	}
1100
+	int delim_len = strlen(SidebarDelim);
1137
+ }
1101
+
1138
+ 
1102
+	c = realloc(entry, SidebarWidth - delim_len + 2);
1139
+ char *make_sidebar_entry(char *box, int size, int new, int flagged)
1103
+	if ( c ) entry = c;
1140
+ {
1104
+	entry[SidebarWidth - delim_len + 1] = 0;
1141
+ 	static char *entry = 0;
1105
+	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1142
+ 	char *c;
1106
+	i = strlen(box);
1143
+ 	int i = 0;
1107
+	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1144
+ 	int delim_len = strlen(SidebarDelim);
1108
+
1145
+ 
1109
+        if (size == -1)
1146
+ 	c = realloc(entry, SidebarWidth - delim_len + 2);
1110
+                sprintf(entry + SidebarWidth - delim_len - 3, "?");
1147
+ 	if ( c ) entry = c;
1111
+        else if ( new ) {
1148
+ 	entry[SidebarWidth - delim_len + 1] = 0;
1112
+          if (flagged > 0) {
1149
+ 	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1113
+              sprintf(
1150
+ 	i = strlen(box);
1114
+		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1151
+ 	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1115
+		        "% d(%d)[%d]", size, new, flagged);
1152
+ 
1153
+         if (size == -1)
1154
+                 sprintf(entry + SidebarWidth - delim_len - 3, "?");
1155
+         else if ( new ) {
1156
+           if (flagged > 0) {
1157
+               sprintf(
1158
+ 		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1159
+ 		        "% d(%d)[%d]", size, new, flagged);
1160
+           } else {
1161
+               sprintf(
1162
+                       entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1163
+                       "% d(%d)", size, new);
1164
+           }
1165
+         } else if (flagged > 0) {
1166
+               sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1167
+         } else {
1168
+               sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1169
+         }
1170
+ 	return entry;
1171
+ }
1172
+ 
1173
+ void set_curbuffy(char buf[LONG_STRING])
1174
+ {
1175
+   BUFFY* tmp = CurBuffy = Incoming;
1176
+ 
1177
+   if (!Incoming)
1178
+     return;
1179
+ 
1180
+   while(1) {
1181
+     if(!strcmp(tmp->path, buf)) {
1182
+       CurBuffy = tmp;
1183
+       break;
1184
+     }
1185
+ 
1186
+     if(tmp->next)
1187
+       tmp = tmp->next;
1188
+     else
1189
+       break;
1190
+   }
1191
+ }
1192
+ 
1193
+ int draw_sidebar(int menu) {
1194
+ 
1195
+ 	int lines = option(OPTHELP) ? 1 : 0;
1196
+ 	BUFFY *tmp;
1197
+ #ifndef USE_SLANG_CURSES
1198
+         attr_t attrs;
1199
+ #endif
1200
+         short delim_len = strlen(SidebarDelim);
1201
+         short color_pair;
1202
+ 
1203
+         static bool initialized = false;
1204
+         static int prev_show_value;
1205
+         static short saveSidebarWidth;
1206
+ 
1207
+         /* initialize first time */
1208
+         if(!initialized) {
1209
+                 prev_show_value = option(OPTSIDEBAR);
1210
+                 saveSidebarWidth = SidebarWidth;
1211
+                 if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1212
+                 initialized = true;
1213
+         }
1214
+ 
1215
+         /* save or restore the value SidebarWidth */
1216
+         if(prev_show_value != option(OPTSIDEBAR)) {
1217
+                 if(prev_show_value && !option(OPTSIDEBAR)) {
1218
+                         saveSidebarWidth = SidebarWidth;
1219
+                         SidebarWidth = 0;
1220
+                 } else if(!prev_show_value && option(OPTSIDEBAR)) {
1221
+                         SidebarWidth = saveSidebarWidth;
1222
+                 }
1223
+                 prev_show_value = option(OPTSIDEBAR);
1224
+         }
1225
+ 
1226
+ 
1227
+ //	if ( SidebarWidth == 0 ) return 0;
1228
+        if (SidebarWidth > 0 && option (OPTSIDEBAR)
1229
+            && delim_len >= SidebarWidth) {
1230
+          unset_option (OPTSIDEBAR);
1231
+          /* saveSidebarWidth = SidebarWidth; */
1232
+          if (saveSidebarWidth > delim_len) {
1233
+            SidebarWidth = saveSidebarWidth;
1234
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1235
+            sleep (2);
1236
+          } else {
1116
+          } else {
1237
+            SidebarWidth = 0;
1117
+              sprintf(
1238
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1118
+                      entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
1239
+            sleep (4); /* the advise to set a sane value should be seen long enough */
1119
+                      "% d(%d)", size, new);
1240
+          }
1120
+          }
1241
+          saveSidebarWidth = 0;
1121
+        } else if (flagged > 0) {
1242
+          return (0);
1122
+              sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
1123
+        } else {
1124
+              sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1243
+        }
1125
+        }
1244
+ 
1126
+	return entry;
1245
+     if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1127
+}
1246
+       if (SidebarWidth > 0) {
1128
+
1247
+         saveSidebarWidth = SidebarWidth;
1129
+void set_curbuffy(char buf[LONG_STRING])
1248
+         SidebarWidth = 0;
1130
+{
1249
+       }
1131
+  BUFFY* tmp = CurBuffy = Incoming;
1250
+       unset_option(OPTSIDEBAR);
1132
+
1251
+       return 0;
1133
+  if (!Incoming)
1252
+     }
1134
+    return;
1253
+ 
1135
+
1254
+         /* get attributes for divider */
1136
+  while(1) {
1255
+ 	SETCOLOR(MT_COLOR_STATUS);
1137
+    if(!strcmp(tmp->path, buf)) {
1256
+ #ifndef USE_SLANG_CURSES
1138
+      CurBuffy = tmp;
1257
+         attr_get(&attrs, &color_pair, 0);
1139
+      break;
1258
+ #else
1140
+    }
1259
+         color_pair = attr_get();
1141
+
1260
+ #endif
1142
+    if(tmp->next)
1261
+ 	SETCOLOR(MT_COLOR_NORMAL);
1143
+      tmp = tmp->next;
1262
+ 
1144
+    else
1263
+ 	/* draw the divider */
1145
+      break;
1264
+ 
1146
+  }
1265
+ 	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1147
+}
1266
+ 		move(lines, SidebarWidth - delim_len);
1148
+
1267
+ 		addstr(NONULL(SidebarDelim));
1149
+int draw_sidebar(int menu) {
1268
+ #ifndef USE_SLANG_CURSES
1150
+
1269
+                 mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1151
+	int lines = option(OPTHELP) ? 1 : 0;
1270
+ #endif
1152
+	BUFFY *tmp;
1271
+ 	}
1153
+#ifndef USE_SLANG_CURSES
1272
+ 
1154
+        attr_t attrs;
1273
+ 	if ( Incoming == 0 ) return 0;
1155
+#endif
1274
+ 	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1156
+        short delim_len = strlen(SidebarDelim);
1275
+ 
1157
+        short color_pair;
1276
+ 	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1158
+
1277
+ 		calc_boundaries(menu);
1159
+        static bool initialized = false;
1278
+ 	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1160
+        static int prev_show_value;
1279
+ 
1161
+        static short saveSidebarWidth;
1280
+ 	tmp = TopBuffy;
1162
+
1281
+ 
1163
+        /* initialize first time */
1282
+ 	SETCOLOR(MT_COLOR_NORMAL);
1164
+        if(!initialized) {
1283
+ 
1165
+                prev_show_value = option(OPTSIDEBAR);
1284
+ 	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1166
+                saveSidebarWidth = SidebarWidth;
1285
+ 		if ( tmp == CurBuffy )
1167
+                if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1286
+ 			SETCOLOR(MT_COLOR_INDICATOR);
1168
+                initialized = true;
1287
+ 		else if ( tmp->msg_unread > 0 )
1169
+        }
1288
+ 			SETCOLOR(MT_COLOR_NEW);
1170
+
1289
+ 		else if ( tmp->msg_flagged > 0 )
1171
+        /* save or restore the value SidebarWidth */
1290
+ 		        SETCOLOR(MT_COLOR_FLAGGED);
1172
+        if(prev_show_value != option(OPTSIDEBAR)) {
1291
+ 		else
1173
+                if(prev_show_value && !option(OPTSIDEBAR)) {
1292
+ 			SETCOLOR(MT_COLOR_NORMAL);
1174
+                        saveSidebarWidth = SidebarWidth;
1293
+ 
1175
+                        SidebarWidth = 0;
1294
+ 		move( lines, 0 );
1176
+                } else if(!prev_show_value && option(OPTSIDEBAR)) {
1295
+ 		if ( Context && !strcmp( tmp->path, Context->path ) ) {
1177
+                        SidebarWidth = saveSidebarWidth;
1296
+ 			tmp->msg_unread = Context->unread;
1178
+                }
1297
+ 			tmp->msgcount = Context->msgcount;
1179
+                prev_show_value = option(OPTSIDEBAR);
1298
+ 			tmp->msg_flagged = Context->flagged;
1180
+        }
1299
+ 		}
1181
+
1300
+ 		// check whether Maildir is a prefix of the current folder's path
1182
+
1301
+ 		short maildir_is_prefix = 0;
1183
+//	if ( SidebarWidth == 0 ) return 0;
1302
+ 		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1184
+       if (SidebarWidth > 0 && option (OPTSIDEBAR)
1303
+ 			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1185
+           && delim_len >= SidebarWidth) {
1304
+         		maildir_is_prefix = 1;
1186
+         unset_option (OPTSIDEBAR);
1305
+ 		// calculate depth of current folder and generate its display name with indented spaces
1187
+         /* saveSidebarWidth = SidebarWidth; */
1306
+ 		int sidebar_folder_depth = 0;
1188
+         if (saveSidebarWidth > delim_len) {
1307
+ 		char *sidebar_folder_name;
1189
+           SidebarWidth = saveSidebarWidth;
1308
+ 		sidebar_folder_name = basename(tmp->path);
1190
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1309
+ 		if ( maildir_is_prefix ) {
1191
+           sleep (2);
1310
+ 			char *tmp_folder_name;
1192
+         } else {
1311
+ 			int i;
1193
+           SidebarWidth = 0;
1312
+ 			tmp_folder_name = tmp->path + strlen(Maildir);
1194
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1313
+ 			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1195
+           sleep (4); /* the advise to set a sane value should be seen long enough */
1314
+ 				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1315
+ 			}   
1316
+ 			if (sidebar_folder_depth > 0) {
1317
+ 				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1318
+ 				for (i=0; i < sidebar_folder_depth; i++)
1319
+ 					sidebar_folder_name[i]=' ';
1320
+ 				sidebar_folder_name[i]=0;
1321
+ 				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1322
+ 			}
1323
+ 		}
1324
+ 		printw( "%.*s", SidebarWidth - delim_len + 1,
1325
+ 			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1326
+ 			tmp->msg_unread, tmp->msg_flagged));
1327
+ 		if (sidebar_folder_depth > 0)
1328
+ 		        free(sidebar_folder_name);
1329
+ 		lines++;
1330
+ 	}
1331
+ 	SETCOLOR(MT_COLOR_NORMAL);
1332
+ 	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1333
+ 		int i = 0;
1334
+ 		move( lines, 0 );
1335
+ 		for ( ; i < SidebarWidth - delim_len; i++ )
1336
+ 			addch(' ');
1337
+ 	}
1338
+ 	return 0;
1339
+ }
1340
+ 
1341
+ 
1342
+ void set_buffystats(CONTEXT* Context)
1343
+ {
1344
+         BUFFY *tmp = Incoming;
1345
+         while(tmp) {
1346
+                 if(Context && !strcmp(tmp->path, Context->path)) {
1347
+ 			tmp->msg_unread = Context->unread;
1348
+ 			tmp->msgcount = Context->msgcount;
1349
+                         break;
1350
+                 }
1351
+                 tmp = tmp->next;
1352
+         }
1196
+         }
1353
+ }
1197
+         saveSidebarWidth = 0;
1354
+ 
1198
+         return (0);
1355
+ void scroll_sidebar(int op, int menu)
1199
+       }
1356
+ {
1200
+
1357
+         if(!SidebarWidth) return;
1201
+    if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1358
+         if(!CurBuffy) return;
1202
+      if (SidebarWidth > 0) {
1359
+ 
1203
+        saveSidebarWidth = SidebarWidth;
1360
+ 	switch (op) {
1204
+        SidebarWidth = 0;
1361
+ 		case OP_SIDEBAR_NEXT:
1205
+      }
1362
+ 			if ( CurBuffy->next == NULL ) return;
1206
+      unset_option(OPTSIDEBAR);
1363
+ 			CurBuffy = CurBuffy->next;
1207
+      return 0;
1364
+ 			break;
1208
+    }
1365
+ 		case OP_SIDEBAR_PREV:
1209
+
1366
+ 			if ( CurBuffy->prev == NULL ) return;
1210
+        /* get attributes for divider */
1367
+ 			CurBuffy = CurBuffy->prev;
1211
+	SETCOLOR(MT_COLOR_STATUS);
1368
+ 			break;
1212
+#ifndef USE_SLANG_CURSES
1369
+ 		case OP_SIDEBAR_SCROLL_UP:
1213
+        attr_get(&attrs, &color_pair, 0);
1370
+ 			CurBuffy = TopBuffy;
1214
+#else
1371
+ 			if ( CurBuffy != Incoming ) {
1215
+        color_pair = attr_get();
1372
+ 				calc_boundaries(menu);
1216
+#endif
1373
+ 				CurBuffy = CurBuffy->prev;
1217
+	SETCOLOR(MT_COLOR_NORMAL);
1374
+ 			}
1218
+
1375
+ 			break;
1219
+	/* draw the divider */
1376
+ 		case OP_SIDEBAR_SCROLL_DOWN:
1220
+
1377
+ 			CurBuffy = BottomBuffy;
1221
+	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1378
+ 			if ( CurBuffy->next ) {
1222
+		move(lines, SidebarWidth - delim_len);
1379
+ 				calc_boundaries(menu);
1223
+		addstr(NONULL(SidebarDelim));
1380
+ 				CurBuffy = CurBuffy->next;
1224
+#ifndef USE_SLANG_CURSES
1381
+ 			}
1225
+                mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1382
+ 			break;
1226
+#endif
1383
+ 		default:
1227
+	}
1384
+ 			return;
1228
+
1385
+ 	}
1229
+	if ( Incoming == 0 ) return 0;
1386
+ 	calc_boundaries(menu);
1230
+	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1387
+ 	draw_sidebar(menu);
1231
+
1388
+ }
1232
+	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1389
+ 
1233
+		calc_boundaries(menu);
1390
*** mutt-1.5.20-orig/sidebar.h	1969-12-31 18:00:00.000000000 -0600
1234
+	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1391
--- mutt-1.5.20-patched/sidebar.h	2009-06-19 22:07:04.000000000 -0500
1235
+
1392
***************
1236
+	tmp = TopBuffy;
1393
*** 0 ****
1237
+
1394
--- 1,36 ----
1238
+	SETCOLOR(MT_COLOR_NORMAL);
1395
+ /*
1239
+
1396
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1240
+	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1397
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1241
+		if ( tmp == CurBuffy )
1398
+  * 
1242
+			SETCOLOR(MT_COLOR_INDICATOR);
1399
+  *     This program is free software; you can redistribute it and/or modify
1243
+		else if ( tmp->msg_unread > 0 )
1400
+  *     it under the terms of the GNU General Public License as published by
1244
+			SETCOLOR(MT_COLOR_NEW);
1401
+  *     the Free Software Foundation; either version 2 of the License, or
1245
+		else if ( tmp->msg_flagged > 0 )
1402
+  *     (at your option) any later version.
1246
+		        SETCOLOR(MT_COLOR_FLAGGED);
1403
+  * 
1247
+		else
1404
+  *     This program is distributed in the hope that it will be useful,
1248
+			SETCOLOR(MT_COLOR_NORMAL);
1405
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1249
+
1406
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1250
+		move( lines, 0 );
1407
+  *     GNU General Public License for more details.
1251
+		if ( Context && !strcmp( tmp->path, Context->path ) ) {
1408
+  * 
1252
+			tmp->msg_unread = Context->unread;
1409
+  *     You should have received a copy of the GNU General Public License
1253
+			tmp->msgcount = Context->msgcount;
1410
+  *     along with this program; if not, write to the Free Software
1254
+			tmp->msg_flagged = Context->flagged;
1411
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1255
+		}
1412
+  */ 
1256
+		// check whether Maildir is a prefix of the current folder's path
1413
+ 
1257
+		short maildir_is_prefix = 0;
1414
+ #ifndef SIDEBAR_H
1258
+		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1415
+ #define SIDEBAR_H
1259
+			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1416
+ 
1260
+        		maildir_is_prefix = 1;
1417
+ struct MBOX_LIST {
1261
+		// calculate depth of current folder and generate its display name with indented spaces
1418
+ 	char *path;
1262
+		int sidebar_folder_depth = 0;
1419
+ 	int msgcount;
1263
+		char *sidebar_folder_name;
1420
+ 	int new;
1264
+		sidebar_folder_name = basename(tmp->path);
1421
+ } MBLIST;
1265
+		if ( maildir_is_prefix ) {
1422
+ 
1266
+			char *tmp_folder_name;
1423
+ /* parameter is whether or not to go to the status line */
1267
+			int i;
1424
+ /* used for omitting the last | that covers up the status bar in the index */
1268
+			tmp_folder_name = tmp->path + strlen(Maildir);
1425
+ int draw_sidebar(int);
1269
+			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1426
+ void scroll_sidebar(int, int);
1270
+				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1427
+ void set_curbuffy(char*);
1271
+			}   
1428
+ void set_buffystats(CONTEXT*);
1272
+			if (sidebar_folder_depth > 0) {
1429
+ 
1273
+				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1430
+ #endif /* SIDEBAR_H */
1274
+				for (i=0; i < sidebar_folder_depth; i++)
1275
+					sidebar_folder_name[i]=' ';
1276
+				sidebar_folder_name[i]=0;
1277
+				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1278
+			}
1279
+		}
1280
+		printw( "%.*s", SidebarWidth - delim_len + 1,
1281
+			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1282
+			tmp->msg_unread, tmp->msg_flagged));
1283
+		if (sidebar_folder_depth > 0)
1284
+		        free(sidebar_folder_name);
1285
+		lines++;
1286
+	}
1287
+	SETCOLOR(MT_COLOR_NORMAL);
1288
+	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1289
+		int i = 0;
1290
+		move( lines, 0 );
1291
+		for ( ; i < SidebarWidth - delim_len; i++ )
1292
+			addch(' ');
1293
+	}
1294
+	return 0;
1295
+}
1296
+
1297
+
1298
+void set_buffystats(CONTEXT* Context)
1299
+{
1300
+        BUFFY *tmp = Incoming;
1301
+        while(tmp) {
1302
+                if(Context && !strcmp(tmp->path, Context->path)) {
1303
+			tmp->msg_unread = Context->unread;
1304
+			tmp->msgcount = Context->msgcount;
1305
+                        break;
1306
+                }
1307
+                tmp = tmp->next;
1308
+        }
1309
+}
1310
+
1311
+void scroll_sidebar(int op, int menu)
1312
+{
1313
+        if(!SidebarWidth) return;
1314
+        if(!CurBuffy) return;
1315
+
1316
+	switch (op) {
1317
+		case OP_SIDEBAR_NEXT:
1318
+			if ( CurBuffy->next == NULL ) return;
1319
+			CurBuffy = CurBuffy->next;
1320
+			break;
1321
+		case OP_SIDEBAR_PREV:
1322
+			if ( CurBuffy->prev == NULL ) return;
1323
+			CurBuffy = CurBuffy->prev;
1324
+			break;
1325
+		case OP_SIDEBAR_SCROLL_UP:
1326
+			CurBuffy = TopBuffy;
1327
+			if ( CurBuffy != Incoming ) {
1328
+				calc_boundaries(menu);
1329
+				CurBuffy = CurBuffy->prev;
1330
+			}
1331
+			break;
1332
+		case OP_SIDEBAR_SCROLL_DOWN:
1333
+			CurBuffy = BottomBuffy;
1334
+			if ( CurBuffy->next ) {
1335
+				calc_boundaries(menu);
1336
+				CurBuffy = CurBuffy->next;
1337
+			}
1338
+			break;
1339
+		default:
1340
+			return;
1341
+	}
1342
+	calc_boundaries(menu);
1343
+	draw_sidebar(menu);
1344
+}
1345
+
1346
diff -uNp -r mutt-1.5.22.orig/sidebar.h mutt-1.5.22/sidebar.h
1347
--- mutt-1.5.22.orig/sidebar.h	Thu Jan  1 01:00:00 1970
1348
+++ mutt-1.5.22/sidebar.h	Fri Oct 18 10:18:45 2013
1349
@@ -0,0 +1,36 @@
1350
+/*
1351
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1352
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1353
+ * 
1354
+ *     This program is free software; you can redistribute it and/or modify
1355
+ *     it under the terms of the GNU General Public License as published by
1356
+ *     the Free Software Foundation; either version 2 of the License, or
1357
+ *     (at your option) any later version.
1358
+ * 
1359
+ *     This program is distributed in the hope that it will be useful,
1360
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1361
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1362
+ *     GNU General Public License for more details.
1363
+ * 
1364
+ *     You should have received a copy of the GNU General Public License
1365
+ *     along with this program; if not, write to the Free Software
1366
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1367
+ */ 
1368
+
1369
+#ifndef SIDEBAR_H
1370
+#define SIDEBAR_H
1371
+
1372
+struct MBOX_LIST {
1373
+	char *path;
1374
+	int msgcount;
1375
+	int new;
1376
+} MBLIST;
1377
+
1378
+/* parameter is whether or not to go to the status line */
1379
+/* used for omitting the last | that covers up the status bar in the index */
1380
+int draw_sidebar(int);
1381
+void scroll_sidebar(int, int);
1382
+void set_curbuffy(char*);
1383
+void set_buffystats(CONTEXT*);
1384
+
1385
+#endif /* SIDEBAR_H */
1386
--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
1387
+++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
1388
@@ -34,7 +34,7 @@
1389
 	score.c send.c sendlib.c signal.c sort.c \
1390
 	status.c system.c thread.c charset.c history.c lib.c \
1391
 	muttlib.c editmsg.c mbyte.c \
1392
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1393
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
1394
 
1395
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
1396
 
1397
--- orig/Makefile.in.orig	2013-10-25 08:23:07.000000000 +0200
1398
+++ new/Makefile.in	2013-10-25 08:26:20.000000000 +0200
1399
@@ -133,7 +133,7 @@
1400
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
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
1431
*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
1426
*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
1432
--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
1427
--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
1433
***************
1428
***************
Lines 1459-1616 Link Here
1459
  # set crypt_autosign=no
1454
  # set crypt_autosign=no
1460
  #
1455
  #
1461
  # Name: crypt_autosign
1456
  # Name: crypt_autosign
1462
*** mutt-1.5.20-orig/imap/imap.c	2009-06-14 12:19:16.000000000 -0500
1463
--- mutt-1.5.20-patched/imap/imap.c	2009-06-19 22:07:04.000000000 -0500
1464
***************
1465
*** 1521,1527 ****
1466
  
1467
      imap_munge_mbox_name (munged, sizeof (munged), name);
1468
      snprintf (command, sizeof (command),
1469
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
1470
  
1471
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
1472
      {
1473
--- 1521,1527 ----
1474
  
1475
      imap_munge_mbox_name (munged, sizeof (munged), name);
1476
      snprintf (command, sizeof (command),
1477
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
1478
  
1479
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
1480
      {
1481
*** mutt-1.5.20-orig/imap/command.c	2009-01-05 20:58:31.000000000 -0600
1482
--- mutt-1.5.20-patched/imap/command.c	2009-06-19 22:07:04.000000000 -0500
1483
***************
1484
*** 1009,1014 ****
1485
--- 1009,1021 ----
1486
  	     opened */
1487
  	  status->uidnext = oldun;
1488
  
1489
+         /* Added to make the sidebar show the correct numbers */
1490
+         if (status->messages)
1491
+         {
1492
+           inc->msgcount = status->messages;
1493
+           inc->msg_unread = status->unseen;
1494
+         }
1495
+ 
1496
          FREE (&value);
1497
          return;
1498
        }
1499
--- orig/compose.c.orig	2010-09-18 13:23:18.000000000 +0200
1500
+++ new/compose.c	2010-09-18 14:01:09.000000000 +0200
1501
@@ -80,7 +80,7 @@
1502
 
1503
 #define HDR_XOFFSET 14
1504
 #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1505
-#define W (COLS - HDR_XOFFSET)
1506
+#define W (COLS - HDR_XOFFSET - SidebarWidth)
1507
 
1508
 static char *Prompts[] =
1509
 {
1510
@@ -143,7 +143,7 @@
1511
 {
1512
   int off = 0;
1513
 
1514
-  mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: ");
1515
+  mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
1516
 
1517
   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
1518
   {
1519
@@ -175,7 +175,7 @@
1520
   }
1521
 
1522
   clrtoeol ();
1523
-  move (HDR_CRYPTINFO, 0);
1524
+  move (HDR_CRYPTINFO, SidebarWidth);
1525
   clrtoeol ();
1526
 
1527
   if ((WithCrypto & APPLICATION_PGP)
1528
@@ -195,7 +195,7 @@
1529
       && (msg->security & ENCRYPT)
1530
       && SmimeCryptAlg
1531
       && *SmimeCryptAlg) {
1532
-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
1533
+      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
1534
 		NONULL(SmimeCryptAlg));
1535
       off = 20;
1536
   }
1537
@@ -224,7 +224,7 @@
1538
     if (t && t[0] == '0' && t[1] == '\0')
1539
       t = "<random>";
1540
     
1541
-    if (c + mutt_strlen (t) + 2 >= COLS)
1542
+    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
1543
       break;
1544
 
1545
     addstr (NONULL(t));
1546
@@ -276,7 +276,7 @@
1547
 
1548
   buf[0] = 0;
1549
   rfc822_write_address (buf, sizeof (buf), addr, 1);
1550
-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
1551
+  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
1552
   mutt_paddstr (W, buf);
1553
 }
1554
 
1555
@@ -294,21 +294,21 @@
1556
   }
1557
   else
1558
   {
1559
-    mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1560
+    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1561
     mutt_paddstr (W, NONULL (msg->env->newsgroups));
1562
-    mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1563
+    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1564
     mutt_paddstr (W, NONULL (msg->env->followup_to));
1565
     if (option (OPTXCOMMENTTO))
1566
     {
1567
-      mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1568
+      mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1569
       mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1570
     }
1571
   }
1572
 #endif
1573
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1574
+  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1575
   mutt_paddstr (W, NONULL (msg->env->subject));
1576
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1577
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
1578
+  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
1579
   mutt_paddstr (W, fcc);
1580
 
1581
   if (WithCrypto)
1582
@@ -319,7 +319,7 @@
1583
 #endif
1584
 
1585
   SETCOLOR (MT_COLOR_STATUS);
1586
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
1587
+  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
1588
   BKGDSET (MT_COLOR_STATUS);
1589
   clrtoeol ();
1590
 
1591
@@ -357,7 +357,7 @@
1592
   /* redraw the expanded list so the user can see the result */
1593
   buf[0] = 0;
1594
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
1595
-  move (line, HDR_XOFFSET);
1596
+  move (line, HDR_XOFFSET+SidebarWidth);
1597
   mutt_paddstr (W, buf);
1598
   
1599
   return 0;
1600
@@ -686,7 +686,7 @@
1601
 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
1602
 	{
1603
 	  mutt_str_replace (&msg->env->subject, buf);
1604
-	  move (HDR_SUBJECT, HDR_XOFFSET);
1605
+	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
1606
 	  clrtoeol ();
1607
 	  if (msg->env->subject)
1608
 	    mutt_paddstr (W, msg->env->subject);
1609
@@ -703,7 +703,7 @@
1610
 	{
1611
 	  strfcpy (fcc, buf, fcclen);
1612
 	  mutt_pretty_mailbox (fcc, fcclen);
1613
-	  move (HDR_FCC, HDR_XOFFSET);
1614
+	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
1615
 	  mutt_paddstr (W, fcc);
1616
 	  fccSet = 1;

Return to bug 183251