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