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