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

(-)./Makefile (-27 / +9 lines)
Lines 23-30 Link Here
23
# and SLANG (WITH_MUTT_SLANG). Note that you may have to set the variables
23
# and SLANG (WITH_MUTT_SLANG). Note that you may have to set the variables
24
# COLORTERM=yes and COLORFGBG="color1;color2" in your environment to get slang
24
# COLORTERM=yes and COLORFGBG="color1;color2" in your environment to get slang
25
# function properly.
25
# function properly.
26
# The default version for slang is 1.x. Define WITH_MUTT_SLANG2 if you want
27
# to use the slang version 2.x
28
# The default version for ncurses is that which comes with the operating
26
# The default version for ncurses is that which comes with the operating
29
# system. If you want to use the ncurses supplied by the ports-system define
27
# system. If you want to use the ncurses supplied by the ports-system define
30
# WITH_MUTT_NCURSES_PORT.
28
# WITH_MUTT_NCURSES_PORT.
Lines 117-123 Link Here
117
115
118
PORTNAME=	mutt-devel
116
PORTNAME=	mutt-devel
119
PORTVERSION=	1.5.19
117
PORTVERSION=	1.5.19
120
PORTREVISION?=	0
118
PORTREVISION?=	1
121
CATEGORIES+=	mail ipv6
119
CATEGORIES+=	mail ipv6
122
.if defined(WITH_MUTT_NNTP)
120
.if defined(WITH_MUTT_NNTP)
123
CATEGORIES+=	news
121
CATEGORIES+=	news
Lines 210-223 Link Here
210
.if defined(WITH_MUTT_MAILDIR_HEADER_CACHE)
208
.if defined(WITH_MUTT_MAILDIR_HEADER_CACHE)
211
WITH_MUTT_IMAP_HEADER_CACHE=	yes
209
WITH_MUTT_IMAP_HEADER_CACHE=	yes
212
.endif
210
.endif
213
.if defined(WITH_MUTT_SIDEBAR_PATCH)
214
.if defined(WITH_MUTT_NNTP)
215
IGNORE=	cannot install: the WITH_MUTT_SIDEBAR_PATCH and WITH_MUTT_NNTP are not compatible
216
.endif
217
.if defined(WITH_MUTT_GREETING_PATCH)
218
IGNORE=	cannot install: the WITH_MUTT_SIDEBAR_PATCH and WITH_MUTT_GREETING_PATCH are not compatible
219
.endif
220
.endif
221
.if ${OSVERSION} >= 700033 || (${OSVERSION} < 700000 && ${OSVERSION} >= 602107)
211
.if ${OSVERSION} >= 700033 || (${OSVERSION} < 700000 && ${OSVERSION} >= 602107)
222
NCURSES_IS_DEFAULT=	yes
212
NCURSES_IS_DEFAULT=	yes
223
.else
213
.else
Lines 271-281 Link Here
271
.endif
261
.endif
272
.if defined(WITH_MUTT_SLANG) || defined(WITH_SLANG)
262
.if defined(WITH_MUTT_SLANG) || defined(WITH_SLANG)
273
MUTT_USES_SLANG=	yes
263
MUTT_USES_SLANG=	yes
274
MUTT_USES_SLANG1=	yes
275
.endif
276
.if defined(WITH_MUTT_SLANG2)
277
MUTT_USES_SLANG=	yes
278
MUTT_USES_SLANG2=	yes
279
.endif
264
.endif
280
.if defined(WITH_MUTT_NCURSES) && !defined(MUTT_USES_SLANG)
265
.if defined(WITH_MUTT_NCURSES) && !defined(MUTT_USES_SLANG)
281
MUTT_USES_NCURSES=	yes
266
MUTT_USES_NCURSES=	yes
Lines 283-289 Link Here
283
.if !defined(MUTT_USES_SLANG) && !defined(WITHOUT_MUTT_SLANG) && !defined(MUTT_USES_NCURSES)
268
.if !defined(MUTT_USES_SLANG) && !defined(WITHOUT_MUTT_SLANG) && !defined(MUTT_USES_NCURSES)
284
.if defined(SLANG_IS_DEFAULT)
269
.if defined(SLANG_IS_DEFAULT)
285
MUTT_USES_SLANG=	yes
270
MUTT_USES_SLANG=	yes
286
MUTT_USES_SLANG1=	yes
287
.elif defined(NCURSES_IS_DEFAULT)
271
.elif defined(NCURSES_IS_DEFAULT)
288
MUTT_USES_NCURSES=	yes
272
MUTT_USES_NCURSES=	yes
289
.endif
273
.endif
Lines 314-322 Link Here
314
.if defined(MUTT_USES_NCURSES_PORT)
298
.if defined(MUTT_USES_NCURSES_PORT)
315
LIB_DEPENDS+=	ncurses.5:${PORTSDIR}/devel/ncurses
299
LIB_DEPENDS+=	ncurses.5:${PORTSDIR}/devel/ncurses
316
CFLAGS+=	-I${LOCALBASE}/include/ncurses -I${LOCALBASE}/include
300
CFLAGS+=	-I${LOCALBASE}/include/ncurses -I${LOCALBASE}/include
317
.elif defined(MUTT_USES_SLANG1)
301
.elif defined(MUTT_USES_SLANG)
318
LIB_DEPENDS+=	slang.1:${PORTSDIR}/devel/libslang
319
.elif defined(MUTT_USES_SLANG2)
320
LIB_DEPENDS+=	slang.2:${PORTSDIR}/devel/libslang2
302
LIB_DEPENDS+=	slang.2:${PORTSDIR}/devel/libslang2
321
.endif
303
.endif
322
.if defined(WITH_MUTT_CYRUS_SASL2)
304
.if defined(WITH_MUTT_CYRUS_SASL2)
Lines 455-468 Link Here
455
PATCHFILES+=	p0-patch-${DW_MBOX_PATCH_VERSION}.dw.mbox-hook.1:dw
437
PATCHFILES+=	p0-patch-${DW_MBOX_PATCH_VERSION}.dw.mbox-hook.1:dw
456
.endif
438
.endif
457
.if defined(WITH_MUTT_SIDEBAR_PATCH)
439
.if defined(WITH_MUTT_SIDEBAR_PATCH)
458
SIDEBAR_PATCH=	patch-1.5.18.sidebar.20080611.txt
459
DISTFILES+=	${SIDEBAR_PATCH}:tchan
460
XML_NEEDED=	yes
440
XML_NEEDED=	yes
461
pre-patch::
441
.if defined(WITH_MUTT_NNTP)
462
	@${GUNZIP_CMD} -c ${DISTDIR}/${DIST_SUBDIR}/${SIDEBAR_PATCH} > ${WRKDIR}/patch-sidebar
442
post-patch::
463
	@${REINPLACE_CMD} -E '/^diff.*\/Makefile.in$$/,/^diff/d' \
443
	@${PATCH} ${PATCH_ARGS} -p0 < ${PATCHDIR}/extra-patch-sidebar-nntp
464
		 ${WRKDIR}/patch-sidebar
444
.else
465
	@${PATCH} ${PATCH_ARGS} -p1 < ${WRKDIR}/patch-sidebar
445
post-patch::
446
	@${PATCH} ${PATCH_ARGS} -p0 < ${PATCHDIR}/extra-patch-sidebar
447
.endif
466
.endif
448
.endif
467
.if defined(WITH_MUTT_GREETING_PATCH)
449
.if defined(WITH_MUTT_GREETING_PATCH)
468
PATCHFILES+=	mutt-${VC_PATCH_VERSION}.vc.greeting:vc
450
PATCHFILES+=	mutt-${VC_PATCH_VERSION}.vc.greeting:vc
(-)./distinfo (-3 lines)
Lines 22-27 Link Here
22
MD5 (mutt/mutt-1.5.16.vc.greeting) = 4bd9beeb74d075e4418e86e8ed887aa0
22
MD5 (mutt/mutt-1.5.16.vc.greeting) = 4bd9beeb74d075e4418e86e8ed887aa0
23
SHA256 (mutt/mutt-1.5.16.vc.greeting) = cf05aeab5f1813864aa72b68f59a579c46dacf2fbd8e5fd064b920012320b986
23
SHA256 (mutt/mutt-1.5.16.vc.greeting) = cf05aeab5f1813864aa72b68f59a579c46dacf2fbd8e5fd064b920012320b986
24
SIZE (mutt/mutt-1.5.16.vc.greeting) = 4526
24
SIZE (mutt/mutt-1.5.16.vc.greeting) = 4526
25
MD5 (mutt/patch-1.5.18.sidebar.20080611.txt) = 0f6565cecfc7fd72eaf33756abbc3088
26
SHA256 (mutt/patch-1.5.18.sidebar.20080611.txt) = a94bc11072dbfe9a4a7d5a761105bf40a496bb2706e9940978de7b64d1555fa7
27
SIZE (mutt/patch-1.5.18.sidebar.20080611.txt) = 52201
(-)./files/extra-patch-sidebar (+1180 lines)
Line 0 Link Here
1
--- Makefile.am	2009-01-05 20:20:53.000000000 +0100
2
+++ Makefile.am	2009-02-16 17:07:44.000000000 +0100
3
@@ -29,7 +29,7 @@
4
 	score.c send.c sendlib.c signal.c sort.c \
5
 	status.c system.c thread.c charset.c history.c lib.c \
6
 	muttlib.c editmsg.c mbyte.c \
7
-	url.c ascii.c crypt-mod.c crypt-mod.h
8
+	url.c ascii.c crypt-mod.c crypt-mod.h sidebar.c
9
 
10
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
11
 
12
--- Makefile.in	2009-01-05 20:24:13.000000000 +0100
13
+++ Makefile.in	2009-02-16 17:07:44.000000000 +0100
14
@@ -83,7 +83,7 @@
15
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
16
 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
17
 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
18
-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT)
19
+	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) sidebar.$(OBJEXT)
20
 am__objects_1 = patchlist.$(OBJEXT)
21
 nodist_mutt_OBJECTS = $(am__objects_1)
22
 mutt_OBJECTS = $(am_mutt_OBJECTS) $(nodist_mutt_OBJECTS)
23
@@ -307,7 +307,8 @@
24
 	score.c send.c sendlib.c signal.c sort.c \
25
 	status.c system.c thread.c charset.c history.c lib.c \
26
 	muttlib.c editmsg.c mbyte.c \
27
-	url.c ascii.c crypt-mod.c crypt-mod.h
28
+	url.c ascii.c crypt-mod.c crypt-mod.h \
29
+      sidebar.c
30
 
31
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
32
 mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
33
@@ -339,7 +340,7 @@
34
 	README.SSL smime.h \
35
 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
36
 	ChangeLog mkchangelog.sh mutt_idna.h \
37
-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in
38
+	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
39
 
40
 EXTRA_SCRIPTS = smime_keys
41
 mutt_dotlock_SOURCES = mutt_dotlock.c
42
--- OPS	2008-03-19 21:07:57.000000000 +0100
43
+++ OPS	2009-02-16 17:07:44.000000000 +0100
44
@@ -178,3 +178,8 @@
45
 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
46
 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
47
 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
48
+OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
49
+OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
50
+OP_SIDEBAR_NEXT "go down to next mailbox"
51
+OP_SIDEBAR_PREV "go to previous mailbox"
52
+OP_SIDEBAR_OPEN "open hilighted mailbox"
53
--- PATCHES	2008-03-19 21:07:06.000000000 +0100
54
+++ PATCHES	2009-02-16 17:07:44.000000000 +0100
55
@@ -0,0 +1 @@
56
+patch-1.5.19.sidebar.20080611.txt
57
--- buffy.c	2008-08-30 01:39:48.000000000 +0200
58
+++ buffy.c	2009-02-16 17:07:44.000000000 +0100
59
@@ -260,6 +260,7 @@
60
   struct stat contex_sb;
61
   time_t t;
62
 
63
+CONTEXT *ctx;
64
 #ifdef USE_IMAP
65
   /* update postponed count as well, on force */
66
   if (force)
67
--- buffy.h	2008-05-22 20:25:19.000000000 +0200
68
+++ buffy.h	2009-02-16 17:07:44.000000000 +0100
69
@@ -25,7 +25,12 @@
70
   char *path;
71
   off_t size;
72
   struct buffy_t *next;
73
+  struct buffy_t *prev;
74
   short new;			/* mailbox has new mail */
75
+  short has_new;		/* set it new if new and not read */
76
+  int msgcount;			/* total number of messages */
77
+  int msg_unread;		/* number of unread messages */
78
+  int msg_flagged;		/* number of flagged messages */
79
   short notified;		/* user has been notified */
80
   short magic;			/* mailbox type */
81
   short newly_created;		/* mbox or mmdf just popped into existence */
82
--- color.c	2008-03-19 21:07:57.000000000 +0100
83
+++ color.c	2009-02-16 17:07:44.000000000 +0100
84
@@ -93,6 +93,8 @@
85
   { "bold",		MT_COLOR_BOLD },
86
   { "underline",	MT_COLOR_UNDERLINE },
87
   { "index",		MT_COLOR_INDEX },
88
+  { "sidebar_new",	MT_COLOR_NEW },
89
+  { "sidebar_flagged",	MT_COLOR_FLAGGED },
90
   { NULL,		0 }
91
 };
92
 
93
--- compose.c	2009-01-05 20:20:53.000000000 +0100
94
+++ compose.c	2009-02-16 17:07:44.000000000 +0100
95
@@ -72,7 +72,7 @@
96
 
97
 #define HDR_XOFFSET 10
98
 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
99
-#define W (COLS - HDR_XOFFSET)
100
+#define W (COLS - HDR_XOFFSET - SidebarWidth)
101
 
102
 static char *Prompts[] =
103
 {
104
@@ -115,16 +115,16 @@
105
   if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
106
   {     
107
     if (!msg->security)
108
-      mvaddstr (HDR_CRYPT, 0,     "Security: ");
109
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "Security: ");
110
     else if (msg->security & APPLICATION_SMIME)
111
-      mvaddstr (HDR_CRYPT, 0,     "  S/MIME: ");
112
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "  S/MIME: ");
113
     else if (msg->security & APPLICATION_PGP)
114
-      mvaddstr (HDR_CRYPT, 0,     "     PGP: ");
115
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "     PGP: ");
116
   }
117
   else if ((WithCrypto & APPLICATION_SMIME))
118
-    mvaddstr (HDR_CRYPT, 0,     "  S/MIME: ");
119
+    mvaddstr (HDR_CRYPT, SidebarWidth,     "  S/MIME: ");
120
   else if ((WithCrypto & APPLICATION_PGP))
121
-    mvaddstr (HDR_CRYPT, 0,     "     PGP: ");
122
+    mvaddstr (HDR_CRYPT, SidebarWidth,     "     PGP: ");
123
   else
124
     return;
125
 
126
@@ -148,7 +148,7 @@
127
     }
128
   clrtoeol ();
129
 
130
-  move (HDR_CRYPTINFO, 0);
131
+  move (HDR_CRYPTINFO, SidebarWidth);
132
   clrtoeol ();
133
   if ((WithCrypto & APPLICATION_PGP)
134
       && msg->security & APPLICATION_PGP  && msg->security & SIGN)
135
@@ -164,7 +164,7 @@
136
       && (msg->security & ENCRYPT)
137
       && SmimeCryptAlg
138
       && *SmimeCryptAlg) {
139
-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
140
+      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
141
 		NONULL(SmimeCryptAlg));
142
       off = 20;
143
   }
144
@@ -178,7 +178,7 @@
145
   int c;
146
   char *t;
147
 
148
-  mvaddstr (HDR_MIX, 0,     "     Mix: ");
149
+  mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
150
 
151
   if (!chain)
152
   {
153
@@ -193,7 +193,7 @@
154
     if (t && t[0] == '0' && t[1] == '\0')
155
       t = "<random>";
156
     
157
-    if (c + mutt_strlen (t) + 2 >= COLS)
158
+    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
159
       break;
160
 
161
     addstr (NONULL(t));
162
@@ -245,7 +245,7 @@
163
 
164
   buf[0] = 0;
165
   rfc822_write_address (buf, sizeof (buf), addr, 1);
166
-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
167
+  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
168
   mutt_paddstr (W, buf);
169
 }
170
 
171
@@ -255,10 +255,10 @@
172
   draw_envelope_addr (HDR_TO, msg->env->to);
173
   draw_envelope_addr (HDR_CC, msg->env->cc);
174
   draw_envelope_addr (HDR_BCC, msg->env->bcc);
175
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
176
+  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
177
   mutt_paddstr (W, NONULL (msg->env->subject));
178
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
179
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
180
+  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
181
   mutt_paddstr (W, fcc);
182
 
183
   if (WithCrypto)
184
@@ -269,7 +269,7 @@
185
 #endif
186
 
187
   SETCOLOR (MT_COLOR_STATUS);
188
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
189
+  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
190
   BKGDSET (MT_COLOR_STATUS);
191
   clrtoeol ();
192
 
193
@@ -307,7 +307,7 @@
194
   /* redraw the expanded list so the user can see the result */
195
   buf[0] = 0;
196
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
197
-  move (line, HDR_XOFFSET);
198
+  move (line, HDR_XOFFSET+SidebarWidth);
199
   mutt_paddstr (W, buf);
200
   
201
   return 0;
202
@@ -552,7 +552,7 @@
203
 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
204
 	{
205
 	  mutt_str_replace (&msg->env->subject, buf);
206
-	  move (HDR_SUBJECT, HDR_XOFFSET);
207
+	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
208
 	  clrtoeol ();
209
 	  if (msg->env->subject)
210
 	    mutt_paddstr (W, msg->env->subject);
211
@@ -569,7 +569,7 @@
212
 	{
213
 	  strfcpy (fcc, buf, fcclen);
214
 	  mutt_pretty_mailbox (fcc, fcclen);
215
-	  move (HDR_FCC, HDR_XOFFSET);
216
+	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
217
 	  mutt_paddstr (W, fcc);
218
 	  fccSet = 1;
219
 	}
220
--- curs_main.c	2009-01-05 20:20:53.000000000 +0100
221
+++ curs_main.c	2009-02-16 17:07:44.000000000 +0100
222
@@ -27,6 +27,9 @@
223
 #include "mapping.h"
224
 #include "sort.h"
225
 #include "mx.h"
226
+#include "attach.h"
227
+#include "buffy.h"
228
+#include "sidebar.h"
229
 
230
 #ifdef USE_POP
231
 #include "pop.h"
232
@@ -523,8 +526,12 @@
233
        menu->redraw |= REDRAW_STATUS;
234
      if (do_buffy_notify)
235
      {
236
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
237
- 	beep ();
238
+       if (mutt_buffy_notify ())
239
+       {
240
+         menu->redraw |= REDRAW_FULL;
241
+         if (option (OPTBEEPNEW))
242
+           beep ();
243
+       }
244
      }
245
      else
246
        do_buffy_notify = 1;
247
@@ -536,6 +543,7 @@
248
     if (menu->redraw & REDRAW_FULL)
249
     {
250
       menu_redraw_full (menu);
251
+      draw_sidebar(menu->menu);
252
       mutt_show_error ();
253
     }
254
 
255
@@ -558,10 +566,13 @@
256
 
257
       if (menu->redraw & REDRAW_STATUS) 
258
       {
259
+        DrawFullLine = 1;
260
 	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
261
+        DrawFullLine = 0;
262
 	CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
263
 	SETCOLOR (MT_COLOR_STATUS);
264
         BKGDSET (MT_COLOR_STATUS);
265
+        set_buffystats(Context);
266
 	mutt_paddstr (COLS, buf);
267
 	SETCOLOR (MT_COLOR_NORMAL);
268
         BKGDSET (MT_COLOR_NORMAL);
269
@@ -575,7 +586,7 @@
270
 	menu->oldcurrent = -1;
271
 
272
       if (option (OPTARROWCURSOR))
273
-	move (menu->current - menu->top + menu->offset, 2);
274
+	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
275
       else if (option (OPTBRAILLEFRIENDLY))
276
 	move (menu->current - menu->top + menu->offset, 0);
277
       else
278
@@ -1048,6 +1059,7 @@
279
 	  menu->redraw = REDRAW_FULL;
280
 	break;
281
 
282
+      case OP_SIDEBAR_OPEN:
283
       case OP_MAIN_CHANGE_FOLDER:
284
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
285
       
286
@@ -1079,7 +1091,11 @@
287
 	{
288
 	  mutt_buffy (buf, sizeof (buf));
289
 
290
-	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
291
+          if ( op == OP_SIDEBAR_OPEN ) {
292
+              if(!CurBuffy)
293
+                break;
294
+            strncpy( buf, CurBuffy->path, sizeof(buf) );  
295
+	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
296
 	  {
297
 	    if (menu->menu == MENU_PAGER)
298
 	    {
299
@@ -1097,6 +1113,7 @@
300
 	}
301
 
302
 	mutt_expand_path (buf, sizeof (buf));
303
+        set_curbuffy(buf);
304
 	if (mx_get_magic (buf) <= 0)
305
 	{
306
 	  mutt_error (_("%s is not a mailbox."), buf);
307
@@ -2176,6 +2193,12 @@
308
 	mutt_what_key();
309
 	break;
310
 
311
+      case OP_SIDEBAR_SCROLL_UP:
312
+      case OP_SIDEBAR_SCROLL_DOWN:
313
+      case OP_SIDEBAR_NEXT:
314
+      case OP_SIDEBAR_PREV:
315
+        scroll_sidebar(op, menu->menu);
316
+        break;
317
       default:
318
 	if (menu->menu == MENU_MAIN)
319
 	  km_error_key (MENU_MAIN);
320
--- flags.c	2009-01-04 00:27:10.000000000 +0100
321
+++ flags.c	2009-02-16 17:07:44.000000000 +0100
322
@@ -22,8 +22,10 @@
323
 
324
 #include "mutt.h"
325
 #include "mutt_curses.h"
326
+#include "mutt_menu.h"
327
 #include "sort.h"
328
 #include "mx.h"
329
+#include "sidebar.h"
330
 
331
 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
332
 {
333
@@ -263,6 +265,7 @@
334
    */
335
   if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
336
     h->searched = 0;
337
+	draw_sidebar(0);
338
 }
339
 
340
 void mutt_tag_set_flag (int flag, int bf)
341
--- functions.h	2009-01-05 20:20:53.000000000 +0100
342
+++ functions.h	2009-02-16 17:07:44.000000000 +0100
343
@@ -168,6 +168,11 @@
344
   { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
345
 
346
 
347
+ { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
348
+ { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
349
+ { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
350
+ { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
351
+ { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
352
   { NULL,			0,				NULL }
353
 };
354
 
355
@@ -266,6 +271,11 @@
356
 
357
   { "what-key",		OP_WHAT_KEY,		NULL },
358
 
359
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
360
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
361
+  { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
362
+  { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
363
+  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
364
   { NULL,		0,				NULL }
365
 };
366
 
367
--- globals.h	2009-01-04 00:27:10.000000000 +0100
368
+++ globals.h	2009-02-16 17:07:44.000000000 +0100
369
@@ -116,6 +116,7 @@
370
 WHERE char *SendCharset;
371
 WHERE char *Sendmail;
372
 WHERE char *Shell;
373
+WHERE char *SidebarDelim;
374
 WHERE char *Signature;
375
 WHERE char *SimpleSearch;
376
 #if USE_SMTP
377
@@ -205,6 +206,9 @@
378
 WHERE short ScoreThresholdRead;
379
 WHERE short ScoreThresholdFlag;
380
 
381
+WHERE struct buffy_t *CurBuffy INITVAL(0);
382
+WHERE short DrawFullLine INITVAL(0);
383
+WHERE short SidebarWidth;
384
 #ifdef USE_IMAP
385
 WHERE short ImapKeepalive;
386
 WHERE short ImapPipelineDepth;
387
--- init.h	2009-01-05 20:20:53.000000000 +0100
388
+++ init.h	2009-02-16 17:07:44.000000000 +0100
389
@@ -1572,6 +1572,22 @@
390
   ** you may \fIunset\fP this setting.
391
   ** (Crypto only)
392
   */
393
+  {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
394
+  /*
395
+  ** .pp
396
+  ** This specifies the delimiter between the sidebar (if visible) and 
397
+  ** other screens.
398
+  */
399
+  { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
400
+  /*
401
+  ** .pp
402
+  ** This specifies whether or not to show sidebar (left-side list of folders).
403
+  */
404
+  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
405
+  /*
406
+  ** .pp
407
+  ** The width of the sidebar.
408
+  */
409
   { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
410
   /*
411
   ** .pp
412
--- mailbox.h	2008-03-19 21:07:06.000000000 +0100
413
+++ mailbox.h	2009-02-16 17:07:44.000000000 +0100
414
@@ -27,6 +27,7 @@
415
 #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
416
 				* safe_fopen() for mbox-style folders.
417
 				*/
418
+#define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
419
 
420
 /* mx_open_new_message() */
421
 #define M_ADD_FROM	1	/* add a From_ line */
422
--- mbox.c	2008-08-15 20:30:12.000000000 +0200
423
+++ mbox.c	2009-02-16 17:07:44.000000000 +0100
424
@@ -100,6 +100,7 @@
425
     mutt_perror (ctx->path);
426
     return (-1);
427
   }
428
+  ctx->atime = sb.st_atime;
429
   ctx->mtime = sb.st_mtime;
430
   ctx->size = sb.st_size;
431
 
432
@@ -255,6 +256,7 @@
433
 
434
   ctx->size = sb.st_size;
435
   ctx->mtime = sb.st_mtime;
436
+  ctx->atime = sb.st_atime;
437
 
438
 #ifdef NFS_ATTRIBUTE_HACK
439
   if (sb.st_mtime > sb.st_atime)
440
--- menu.c	2009-01-05 20:20:53.000000000 +0100
441
+++ menu.c	2009-02-16 17:07:44.000000000 +0100
442
@@ -24,6 +24,7 @@
443
 #include "mutt_curses.h"
444
 #include "mutt_menu.h"
445
 #include "mbyte.h"
446
+#include "sidebar.h"
447
 
448
 #include <string.h>
449
 #include <stdlib.h>
450
@@ -156,7 +157,7 @@
451
 {
452
   char *scratch = safe_strdup (s);
453
   int shift = option (OPTARROWCURSOR) ? 3 : 0;
454
-  int cols = COLS - shift;
455
+  int cols = COLS - shift - SidebarWidth;
456
 
457
   mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
458
   s[n - 1] = 0;
459
@@ -207,6 +208,7 @@
460
   char buf[LONG_STRING];
461
   int i;
462
 
463
+  draw_sidebar(1);
464
   for (i = menu->top; i < menu->top + menu->pagelen; i++)
465
   {
466
     if (i < menu->max)
467
@@ -217,7 +219,7 @@
468
       if (option (OPTARROWCURSOR))
469
       {
470
         attrset (menu->color (i));
471
-	CLEARLINE (i - menu->top + menu->offset);
472
+	CLEARLINE_WIN (i - menu->top + menu->offset);
473
 
474
 	if (i == menu->current)
475
 	{
476
@@ -246,14 +248,14 @@
477
 	  BKGDSET (MT_COLOR_INDICATOR);
478
 	}
479
 
480
-	CLEARLINE (i - menu->top + menu->offset);
481
+	CLEARLINE_WIN (i - menu->top + menu->offset);
482
 	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
483
         SETCOLOR (MT_COLOR_NORMAL);
484
         BKGDSET (MT_COLOR_NORMAL);
485
       }
486
     }
487
     else
488
-      CLEARLINE (i - menu->top + menu->offset);
489
+      CLEARLINE_WIN (i - menu->top + menu->offset);
490
   }
491
   menu->redraw = 0;
492
 }
493
@@ -268,7 +270,7 @@
494
     return;
495
   }
496
   
497
-  move (menu->oldcurrent + menu->offset - menu->top, 0);
498
+  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
499
   SETCOLOR (MT_COLOR_NORMAL);
500
   BKGDSET (MT_COLOR_NORMAL);
501
 
502
@@ -283,13 +285,13 @@
503
       clrtoeol ();
504
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
505
       menu_pad_string (buf, sizeof (buf));
506
-      move (menu->oldcurrent + menu->offset - menu->top, 3);
507
+      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
508
       print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
509
       SETCOLOR (MT_COLOR_NORMAL);
510
     }
511
 
512
     /* now draw it in the new location */
513
-    move (menu->current + menu->offset - menu->top, 0);
514
+    move (menu->current + menu->offset - menu->top, SidebarWidth);
515
     attrset (menu->color (menu->current));
516
     ADDCOLOR (MT_COLOR_INDICATOR);
517
     addstr ("->");
518
@@ -310,7 +312,7 @@
519
     attrset (menu->color (menu->current));
520
     ADDCOLOR (MT_COLOR_INDICATOR);
521
     BKGDSET (MT_COLOR_INDICATOR);
522
-    CLEARLINE (menu->current - menu->top + menu->offset);
523
+    CLEARLINE_WIN (menu->current - menu->top + menu->offset);
524
     print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
525
     SETCOLOR (MT_COLOR_NORMAL);
526
     BKGDSET (MT_COLOR_NORMAL);
527
@@ -322,7 +324,7 @@
528
 {
529
   char buf[LONG_STRING];
530
   
531
-  move (menu->current + menu->offset - menu->top, 0);
532
+  move (menu->current + menu->offset - menu->top, SidebarWidth);
533
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
534
   menu_pad_string (buf, sizeof (buf));
535
 
536
@@ -882,7 +884,7 @@
537
     
538
     
539
     if (option (OPTARROWCURSOR))
540
-      move (menu->current - menu->top + menu->offset, 2);
541
+      move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
542
     else if (option (OPTBRAILLEFRIENDLY))
543
       move (menu->current - menu->top + menu->offset, 0);
544
     else
545
--- mutt.h	2008-09-26 00:00:03.000000000 +0200
546
+++ mutt.h	2009-02-16 17:07:44.000000000 +0100
547
@@ -409,6 +409,7 @@
548
   OPTSAVEEMPTY,
549
   OPTSAVENAME,
550
   OPTSCORE,
551
+  OPTSIDEBAR,
552
   OPTSIGDASHES,
553
   OPTSIGONTOP,
554
   OPTSORTRE,
555
@@ -843,6 +844,7 @@
556
 {
557
   char *path;
558
   FILE *fp;
559
+  time_t atime;
560
   time_t mtime;
561
   off_t size;
562
   off_t vsize;
563
@@ -877,6 +879,7 @@
564
   unsigned int quiet : 1;	/* inhibit status messages? */
565
   unsigned int collapsed : 1;   /* are all threads collapsed? */
566
   unsigned int closing : 1;	/* mailbox is being closed */
567
+  unsigned int peekonly : 1;	/* just taking a glance, revert atime */
568
 
569
   /* driver hooks */
570
   void *data;			/* driver specific data */
571
--- mutt_curses.h	2008-03-19 21:07:57.000000000 +0100
572
+++ mutt_curses.h	2009-02-16 17:07:44.000000000 +0100
573
@@ -64,6 +64,7 @@
574
 #undef lines
575
 #endif /* lines */
576
 
577
+#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
578
 #define CLEARLINE(x) move(x,0), clrtoeol()
579
 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
580
 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
581
@@ -126,6 +127,8 @@
582
   MT_COLOR_BOLD,
583
   MT_COLOR_UNDERLINE,
584
   MT_COLOR_INDEX,
585
+  MT_COLOR_NEW,
586
+  MT_COLOR_FLAGGED,
587
   MT_COLOR_MAX
588
 };
589
 
590
--- muttlib.c	2009-01-05 20:20:53.000000000 +0100
591
+++ muttlib.c	2009-02-16 17:07:44.000000000 +0100
592
@@ -1217,6 +1217,8 @@
593
 	  pl = pw = 1;
594
 
595
 	/* see if there's room to add content, else ignore */
596
+        if ( DrawFullLine )
597
+        {
598
 	if ((col < COLS && wlen < destlen) || soft)
599
 	{
600
 	  int pad;
601
@@ -1259,6 +1261,52 @@
602
 	  col += wid;
603
 	  src += pl;
604
 	}
605
+        }
606
+        else
607
+        {
608
+	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
609
+        {
610
+	  int pad;
611
+
612
+	  /* get contents after padding */
613
+	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
614
+	  len = mutt_strlen (buf);
615
+	  wid = mutt_strwidth (buf);
616
+
617
+	  /* try to consume as many columns as we can, if we don't have
618
+	   * memory for that, use as much memory as possible */
619
+	  pad = (COLS - SidebarWidth - col - wid) / pw;
620
+	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
621
+	    pad = ((signed)(destlen - wlen - len)) / pl;
622
+	  if (pad > 0)
623
+	  {
624
+	    while (pad--)
625
+	    {
626
+	      memcpy (wptr, src, pl);
627
+	      wptr += pl;
628
+	      wlen += pl;
629
+	      col += pw;
630
+	    }
631
+	  }
632
+	  else if (soft && pad < 0)
633
+	  {
634
+	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
635
+	    *wptr = 0;
636
+	    /* make sure right part is at most as wide as display */
637
+	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
638
+	    /* truncate left so that right part fits completely in */
639
+	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
640
+	    wptr = dest + wlen;
641
+	  }
642
+	  if (len + wlen > destlen)
643
+	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
644
+	  memcpy (wptr, buf, len);
645
+	  wptr += len;
646
+	  wlen += len;
647
+	  col += wid;
648
+	  src += pl;
649
+	}
650
+        }
651
 	break; /* skip rest of input */
652
       }
653
       else if (ch == '|')
654
--- mx.c	2009-01-05 20:20:53.000000000 +0100
655
+++ mx.c	2009-02-16 17:07:44.000000000 +0100
656
@@ -611,6 +611,7 @@
657
  *		M_APPEND	open mailbox for appending
658
  *		M_READONLY	open mailbox in read-only mode
659
  *		M_QUIET		only print error messages
660
+ *		M_PEEK		revert atime where applicable
661
  *	ctx	if non-null, context struct to use
662
  */
663
 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
664
@@ -633,6 +634,8 @@
665
     ctx->quiet = 1;
666
   if (flags & M_READONLY)
667
     ctx->readonly = 1;
668
+  if (flags & M_PEEK)
669
+    ctx->peekonly = 1;
670
 
671
   if (flags & (M_APPEND|M_NEWFOLDER))
672
   {
673
@@ -732,9 +735,21 @@
674
 void mx_fastclose_mailbox (CONTEXT *ctx)
675
 {
676
   int i;
677
+#ifndef BUFFY_SIZE
678
+  struct utimbuf ut;
679
+#endif
680
 
681
   if(!ctx) 
682
     return;
683
+#ifndef BUFFY_SIZE
684
+  /* fix up the times so buffy won't get confused */
685
+  if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
686
+  {
687
+    ut.actime = ctx->atime;
688
+    ut.modtime = ctx->mtime;
689
+    utime (ctx->path, &ut); 
690
+  }
691
+#endif
692
 
693
   if (ctx->mx_close)
694
     ctx->mx_close (ctx);
695
--- pager.c	2009-01-05 20:20:53.000000000 +0100
696
+++ pager.c	2009-02-16 17:07:44.000000000 +0100
697
@@ -29,6 +29,7 @@
698
 #include "pager.h"
699
 #include "attach.h"
700
 #include "mbyte.h"
701
+#include "sidebar.h"
702
 
703
 #include "mutt_crypt.h"
704
 
705
@@ -1060,6 +1061,8 @@
706
   mbstate_t mbstate;
707
 
708
   int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
709
+
710
+  wrap_cols -= SidebarWidth;
711
   
712
   /* FIXME: this should come from lineInfo */
713
   memset(&mbstate, 0, sizeof(mbstate));
714
@@ -1694,7 +1697,7 @@
715
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
716
     {
717
       do {
718
-	move (bodyoffset, 0);
719
+	move (bodyoffset, SidebarWidth);
720
 	curline = oldtopline = topline;
721
 	lines = 0;
722
 	force_redraw = 0;
723
@@ -1707,6 +1710,7 @@
724
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
725
 	    lines++;
726
 	  curline++;
727
+  	  move(lines + bodyoffset, SidebarWidth);
728
 	}
729
 	last_offset = lineInfo[curline].offset;
730
       } while (force_redraw);
731
@@ -1720,6 +1724,7 @@
732
 	  addch ('~');
733
 	addch ('\n');
734
 	lines++;
735
+  	move(lines + bodyoffset, SidebarWidth);
736
       }
737
       /* We are going to update the pager status bar, so it isn't
738
        * necessary to reset to normal color now. */
739
@@ -1743,22 +1748,22 @@
740
       /* print out the pager status bar */
741
       SETCOLOR (MT_COLOR_STATUS);
742
       BKGDSET (MT_COLOR_STATUS);
743
-      CLEARLINE (statusoffset);
744
+      CLEARLINE_WIN (statusoffset);
745
       if (IsHeader (extra))
746
       {
747
-	size_t l1 = COLS * MB_LEN_MAX;
748
+	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
749
 	size_t l2 = sizeof (buffer);
750
 	hfi.hdr = extra->hdr;
751
 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
752
       }
753
       else if (IsMsgAttach (extra))
754
       {
755
-	size_t l1 = COLS * MB_LEN_MAX;
756
+	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
757
 	size_t l2 = sizeof (buffer);
758
 	hfi.hdr = extra->bdy->hdr;
759
 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
760
       }
761
-      mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ?  buffer : banner);
762
+      mutt_paddstr (COLS-SidebarWidth, IsHeader (extra) || IsMsgAttach (extra) ?  buffer : banner);
763
       BKGDSET (MT_COLOR_NORMAL);
764
       SETCOLOR (MT_COLOR_NORMAL);
765
     }
766
@@ -1768,18 +1773,23 @@
767
       /* redraw the pager_index indicator, because the
768
        * flags for this message might have changed. */
769
       menu_redraw_current (index);
770
+      draw_sidebar(MENU_PAGER);
771
 
772
       /* print out the index status bar */
773
       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
774
  
775
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
776
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
777
       SETCOLOR (MT_COLOR_STATUS);
778
       BKGDSET (MT_COLOR_STATUS);
779
-      mutt_paddstr (COLS, buffer);
780
+      mutt_paddstr (COLS-SidebarWidth, buffer);
781
       SETCOLOR (MT_COLOR_NORMAL);
782
       BKGDSET (MT_COLOR_NORMAL);
783
     }
784
 
785
+    /* if we're not using the index, update every time */
786
+    if ( index == 0 )
787
+      draw_sidebar(MENU_PAGER);
788
+
789
     redraw = 0;
790
 
791
     if (option(OPTBRAILLEFRIENDLY)) {
792
@@ -2671,6 +2681,13 @@
793
 	mutt_what_key ();
794
 	break;
795
 
796
+      case OP_SIDEBAR_SCROLL_UP:
797
+      case OP_SIDEBAR_SCROLL_DOWN:
798
+      case OP_SIDEBAR_NEXT:
799
+      case OP_SIDEBAR_PREV:
800
+	scroll_sidebar(ch, MENU_PAGER);
801
+ 	break;
802
+
803
       default:
804
 	ch = -1;
805
 	break;
806
--- sidebar.c	1970-01-01 01:00:00.000000000 +0100
807
+++ sidebar.c	2009-02-16 17:07:44.000000000 +0100
808
@@ -0,0 +1,333 @@
809
+/*
810
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
811
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
812
+ * 
813
+ *     This program is free software; you can redistribute it and/or modify
814
+ *     it under the terms of the GNU General Public License as published by
815
+ *     the Free Software Foundation; either version 2 of the License, or
816
+ *     (at your option) any later version.
817
+ * 
818
+ *     This program is distributed in the hope that it will be useful,
819
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
820
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
821
+ *     GNU General Public License for more details.
822
+ * 
823
+ *     You should have received a copy of the GNU General Public License
824
+ *     along with this program; if not, write to the Free Software
825
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
826
+ */ 
827
+
828
+
829
+#if HAVE_CONFIG_H
830
+# include "config.h"
831
+#endif
832
+
833
+#include "mutt.h"
834
+#include "mutt_menu.h"
835
+#include "mutt_curses.h"
836
+#include "sidebar.h"
837
+#include "buffy.h"
838
+#include <libgen.h>
839
+#include "keymap.h"
840
+#include <stdbool.h>
841
+
842
+/*BUFFY *CurBuffy = 0;*/
843
+static BUFFY *TopBuffy = 0;
844
+static BUFFY *BottomBuffy = 0;
845
+static int known_lines = 0;
846
+
847
+static int quick_log10(int n)
848
+{
849
+        char string[32];
850
+        sprintf(string, "%d", n);
851
+        return strlen(string);
852
+}
853
+
854
+void calc_boundaries (int menu)
855
+{
856
+	BUFFY *tmp = Incoming;
857
+
858
+	if ( known_lines != LINES ) {
859
+		TopBuffy = BottomBuffy = 0;
860
+		known_lines = LINES;
861
+	}
862
+	for ( ; tmp->next != 0; tmp = tmp->next )
863
+		tmp->next->prev = tmp;
864
+
865
+	if ( TopBuffy == 0 && BottomBuffy == 0 )
866
+		TopBuffy = Incoming;
867
+	if ( BottomBuffy == 0 ) {
868
+		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
869
+		BottomBuffy = TopBuffy;
870
+		while ( --count && BottomBuffy->next )
871
+			BottomBuffy = BottomBuffy->next;
872
+	}
873
+	else if ( TopBuffy == CurBuffy->next ) {
874
+		int count = LINES - 2 - (menu != MENU_PAGER);
875
+		BottomBuffy = CurBuffy;
876
+		tmp = BottomBuffy;
877
+		while ( --count && tmp->prev)
878
+			tmp = tmp->prev;
879
+		TopBuffy = tmp;
880
+	}
881
+	else if ( BottomBuffy == CurBuffy->prev ) {
882
+		int count = LINES - 2 - (menu != MENU_PAGER);
883
+		TopBuffy = CurBuffy;
884
+		tmp = TopBuffy;
885
+		while ( --count && tmp->next )
886
+			tmp = tmp->next;
887
+		BottomBuffy = tmp;
888
+	}
889
+}
890
+
891
+char *make_sidebar_entry(char *box, int size, int new, int flagged)
892
+{
893
+	static char *entry = 0;
894
+	char *c;
895
+	int i = 0;
896
+	int delim_len = strlen(SidebarDelim);
897
+
898
+	c = realloc(entry, SidebarWidth - delim_len + 2);
899
+	if ( c ) entry = c;
900
+	entry[SidebarWidth - delim_len + 1] = 0;
901
+	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
902
+	i = strlen(box);
903
+	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
904
+
905
+        if (size == -1)
906
+                sprintf(entry + SidebarWidth - delim_len - 3, "?");
907
+        else if ( new ) {
908
+          if (flagged > 0) {
909
+              sprintf(
910
+		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
911
+		        "% d(%d)[%d]", size, new, flagged);
912
+          } else {
913
+              sprintf(
914
+                      entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
915
+                      "% d(%d)", size, new);
916
+          }
917
+        } else if (flagged > 0) {
918
+              sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
919
+        } else {
920
+              sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
921
+        }
922
+	return entry;
923
+}
924
+
925
+void set_curbuffy(char buf[LONG_STRING])
926
+{
927
+  BUFFY* tmp = CurBuffy = Incoming;
928
+
929
+  if (!Incoming)
930
+    return;
931
+
932
+  while(1) {
933
+    if(!strcmp(tmp->path, buf)) {
934
+      CurBuffy = tmp;
935
+      break;
936
+    }
937
+
938
+    if(tmp->next)
939
+      tmp = tmp->next;
940
+    else
941
+      break;
942
+  }
943
+}
944
+
945
+int draw_sidebar(int menu) {
946
+
947
+	int lines = option(OPTHELP) ? 1 : 0;
948
+	BUFFY *tmp;
949
+#ifndef USE_SLANG_CURSES
950
+        attr_t attrs;
951
+#endif
952
+        short delim_len = strlen(SidebarDelim);
953
+        short color_pair;
954
+
955
+        static bool initialized = false;
956
+        static int prev_show_value;
957
+        static short saveSidebarWidth;
958
+
959
+        /* initialize first time */
960
+        if(!initialized) {
961
+                prev_show_value = option(OPTSIDEBAR);
962
+                saveSidebarWidth = SidebarWidth;
963
+                if(!option(OPTSIDEBAR)) SidebarWidth = 0;
964
+                initialized = true;
965
+        }
966
+
967
+        /* save or restore the value SidebarWidth */
968
+        if(prev_show_value != option(OPTSIDEBAR)) {
969
+                if(prev_show_value && !option(OPTSIDEBAR)) {
970
+                        saveSidebarWidth = SidebarWidth;
971
+                        SidebarWidth = 0;
972
+                } else if(!prev_show_value && option(OPTSIDEBAR)) {
973
+                        SidebarWidth = saveSidebarWidth;
974
+                }
975
+                prev_show_value = option(OPTSIDEBAR);
976
+        }
977
+
978
+
979
+//	if ( SidebarWidth == 0 ) return 0;
980
+       if (SidebarWidth > 0 && option (OPTSIDEBAR)
981
+           && delim_len >= SidebarWidth) {
982
+         unset_option (OPTSIDEBAR);
983
+         /* saveSidebarWidth = SidebarWidth; */
984
+         if (saveSidebarWidth > delim_len) {
985
+           SidebarWidth = saveSidebarWidth;
986
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
987
+           sleep (2);
988
+         } else {
989
+           SidebarWidth = 0;
990
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
991
+           sleep (4); /* the advise to set a sane value should be seen long enough */
992
+         }
993
+         saveSidebarWidth = 0;
994
+         return (0);
995
+       }
996
+
997
+    if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
998
+      if (SidebarWidth > 0) {
999
+        saveSidebarWidth = SidebarWidth;
1000
+        SidebarWidth = 0;
1001
+      }
1002
+      unset_option(OPTSIDEBAR);
1003
+      return 0;
1004
+    }
1005
+
1006
+        /* get attributes for divider */
1007
+	SETCOLOR(MT_COLOR_STATUS);
1008
+#ifndef USE_SLANG_CURSES
1009
+        attr_get(&attrs, &color_pair, 0);
1010
+#else
1011
+        color_pair = attr_get();
1012
+#endif
1013
+	SETCOLOR(MT_COLOR_NORMAL);
1014
+
1015
+	/* draw the divider */
1016
+
1017
+	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1018
+		move(lines, SidebarWidth - delim_len);
1019
+		addstr(NONULL(SidebarDelim));
1020
+#ifndef USE_SLANG_CURSES
1021
+                mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1022
+#endif
1023
+	}
1024
+
1025
+	if ( Incoming == 0 ) return 0;
1026
+	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1027
+
1028
+	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1029
+		calc_boundaries(menu);
1030
+	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1031
+
1032
+	tmp = TopBuffy;
1033
+
1034
+	SETCOLOR(MT_COLOR_NORMAL);
1035
+
1036
+	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1037
+		if ( tmp == CurBuffy )
1038
+			SETCOLOR(MT_COLOR_INDICATOR);
1039
+		else if ( tmp->msg_unread > 0 )
1040
+			SETCOLOR(MT_COLOR_NEW);
1041
+		else if ( tmp->msg_flagged > 0 )
1042
+		        SETCOLOR(MT_COLOR_FLAGGED);
1043
+		else
1044
+			SETCOLOR(MT_COLOR_NORMAL);
1045
+
1046
+		move( lines, 0 );
1047
+		if ( Context && !strcmp( tmp->path, Context->path ) ) {
1048
+			tmp->msg_unread = Context->unread;
1049
+			tmp->msgcount = Context->msgcount;
1050
+			tmp->msg_flagged = Context->flagged;
1051
+		}
1052
+		// check whether Maildir is a prefix of the current folder's path
1053
+		short maildir_is_prefix = 0;
1054
+		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1055
+			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1056
+        		maildir_is_prefix = 1;
1057
+		// calculate depth of current folder and generate its display name with indented spaces
1058
+		int sidebar_folder_depth = 0;
1059
+		char *sidebar_folder_name;
1060
+		sidebar_folder_name = basename(tmp->path);
1061
+		if ( maildir_is_prefix ) {
1062
+			char *tmp_folder_name;
1063
+			int i;
1064
+			tmp_folder_name = tmp->path + strlen(Maildir);
1065
+			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1066
+				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1067
+			}   
1068
+			if (sidebar_folder_depth > 0) {
1069
+				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1070
+				for (i=0; i < sidebar_folder_depth; i++)
1071
+					sidebar_folder_name[i]=' ';
1072
+				sidebar_folder_name[i]=0;
1073
+				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1074
+			}
1075
+		}
1076
+		printw( "%.*s", SidebarWidth - delim_len + 1,
1077
+			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1078
+			tmp->msg_unread, tmp->msg_flagged));
1079
+		if (sidebar_folder_depth > 0)
1080
+		        free(sidebar_folder_name);
1081
+		lines++;
1082
+	}
1083
+	SETCOLOR(MT_COLOR_NORMAL);
1084
+	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1085
+		int i = 0;
1086
+		move( lines, 0 );
1087
+		for ( ; i < SidebarWidth - delim_len; i++ )
1088
+			addch(' ');
1089
+	}
1090
+	return 0;
1091
+}
1092
+
1093
+
1094
+void set_buffystats(CONTEXT* Context)
1095
+{
1096
+        BUFFY *tmp = Incoming;
1097
+        while(tmp) {
1098
+                if(Context && !strcmp(tmp->path, Context->path)) {
1099
+			tmp->msg_unread = Context->unread;
1100
+			tmp->msgcount = Context->msgcount;
1101
+                        break;
1102
+                }
1103
+                tmp = tmp->next;
1104
+        }
1105
+}
1106
+
1107
+void scroll_sidebar(int op, int menu)
1108
+{
1109
+        if(!SidebarWidth) return;
1110
+        if(!CurBuffy) return;
1111
+
1112
+	switch (op) {
1113
+		case OP_SIDEBAR_NEXT:
1114
+			if ( CurBuffy->next == NULL ) return;
1115
+			CurBuffy = CurBuffy->next;
1116
+			break;
1117
+		case OP_SIDEBAR_PREV:
1118
+			if ( CurBuffy->prev == NULL ) return;
1119
+			CurBuffy = CurBuffy->prev;
1120
+			break;
1121
+		case OP_SIDEBAR_SCROLL_UP:
1122
+			CurBuffy = TopBuffy;
1123
+			if ( CurBuffy != Incoming ) {
1124
+				calc_boundaries(menu);
1125
+				CurBuffy = CurBuffy->prev;
1126
+			}
1127
+			break;
1128
+		case OP_SIDEBAR_SCROLL_DOWN:
1129
+			CurBuffy = BottomBuffy;
1130
+			if ( CurBuffy->next ) {
1131
+				calc_boundaries(menu);
1132
+				CurBuffy = CurBuffy->next;
1133
+			}
1134
+			break;
1135
+		default:
1136
+			return;
1137
+	}
1138
+	calc_boundaries(menu);
1139
+	draw_sidebar(menu);
1140
+}
1141
+
1142
--- sidebar.h	1970-01-01 01:00:00.000000000 +0100
1143
+++ sidebar.h	2009-02-16 17:07:44.000000000 +0100
1144
@@ -0,0 +1,36 @@
1145
+/*
1146
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1147
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1148
+ * 
1149
+ *     This program is free software; you can redistribute it and/or modify
1150
+ *     it under the terms of the GNU General Public License as published by
1151
+ *     the Free Software Foundation; either version 2 of the License, or
1152
+ *     (at your option) any later version.
1153
+ * 
1154
+ *     This program is distributed in the hope that it will be useful,
1155
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1156
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1157
+ *     GNU General Public License for more details.
1158
+ * 
1159
+ *     You should have received a copy of the GNU General Public License
1160
+ *     along with this program; if not, write to the Free Software
1161
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1162
+ */ 
1163
+
1164
+#ifndef SIDEBAR_H
1165
+#define SIDEBAR_H
1166
+
1167
+struct MBOX_LIST {
1168
+	char *path;
1169
+	int msgcount;
1170
+	int new;
1171
+} MBLIST;
1172
+
1173
+/* parameter is whether or not to go to the status line */
1174
+/* used for omitting the last | that covers up the status bar in the index */
1175
+int draw_sidebar(int);
1176
+void scroll_sidebar(int, int);
1177
+void set_curbuffy(char*);
1178
+void set_buffystats(CONTEXT*);
1179
+
1180
+#endif /* SIDEBAR_H */
(-)./files/extra-patch-sidebar-nntp (+1194 lines)
Line 0 Link Here
1
--- Makefile.am	2009-01-05 20:20:53.000000000 +0100
2
+++ Makefile.am	2009-02-16 17:07:44.000000000 +0100
3
@@ -29,7 +29,7 @@
4
 	score.c send.c sendlib.c signal.c sort.c \
5
 	status.c system.c thread.c charset.c history.c lib.c \
6
 	muttlib.c editmsg.c mbyte.c \
7
-	url.c ascii.c crypt-mod.c crypt-mod.h
8
+	url.c ascii.c crypt-mod.c crypt-mod.h sidebar.c
9
 
10
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
11
 
12
--- Makefile.in	2009-01-05 20:24:13.000000000 +0100
13
+++ Makefile.in	2009-02-16 17:07:44.000000000 +0100
14
@@ -83,7 +83,7 @@
15
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
16
 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
17
 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
18
-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT)
19
+	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) sidebar.$(OBJEXT)
20
 am__objects_1 = patchlist.$(OBJEXT)
21
 nodist_mutt_OBJECTS = $(am__objects_1)
22
 mutt_OBJECTS = $(am_mutt_OBJECTS) $(nodist_mutt_OBJECTS)
23
@@ -307,7 +307,8 @@
24
 	score.c send.c sendlib.c signal.c sort.c \
25
 	status.c system.c thread.c charset.c history.c lib.c \
26
 	muttlib.c editmsg.c mbyte.c \
27
-	url.c ascii.c crypt-mod.c crypt-mod.h
28
+	url.c ascii.c crypt-mod.c crypt-mod.h \
29
+      sidebar.c
30
 
31
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
32
 mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
33
@@ -339,7 +340,7 @@
34
 	README.SSL smime.h \
35
 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
36
 	ChangeLog mkchangelog.sh mutt_idna.h \
37
-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in
38
+	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
39
 
40
 EXTRA_SCRIPTS = smime_keys
41
 mutt_dotlock_SOURCES = mutt_dotlock.c
42
--- OPS	2008-03-19 21:07:57.000000000 +0100
43
+++ OPS	2009-02-16 17:07:44.000000000 +0100
44
@@ -178,3 +178,8 @@
45
 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
46
 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
47
 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
48
+OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
49
+OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
50
+OP_SIDEBAR_NEXT "go down to next mailbox"
51
+OP_SIDEBAR_PREV "go to previous mailbox"
52
+OP_SIDEBAR_OPEN "open hilighted mailbox"
53
--- PATCHES	2008-03-19 21:07:06.000000000 +0100
54
+++ PATCHES	2009-02-16 17:07:44.000000000 +0100
55
@@ -0,0 +1 @@
56
+patch-1.5.19.sidebar.20080611.txt
57
--- buffy.c	2008-08-30 01:39:48.000000000 +0200
58
+++ buffy.c	2009-02-16 17:07:44.000000000 +0100
59
@@ -260,6 +260,7 @@
60
   struct stat contex_sb;
61
   time_t t;
62
 
63
+CONTEXT *ctx;
64
 #ifdef USE_IMAP
65
   /* update postponed count as well, on force */
66
   if (force)
67
--- buffy.h	2008-05-22 20:25:19.000000000 +0200
68
+++ buffy.h	2009-02-16 17:07:44.000000000 +0100
69
@@ -25,7 +25,12 @@
70
   char *path;
71
   off_t size;
72
   struct buffy_t *next;
73
+  struct buffy_t *prev;
74
   short new;			/* mailbox has new mail */
75
+  short has_new;		/* set it new if new and not read */
76
+  int msgcount;			/* total number of messages */
77
+  int msg_unread;		/* number of unread messages */
78
+  int msg_flagged;		/* number of flagged messages */
79
   short notified;		/* user has been notified */
80
   short magic;			/* mailbox type */
81
   short newly_created;		/* mbox or mmdf just popped into existence */
82
--- color.c	2008-03-19 21:07:57.000000000 +0100
83
+++ color.c	2009-02-16 17:07:44.000000000 +0100
84
@@ -93,6 +93,8 @@
85
   { "bold",		MT_COLOR_BOLD },
86
   { "underline",	MT_COLOR_UNDERLINE },
87
   { "index",		MT_COLOR_INDEX },
88
+  { "sidebar_new",	MT_COLOR_NEW },
89
+  { "sidebar_flagged",	MT_COLOR_FLAGGED },
90
   { NULL,		0 }
91
 };
92
 
93
--- compose.c.orig	2009-02-16 17:08:51.000000000 +0100
94
+++ compose.c	2009-02-16 17:12:47.000000000 +0100
95
@@ -80,7 +80,7 @@
96
 
97
 #define HDR_XOFFSET 14
98
 #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
99
-#define W (COLS - HDR_XOFFSET)
100
+#define W (COLS - HDR_XOFFSET - SidebarWidth)
101
 
102
 static char *Prompts[] =
103
 {
104
@@ -146,16 +146,16 @@
105
   if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
106
   {     
107
     if (!msg->security)
108
-      mvaddstr (HDR_CRYPT, 0,     "    Security: ");
109
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "    Security: ");
110
     else if (msg->security & APPLICATION_SMIME)
111
-      mvaddstr (HDR_CRYPT, 0,     "      S/MIME: ");
112
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
113
     else if (msg->security & APPLICATION_PGP)
114
-      mvaddstr (HDR_CRYPT, 0,     "         PGP: ");
115
+      mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
116
   }
117
   else if ((WithCrypto & APPLICATION_SMIME))
118
-    mvaddstr (HDR_CRYPT, 0,     "      S/MIME: ");
119
+    mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
120
   else if ((WithCrypto & APPLICATION_PGP))
121
-    mvaddstr (HDR_CRYPT, 0,     "         PGP: ");
122
+    mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
123
   else
124
     return;
125
 
126
@@ -179,7 +179,7 @@
127
     }
128
   clrtoeol ();
129
 
130
-  move (HDR_CRYPTINFO, 0);
131
+  move (HDR_CRYPTINFO, SidebarWidth);
132
   clrtoeol ();
133
   if ((WithCrypto & APPLICATION_PGP)
134
       && msg->security & APPLICATION_PGP  && msg->security & SIGN)
135
@@ -195,7 +195,7 @@
136
       && (msg->security & ENCRYPT)
137
       && SmimeCryptAlg
138
       && *SmimeCryptAlg) {
139
-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
140
+      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
141
 		NONULL(SmimeCryptAlg));
142
       off = 20;
143
   }
144
@@ -209,7 +209,7 @@
145
   int c;
146
   char *t;
147
 
148
-  mvaddstr (HDR_MIX, 0,     "     Mix: ");
149
+  mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
150
 
151
   if (!chain)
152
   {
153
@@ -224,7 +224,7 @@
154
     if (t && t[0] == '0' && t[1] == '\0')
155
       t = "<random>";
156
     
157
-    if (c + mutt_strlen (t) + 2 >= COLS)
158
+    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
159
       break;
160
 
161
     addstr (NONULL(t));
162
@@ -276,7 +276,7 @@
163
 
164
   buf[0] = 0;
165
   rfc822_write_address (buf, sizeof (buf), addr, 1);
166
-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
167
+  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
168
   mutt_paddstr (W, buf);
169
 }
170
 
171
@@ -294,21 +294,21 @@
172
   }
173
   else
174
   {
175
-    mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
176
+    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
177
     mutt_paddstr (W, NONULL (msg->env->newsgroups));
178
-    mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
179
+    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
180
     mutt_paddstr (W, NONULL (msg->env->followup_to));
181
     if (option (OPTXCOMMENTTO))
182
     {
183
-      mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
184
+      mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
185
       mutt_paddstr (W, NONULL (msg->env->x_comment_to));
186
     }
187
   }
188
 #endif
189
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
190
+  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
191
   mutt_paddstr (W, NONULL (msg->env->subject));
192
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
193
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
194
+  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
195
   mutt_paddstr (W, fcc);
196
 
197
   if (WithCrypto)
198
@@ -319,7 +319,7 @@
199
 #endif
200
 
201
   SETCOLOR (MT_COLOR_STATUS);
202
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
203
+  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
204
   BKGDSET (MT_COLOR_STATUS);
205
   clrtoeol ();
206
 
207
@@ -357,7 +357,7 @@
208
   /* redraw the expanded list so the user can see the result */
209
   buf[0] = 0;
210
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
211
-  move (line, HDR_XOFFSET);
212
+  move (line, HDR_XOFFSET+SidebarWidth);
213
   mutt_paddstr (W, buf);
214
   
215
   return 0;
216
@@ -686,7 +686,7 @@
217
 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
218
 	{
219
 	  mutt_str_replace (&msg->env->subject, buf);
220
-	  move (HDR_SUBJECT, HDR_XOFFSET);
221
+	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
222
 	  clrtoeol ();
223
 	  if (msg->env->subject)
224
 	    mutt_paddstr (W, msg->env->subject);
225
@@ -703,7 +703,7 @@
226
 	{
227
 	  strfcpy (fcc, buf, fcclen);
228
 	  mutt_pretty_mailbox (fcc, fcclen);
229
-	  move (HDR_FCC, HDR_XOFFSET);
230
+	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
231
 	  mutt_paddstr (W, fcc);
232
 	  fccSet = 1;
233
 	}
234
--- curs_main.c	2009-01-05 20:20:53.000000000 +0100
235
+++ curs_main.c	2009-02-16 17:07:44.000000000 +0100
236
@@ -27,6 +27,9 @@
237
 #include "mapping.h"
238
 #include "sort.h"
239
 #include "mx.h"
240
+#include "attach.h"
241
+#include "buffy.h"
242
+#include "sidebar.h"
243
 
244
 #ifdef USE_POP
245
 #include "pop.h"
246
@@ -523,8 +526,12 @@
247
        menu->redraw |= REDRAW_STATUS;
248
      if (do_buffy_notify)
249
      {
250
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
251
- 	beep ();
252
+       if (mutt_buffy_notify ())
253
+       {
254
+         menu->redraw |= REDRAW_FULL;
255
+         if (option (OPTBEEPNEW))
256
+           beep ();
257
+       }
258
      }
259
      else
260
        do_buffy_notify = 1;
261
@@ -536,6 +543,7 @@
262
     if (menu->redraw & REDRAW_FULL)
263
     {
264
       menu_redraw_full (menu);
265
+      draw_sidebar(menu->menu);
266
       mutt_show_error ();
267
     }
268
 
269
@@ -558,10 +566,13 @@
270
 
271
       if (menu->redraw & REDRAW_STATUS) 
272
       {
273
+        DrawFullLine = 1;
274
 	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
275
+        DrawFullLine = 0;
276
 	CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
277
 	SETCOLOR (MT_COLOR_STATUS);
278
         BKGDSET (MT_COLOR_STATUS);
279
+        set_buffystats(Context);
280
 	mutt_paddstr (COLS, buf);
281
 	SETCOLOR (MT_COLOR_NORMAL);
282
         BKGDSET (MT_COLOR_NORMAL);
283
@@ -575,7 +586,7 @@
284
 	menu->oldcurrent = -1;
285
 
286
       if (option (OPTARROWCURSOR))
287
-	move (menu->current - menu->top + menu->offset, 2);
288
+	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
289
       else if (option (OPTBRAILLEFRIENDLY))
290
 	move (menu->current - menu->top + menu->offset, 0);
291
       else
292
@@ -1048,6 +1059,7 @@
293
 	  menu->redraw = REDRAW_FULL;
294
 	break;
295
 
296
+      case OP_SIDEBAR_OPEN:
297
       case OP_MAIN_CHANGE_FOLDER:
298
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
299
       
300
@@ -1079,7 +1091,11 @@
301
 	{
302
 	  mutt_buffy (buf, sizeof (buf));
303
 
304
-	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
305
+          if ( op == OP_SIDEBAR_OPEN ) {
306
+              if(!CurBuffy)
307
+                break;
308
+            strncpy( buf, CurBuffy->path, sizeof(buf) );  
309
+	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
310
 	  {
311
 	    if (menu->menu == MENU_PAGER)
312
 	    {
313
@@ -1097,6 +1113,7 @@
314
 	}
315
 
316
 	mutt_expand_path (buf, sizeof (buf));
317
+        set_curbuffy(buf);
318
 	if (mx_get_magic (buf) <= 0)
319
 	{
320
 	  mutt_error (_("%s is not a mailbox."), buf);
321
@@ -2176,6 +2193,12 @@
322
 	mutt_what_key();
323
 	break;
324
 
325
+      case OP_SIDEBAR_SCROLL_UP:
326
+      case OP_SIDEBAR_SCROLL_DOWN:
327
+      case OP_SIDEBAR_NEXT:
328
+      case OP_SIDEBAR_PREV:
329
+        scroll_sidebar(op, menu->menu);
330
+        break;
331
       default:
332
 	if (menu->menu == MENU_MAIN)
333
 	  km_error_key (MENU_MAIN);
334
--- flags.c	2009-01-04 00:27:10.000000000 +0100
335
+++ flags.c	2009-02-16 17:07:44.000000000 +0100
336
@@ -22,8 +22,10 @@
337
 
338
 #include "mutt.h"
339
 #include "mutt_curses.h"
340
+#include "mutt_menu.h"
341
 #include "sort.h"
342
 #include "mx.h"
343
+#include "sidebar.h"
344
 
345
 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
346
 {
347
@@ -263,6 +265,7 @@
348
    */
349
   if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
350
     h->searched = 0;
351
+	draw_sidebar(0);
352
 }
353
 
354
 void mutt_tag_set_flag (int flag, int bf)
355
--- functions.h	2009-01-05 20:20:53.000000000 +0100
356
+++ functions.h	2009-02-16 17:07:44.000000000 +0100
357
@@ -168,6 +168,11 @@
358
   { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
359
 
360
 
361
+ { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
362
+ { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
363
+ { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
364
+ { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
365
+ { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
366
   { NULL,			0,				NULL }
367
 };
368
 
369
@@ -266,6 +271,11 @@
370
 
371
   { "what-key",		OP_WHAT_KEY,		NULL },
372
 
373
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
374
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
375
+  { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
376
+  { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
377
+  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
378
   { NULL,		0,				NULL }
379
 };
380
 
381
--- globals.h	2009-01-04 00:27:10.000000000 +0100
382
+++ globals.h	2009-02-16 17:07:44.000000000 +0100
383
@@ -116,6 +116,7 @@
384
 WHERE char *SendCharset;
385
 WHERE char *Sendmail;
386
 WHERE char *Shell;
387
+WHERE char *SidebarDelim;
388
 WHERE char *Signature;
389
 WHERE char *SimpleSearch;
390
 #if USE_SMTP
391
@@ -205,6 +206,9 @@
392
 WHERE short ScoreThresholdRead;
393
 WHERE short ScoreThresholdFlag;
394
 
395
+WHERE struct buffy_t *CurBuffy INITVAL(0);
396
+WHERE short DrawFullLine INITVAL(0);
397
+WHERE short SidebarWidth;
398
 #ifdef USE_IMAP
399
 WHERE short ImapKeepalive;
400
 WHERE short ImapPipelineDepth;
401
--- init.h	2009-01-05 20:20:53.000000000 +0100
402
+++ init.h	2009-02-16 17:07:44.000000000 +0100
403
@@ -1572,6 +1572,22 @@
404
   ** you may \fIunset\fP this setting.
405
   ** (Crypto only)
406
   */
407
+  {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
408
+  /*
409
+  ** .pp
410
+  ** This specifies the delimiter between the sidebar (if visible) and 
411
+  ** other screens.
412
+  */
413
+  { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
414
+  /*
415
+  ** .pp
416
+  ** This specifies whether or not to show sidebar (left-side list of folders).
417
+  */
418
+  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
419
+  /*
420
+  ** .pp
421
+  ** The width of the sidebar.
422
+  */
423
   { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
424
   /*
425
   ** .pp
426
--- mailbox.h	2008-03-19 21:07:06.000000000 +0100
427
+++ mailbox.h	2009-02-16 17:07:44.000000000 +0100
428
@@ -27,6 +27,7 @@
429
 #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
430
 				* safe_fopen() for mbox-style folders.
431
 				*/
432
+#define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
433
 
434
 /* mx_open_new_message() */
435
 #define M_ADD_FROM	1	/* add a From_ line */
436
--- mbox.c	2008-08-15 20:30:12.000000000 +0200
437
+++ mbox.c	2009-02-16 17:07:44.000000000 +0100
438
@@ -100,6 +100,7 @@
439
     mutt_perror (ctx->path);
440
     return (-1);
441
   }
442
+  ctx->atime = sb.st_atime;
443
   ctx->mtime = sb.st_mtime;
444
   ctx->size = sb.st_size;
445
 
446
@@ -255,6 +256,7 @@
447
 
448
   ctx->size = sb.st_size;
449
   ctx->mtime = sb.st_mtime;
450
+  ctx->atime = sb.st_atime;
451
 
452
 #ifdef NFS_ATTRIBUTE_HACK
453
   if (sb.st_mtime > sb.st_atime)
454
--- menu.c	2009-01-05 20:20:53.000000000 +0100
455
+++ menu.c	2009-02-16 17:07:44.000000000 +0100
456
@@ -24,6 +24,7 @@
457
 #include "mutt_curses.h"
458
 #include "mutt_menu.h"
459
 #include "mbyte.h"
460
+#include "sidebar.h"
461
 
462
 #include <string.h>
463
 #include <stdlib.h>
464
@@ -156,7 +157,7 @@
465
 {
466
   char *scratch = safe_strdup (s);
467
   int shift = option (OPTARROWCURSOR) ? 3 : 0;
468
-  int cols = COLS - shift;
469
+  int cols = COLS - shift - SidebarWidth;
470
 
471
   mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
472
   s[n - 1] = 0;
473
@@ -207,6 +208,7 @@
474
   char buf[LONG_STRING];
475
   int i;
476
 
477
+  draw_sidebar(1);
478
   for (i = menu->top; i < menu->top + menu->pagelen; i++)
479
   {
480
     if (i < menu->max)
481
@@ -217,7 +219,7 @@
482
       if (option (OPTARROWCURSOR))
483
       {
484
         attrset (menu->color (i));
485
-	CLEARLINE (i - menu->top + menu->offset);
486
+	CLEARLINE_WIN (i - menu->top + menu->offset);
487
 
488
 	if (i == menu->current)
489
 	{
490
@@ -246,14 +248,14 @@
491
 	  BKGDSET (MT_COLOR_INDICATOR);
492
 	}
493
 
494
-	CLEARLINE (i - menu->top + menu->offset);
495
+	CLEARLINE_WIN (i - menu->top + menu->offset);
496
 	print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
497
         SETCOLOR (MT_COLOR_NORMAL);
498
         BKGDSET (MT_COLOR_NORMAL);
499
       }
500
     }
501
     else
502
-      CLEARLINE (i - menu->top + menu->offset);
503
+      CLEARLINE_WIN (i - menu->top + menu->offset);
504
   }
505
   menu->redraw = 0;
506
 }
507
@@ -268,7 +270,7 @@
508
     return;
509
   }
510
   
511
-  move (menu->oldcurrent + menu->offset - menu->top, 0);
512
+  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
513
   SETCOLOR (MT_COLOR_NORMAL);
514
   BKGDSET (MT_COLOR_NORMAL);
515
 
516
@@ -283,13 +285,13 @@
517
       clrtoeol ();
518
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
519
       menu_pad_string (buf, sizeof (buf));
520
-      move (menu->oldcurrent + menu->offset - menu->top, 3);
521
+      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
522
       print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
523
       SETCOLOR (MT_COLOR_NORMAL);
524
     }
525
 
526
     /* now draw it in the new location */
527
-    move (menu->current + menu->offset - menu->top, 0);
528
+    move (menu->current + menu->offset - menu->top, SidebarWidth);
529
     attrset (menu->color (menu->current));
530
     ADDCOLOR (MT_COLOR_INDICATOR);
531
     addstr ("->");
532
@@ -310,7 +312,7 @@
533
     attrset (menu->color (menu->current));
534
     ADDCOLOR (MT_COLOR_INDICATOR);
535
     BKGDSET (MT_COLOR_INDICATOR);
536
-    CLEARLINE (menu->current - menu->top + menu->offset);
537
+    CLEARLINE_WIN (menu->current - menu->top + menu->offset);
538
     print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
539
     SETCOLOR (MT_COLOR_NORMAL);
540
     BKGDSET (MT_COLOR_NORMAL);
541
@@ -322,7 +324,7 @@
542
 {
543
   char buf[LONG_STRING];
544
   
545
-  move (menu->current + menu->offset - menu->top, 0);
546
+  move (menu->current + menu->offset - menu->top, SidebarWidth);
547
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
548
   menu_pad_string (buf, sizeof (buf));
549
 
550
@@ -882,7 +884,7 @@
551
     
552
     
553
     if (option (OPTARROWCURSOR))
554
-      move (menu->current - menu->top + menu->offset, 2);
555
+      move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
556
     else if (option (OPTBRAILLEFRIENDLY))
557
       move (menu->current - menu->top + menu->offset, 0);
558
     else
559
--- mutt.h	2008-09-26 00:00:03.000000000 +0200
560
+++ mutt.h	2009-02-16 17:07:44.000000000 +0100
561
@@ -409,6 +409,7 @@
562
   OPTSAVEEMPTY,
563
   OPTSAVENAME,
564
   OPTSCORE,
565
+  OPTSIDEBAR,
566
   OPTSIGDASHES,
567
   OPTSIGONTOP,
568
   OPTSORTRE,
569
@@ -843,6 +844,7 @@
570
 {
571
   char *path;
572
   FILE *fp;
573
+  time_t atime;
574
   time_t mtime;
575
   off_t size;
576
   off_t vsize;
577
@@ -877,6 +879,7 @@
578
   unsigned int quiet : 1;	/* inhibit status messages? */
579
   unsigned int collapsed : 1;   /* are all threads collapsed? */
580
   unsigned int closing : 1;	/* mailbox is being closed */
581
+  unsigned int peekonly : 1;	/* just taking a glance, revert atime */
582
 
583
   /* driver hooks */
584
   void *data;			/* driver specific data */
585
--- mutt_curses.h	2008-03-19 21:07:57.000000000 +0100
586
+++ mutt_curses.h	2009-02-16 17:07:44.000000000 +0100
587
@@ -64,6 +64,7 @@
588
 #undef lines
589
 #endif /* lines */
590
 
591
+#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
592
 #define CLEARLINE(x) move(x,0), clrtoeol()
593
 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
594
 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
595
@@ -126,6 +127,8 @@
596
   MT_COLOR_BOLD,
597
   MT_COLOR_UNDERLINE,
598
   MT_COLOR_INDEX,
599
+  MT_COLOR_NEW,
600
+  MT_COLOR_FLAGGED,
601
   MT_COLOR_MAX
602
 };
603
 
604
--- muttlib.c	2009-01-05 20:20:53.000000000 +0100
605
+++ muttlib.c	2009-02-16 17:07:44.000000000 +0100
606
@@ -1217,6 +1217,8 @@
607
 	  pl = pw = 1;
608
 
609
 	/* see if there's room to add content, else ignore */
610
+        if ( DrawFullLine )
611
+        {
612
 	if ((col < COLS && wlen < destlen) || soft)
613
 	{
614
 	  int pad;
615
@@ -1259,6 +1261,52 @@
616
 	  col += wid;
617
 	  src += pl;
618
 	}
619
+        }
620
+        else
621
+        {
622
+	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
623
+        {
624
+	  int pad;
625
+
626
+	  /* get contents after padding */
627
+	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
628
+	  len = mutt_strlen (buf);
629
+	  wid = mutt_strwidth (buf);
630
+
631
+	  /* try to consume as many columns as we can, if we don't have
632
+	   * memory for that, use as much memory as possible */
633
+	  pad = (COLS - SidebarWidth - col - wid) / pw;
634
+	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
635
+	    pad = ((signed)(destlen - wlen - len)) / pl;
636
+	  if (pad > 0)
637
+	  {
638
+	    while (pad--)
639
+	    {
640
+	      memcpy (wptr, src, pl);
641
+	      wptr += pl;
642
+	      wlen += pl;
643
+	      col += pw;
644
+	    }
645
+	  }
646
+	  else if (soft && pad < 0)
647
+	  {
648
+	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
649
+	    *wptr = 0;
650
+	    /* make sure right part is at most as wide as display */
651
+	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
652
+	    /* truncate left so that right part fits completely in */
653
+	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
654
+	    wptr = dest + wlen;
655
+	  }
656
+	  if (len + wlen > destlen)
657
+	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
658
+	  memcpy (wptr, buf, len);
659
+	  wptr += len;
660
+	  wlen += len;
661
+	  col += wid;
662
+	  src += pl;
663
+	}
664
+        }
665
 	break; /* skip rest of input */
666
       }
667
       else if (ch == '|')
668
--- mx.c	2009-01-05 20:20:53.000000000 +0100
669
+++ mx.c	2009-02-16 17:07:44.000000000 +0100
670
@@ -611,6 +611,7 @@
671
  *		M_APPEND	open mailbox for appending
672
  *		M_READONLY	open mailbox in read-only mode
673
  *		M_QUIET		only print error messages
674
+ *		M_PEEK		revert atime where applicable
675
  *	ctx	if non-null, context struct to use
676
  */
677
 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
678
@@ -633,6 +634,8 @@
679
     ctx->quiet = 1;
680
   if (flags & M_READONLY)
681
     ctx->readonly = 1;
682
+  if (flags & M_PEEK)
683
+    ctx->peekonly = 1;
684
 
685
   if (flags & (M_APPEND|M_NEWFOLDER))
686
   {
687
@@ -732,9 +735,21 @@
688
 void mx_fastclose_mailbox (CONTEXT *ctx)
689
 {
690
   int i;
691
+#ifndef BUFFY_SIZE
692
+  struct utimbuf ut;
693
+#endif
694
 
695
   if(!ctx) 
696
     return;
697
+#ifndef BUFFY_SIZE
698
+  /* fix up the times so buffy won't get confused */
699
+  if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
700
+  {
701
+    ut.actime = ctx->atime;
702
+    ut.modtime = ctx->mtime;
703
+    utime (ctx->path, &ut); 
704
+  }
705
+#endif
706
 
707
   if (ctx->mx_close)
708
     ctx->mx_close (ctx);
709
--- pager.c	2009-01-05 20:20:53.000000000 +0100
710
+++ pager.c	2009-02-16 17:07:44.000000000 +0100
711
@@ -29,6 +29,7 @@
712
 #include "pager.h"
713
 #include "attach.h"
714
 #include "mbyte.h"
715
+#include "sidebar.h"
716
 
717
 #include "mutt_crypt.h"
718
 
719
@@ -1060,6 +1061,8 @@
720
   mbstate_t mbstate;
721
 
722
   int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
723
+
724
+  wrap_cols -= SidebarWidth;
725
   
726
   /* FIXME: this should come from lineInfo */
727
   memset(&mbstate, 0, sizeof(mbstate));
728
@@ -1694,7 +1697,7 @@
729
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
730
     {
731
       do {
732
-	move (bodyoffset, 0);
733
+	move (bodyoffset, SidebarWidth);
734
 	curline = oldtopline = topline;
735
 	lines = 0;
736
 	force_redraw = 0;
737
@@ -1707,6 +1710,7 @@
738
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
739
 	    lines++;
740
 	  curline++;
741
+  	  move(lines + bodyoffset, SidebarWidth);
742
 	}
743
 	last_offset = lineInfo[curline].offset;
744
       } while (force_redraw);
745
@@ -1720,6 +1724,7 @@
746
 	  addch ('~');
747
 	addch ('\n');
748
 	lines++;
749
+  	move(lines + bodyoffset, SidebarWidth);
750
       }
751
       /* We are going to update the pager status bar, so it isn't
752
        * necessary to reset to normal color now. */
753
@@ -1743,22 +1748,22 @@
754
       /* print out the pager status bar */
755
       SETCOLOR (MT_COLOR_STATUS);
756
       BKGDSET (MT_COLOR_STATUS);
757
-      CLEARLINE (statusoffset);
758
+      CLEARLINE_WIN (statusoffset);
759
       if (IsHeader (extra))
760
       {
761
-	size_t l1 = COLS * MB_LEN_MAX;
762
+	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
763
 	size_t l2 = sizeof (buffer);
764
 	hfi.hdr = extra->hdr;
765
 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
766
       }
767
       else if (IsMsgAttach (extra))
768
       {
769
-	size_t l1 = COLS * MB_LEN_MAX;
770
+	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
771
 	size_t l2 = sizeof (buffer);
772
 	hfi.hdr = extra->bdy->hdr;
773
 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
774
       }
775
-      mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ?  buffer : banner);
776
+      mutt_paddstr (COLS-SidebarWidth, IsHeader (extra) || IsMsgAttach (extra) ?  buffer : banner);
777
       BKGDSET (MT_COLOR_NORMAL);
778
       SETCOLOR (MT_COLOR_NORMAL);
779
     }
780
@@ -1768,18 +1773,23 @@
781
       /* redraw the pager_index indicator, because the
782
        * flags for this message might have changed. */
783
       menu_redraw_current (index);
784
+      draw_sidebar(MENU_PAGER);
785
 
786
       /* print out the index status bar */
787
       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
788
  
789
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
790
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
791
       SETCOLOR (MT_COLOR_STATUS);
792
       BKGDSET (MT_COLOR_STATUS);
793
-      mutt_paddstr (COLS, buffer);
794
+      mutt_paddstr (COLS-SidebarWidth, buffer);
795
       SETCOLOR (MT_COLOR_NORMAL);
796
       BKGDSET (MT_COLOR_NORMAL);
797
     }
798
 
799
+    /* if we're not using the index, update every time */
800
+    if ( index == 0 )
801
+      draw_sidebar(MENU_PAGER);
802
+
803
     redraw = 0;
804
 
805
     if (option(OPTBRAILLEFRIENDLY)) {
806
@@ -2671,6 +2681,13 @@
807
 	mutt_what_key ();
808
 	break;
809
 
810
+      case OP_SIDEBAR_SCROLL_UP:
811
+      case OP_SIDEBAR_SCROLL_DOWN:
812
+      case OP_SIDEBAR_NEXT:
813
+      case OP_SIDEBAR_PREV:
814
+	scroll_sidebar(ch, MENU_PAGER);
815
+ 	break;
816
+
817
       default:
818
 	ch = -1;
819
 	break;
820
--- sidebar.c	1970-01-01 01:00:00.000000000 +0100
821
+++ sidebar.c	2009-02-16 17:07:44.000000000 +0100
822
@@ -0,0 +1,333 @@
823
+/*
824
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
825
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
826
+ * 
827
+ *     This program is free software; you can redistribute it and/or modify
828
+ *     it under the terms of the GNU General Public License as published by
829
+ *     the Free Software Foundation; either version 2 of the License, or
830
+ *     (at your option) any later version.
831
+ * 
832
+ *     This program is distributed in the hope that it will be useful,
833
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
834
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
835
+ *     GNU General Public License for more details.
836
+ * 
837
+ *     You should have received a copy of the GNU General Public License
838
+ *     along with this program; if not, write to the Free Software
839
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
840
+ */ 
841
+
842
+
843
+#if HAVE_CONFIG_H
844
+# include "config.h"
845
+#endif
846
+
847
+#include "mutt.h"
848
+#include "mutt_menu.h"
849
+#include "mutt_curses.h"
850
+#include "sidebar.h"
851
+#include "buffy.h"
852
+#include <libgen.h>
853
+#include "keymap.h"
854
+#include <stdbool.h>
855
+
856
+/*BUFFY *CurBuffy = 0;*/
857
+static BUFFY *TopBuffy = 0;
858
+static BUFFY *BottomBuffy = 0;
859
+static int known_lines = 0;
860
+
861
+static int quick_log10(int n)
862
+{
863
+        char string[32];
864
+        sprintf(string, "%d", n);
865
+        return strlen(string);
866
+}
867
+
868
+void calc_boundaries (int menu)
869
+{
870
+	BUFFY *tmp = Incoming;
871
+
872
+	if ( known_lines != LINES ) {
873
+		TopBuffy = BottomBuffy = 0;
874
+		known_lines = LINES;
875
+	}
876
+	for ( ; tmp->next != 0; tmp = tmp->next )
877
+		tmp->next->prev = tmp;
878
+
879
+	if ( TopBuffy == 0 && BottomBuffy == 0 )
880
+		TopBuffy = Incoming;
881
+	if ( BottomBuffy == 0 ) {
882
+		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
883
+		BottomBuffy = TopBuffy;
884
+		while ( --count && BottomBuffy->next )
885
+			BottomBuffy = BottomBuffy->next;
886
+	}
887
+	else if ( TopBuffy == CurBuffy->next ) {
888
+		int count = LINES - 2 - (menu != MENU_PAGER);
889
+		BottomBuffy = CurBuffy;
890
+		tmp = BottomBuffy;
891
+		while ( --count && tmp->prev)
892
+			tmp = tmp->prev;
893
+		TopBuffy = tmp;
894
+	}
895
+	else if ( BottomBuffy == CurBuffy->prev ) {
896
+		int count = LINES - 2 - (menu != MENU_PAGER);
897
+		TopBuffy = CurBuffy;
898
+		tmp = TopBuffy;
899
+		while ( --count && tmp->next )
900
+			tmp = tmp->next;
901
+		BottomBuffy = tmp;
902
+	}
903
+}
904
+
905
+char *make_sidebar_entry(char *box, int size, int new, int flagged)
906
+{
907
+	static char *entry = 0;
908
+	char *c;
909
+	int i = 0;
910
+	int delim_len = strlen(SidebarDelim);
911
+
912
+	c = realloc(entry, SidebarWidth - delim_len + 2);
913
+	if ( c ) entry = c;
914
+	entry[SidebarWidth - delim_len + 1] = 0;
915
+	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
916
+	i = strlen(box);
917
+	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
918
+
919
+        if (size == -1)
920
+                sprintf(entry + SidebarWidth - delim_len - 3, "?");
921
+        else if ( new ) {
922
+          if (flagged > 0) {
923
+              sprintf(
924
+		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
925
+		        "% d(%d)[%d]", size, new, flagged);
926
+          } else {
927
+              sprintf(
928
+                      entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
929
+                      "% d(%d)", size, new);
930
+          }
931
+        } else if (flagged > 0) {
932
+              sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
933
+        } else {
934
+              sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
935
+        }
936
+	return entry;
937
+}
938
+
939
+void set_curbuffy(char buf[LONG_STRING])
940
+{
941
+  BUFFY* tmp = CurBuffy = Incoming;
942
+
943
+  if (!Incoming)
944
+    return;
945
+
946
+  while(1) {
947
+    if(!strcmp(tmp->path, buf)) {
948
+      CurBuffy = tmp;
949
+      break;
950
+    }
951
+
952
+    if(tmp->next)
953
+      tmp = tmp->next;
954
+    else
955
+      break;
956
+  }
957
+}
958
+
959
+int draw_sidebar(int menu) {
960
+
961
+	int lines = option(OPTHELP) ? 1 : 0;
962
+	BUFFY *tmp;
963
+#ifndef USE_SLANG_CURSES
964
+        attr_t attrs;
965
+#endif
966
+        short delim_len = strlen(SidebarDelim);
967
+        short color_pair;
968
+
969
+        static bool initialized = false;
970
+        static int prev_show_value;
971
+        static short saveSidebarWidth;
972
+
973
+        /* initialize first time */
974
+        if(!initialized) {
975
+                prev_show_value = option(OPTSIDEBAR);
976
+                saveSidebarWidth = SidebarWidth;
977
+                if(!option(OPTSIDEBAR)) SidebarWidth = 0;
978
+                initialized = true;
979
+        }
980
+
981
+        /* save or restore the value SidebarWidth */
982
+        if(prev_show_value != option(OPTSIDEBAR)) {
983
+                if(prev_show_value && !option(OPTSIDEBAR)) {
984
+                        saveSidebarWidth = SidebarWidth;
985
+                        SidebarWidth = 0;
986
+                } else if(!prev_show_value && option(OPTSIDEBAR)) {
987
+                        SidebarWidth = saveSidebarWidth;
988
+                }
989
+                prev_show_value = option(OPTSIDEBAR);
990
+        }
991
+
992
+
993
+//	if ( SidebarWidth == 0 ) return 0;
994
+       if (SidebarWidth > 0 && option (OPTSIDEBAR)
995
+           && delim_len >= SidebarWidth) {
996
+         unset_option (OPTSIDEBAR);
997
+         /* saveSidebarWidth = SidebarWidth; */
998
+         if (saveSidebarWidth > delim_len) {
999
+           SidebarWidth = saveSidebarWidth;
1000
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1001
+           sleep (2);
1002
+         } else {
1003
+           SidebarWidth = 0;
1004
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1005
+           sleep (4); /* the advise to set a sane value should be seen long enough */
1006
+         }
1007
+         saveSidebarWidth = 0;
1008
+         return (0);
1009
+       }
1010
+
1011
+    if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1012
+      if (SidebarWidth > 0) {
1013
+        saveSidebarWidth = SidebarWidth;
1014
+        SidebarWidth = 0;
1015
+      }
1016
+      unset_option(OPTSIDEBAR);
1017
+      return 0;
1018
+    }
1019
+
1020
+        /* get attributes for divider */
1021
+	SETCOLOR(MT_COLOR_STATUS);
1022
+#ifndef USE_SLANG_CURSES
1023
+        attr_get(&attrs, &color_pair, 0);
1024
+#else
1025
+        color_pair = attr_get();
1026
+#endif
1027
+	SETCOLOR(MT_COLOR_NORMAL);
1028
+
1029
+	/* draw the divider */
1030
+
1031
+	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1032
+		move(lines, SidebarWidth - delim_len);
1033
+		addstr(NONULL(SidebarDelim));
1034
+#ifndef USE_SLANG_CURSES
1035
+                mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1036
+#endif
1037
+	}
1038
+
1039
+	if ( Incoming == 0 ) return 0;
1040
+	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
1041
+
1042
+	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1043
+		calc_boundaries(menu);
1044
+	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1045
+
1046
+	tmp = TopBuffy;
1047
+
1048
+	SETCOLOR(MT_COLOR_NORMAL);
1049
+
1050
+	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
1051
+		if ( tmp == CurBuffy )
1052
+			SETCOLOR(MT_COLOR_INDICATOR);
1053
+		else if ( tmp->msg_unread > 0 )
1054
+			SETCOLOR(MT_COLOR_NEW);
1055
+		else if ( tmp->msg_flagged > 0 )
1056
+		        SETCOLOR(MT_COLOR_FLAGGED);
1057
+		else
1058
+			SETCOLOR(MT_COLOR_NORMAL);
1059
+
1060
+		move( lines, 0 );
1061
+		if ( Context && !strcmp( tmp->path, Context->path ) ) {
1062
+			tmp->msg_unread = Context->unread;
1063
+			tmp->msgcount = Context->msgcount;
1064
+			tmp->msg_flagged = Context->flagged;
1065
+		}
1066
+		// check whether Maildir is a prefix of the current folder's path
1067
+		short maildir_is_prefix = 0;
1068
+		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1069
+			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1070
+        		maildir_is_prefix = 1;
1071
+		// calculate depth of current folder and generate its display name with indented spaces
1072
+		int sidebar_folder_depth = 0;
1073
+		char *sidebar_folder_name;
1074
+		sidebar_folder_name = basename(tmp->path);
1075
+		if ( maildir_is_prefix ) {
1076
+			char *tmp_folder_name;
1077
+			int i;
1078
+			tmp_folder_name = tmp->path + strlen(Maildir);
1079
+			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1080
+				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
1081
+			}   
1082
+			if (sidebar_folder_depth > 0) {
1083
+				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
1084
+				for (i=0; i < sidebar_folder_depth; i++)
1085
+					sidebar_folder_name[i]=' ';
1086
+				sidebar_folder_name[i]=0;
1087
+				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
1088
+			}
1089
+		}
1090
+		printw( "%.*s", SidebarWidth - delim_len + 1,
1091
+			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1092
+			tmp->msg_unread, tmp->msg_flagged));
1093
+		if (sidebar_folder_depth > 0)
1094
+		        free(sidebar_folder_name);
1095
+		lines++;
1096
+	}
1097
+	SETCOLOR(MT_COLOR_NORMAL);
1098
+	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
1099
+		int i = 0;
1100
+		move( lines, 0 );
1101
+		for ( ; i < SidebarWidth - delim_len; i++ )
1102
+			addch(' ');
1103
+	}
1104
+	return 0;
1105
+}
1106
+
1107
+
1108
+void set_buffystats(CONTEXT* Context)
1109
+{
1110
+        BUFFY *tmp = Incoming;
1111
+        while(tmp) {
1112
+                if(Context && !strcmp(tmp->path, Context->path)) {
1113
+			tmp->msg_unread = Context->unread;
1114
+			tmp->msgcount = Context->msgcount;
1115
+                        break;
1116
+                }
1117
+                tmp = tmp->next;
1118
+        }
1119
+}
1120
+
1121
+void scroll_sidebar(int op, int menu)
1122
+{
1123
+        if(!SidebarWidth) return;
1124
+        if(!CurBuffy) return;
1125
+
1126
+	switch (op) {
1127
+		case OP_SIDEBAR_NEXT:
1128
+			if ( CurBuffy->next == NULL ) return;
1129
+			CurBuffy = CurBuffy->next;
1130
+			break;
1131
+		case OP_SIDEBAR_PREV:
1132
+			if ( CurBuffy->prev == NULL ) return;
1133
+			CurBuffy = CurBuffy->prev;
1134
+			break;
1135
+		case OP_SIDEBAR_SCROLL_UP:
1136
+			CurBuffy = TopBuffy;
1137
+			if ( CurBuffy != Incoming ) {
1138
+				calc_boundaries(menu);
1139
+				CurBuffy = CurBuffy->prev;
1140
+			}
1141
+			break;
1142
+		case OP_SIDEBAR_SCROLL_DOWN:
1143
+			CurBuffy = BottomBuffy;
1144
+			if ( CurBuffy->next ) {
1145
+				calc_boundaries(menu);
1146
+				CurBuffy = CurBuffy->next;
1147
+			}
1148
+			break;
1149
+		default:
1150
+			return;
1151
+	}
1152
+	calc_boundaries(menu);
1153
+	draw_sidebar(menu);
1154
+}
1155
+
1156
--- sidebar.h	1970-01-01 01:00:00.000000000 +0100
1157
+++ sidebar.h	2009-02-16 17:07:44.000000000 +0100
1158
@@ -0,0 +1,36 @@
1159
+/*
1160
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1161
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1162
+ * 
1163
+ *     This program is free software; you can redistribute it and/or modify
1164
+ *     it under the terms of the GNU General Public License as published by
1165
+ *     the Free Software Foundation; either version 2 of the License, or
1166
+ *     (at your option) any later version.
1167
+ * 
1168
+ *     This program is distributed in the hope that it will be useful,
1169
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1170
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1171
+ *     GNU General Public License for more details.
1172
+ * 
1173
+ *     You should have received a copy of the GNU General Public License
1174
+ *     along with this program; if not, write to the Free Software
1175
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1176
+ */ 
1177
+
1178
+#ifndef SIDEBAR_H
1179
+#define SIDEBAR_H
1180
+
1181
+struct MBOX_LIST {
1182
+	char *path;
1183
+	int msgcount;
1184
+	int new;
1185
+} MBLIST;
1186
+
1187
+/* parameter is whether or not to go to the status line */
1188
+/* used for omitting the last | that covers up the status bar in the index */
1189
+int draw_sidebar(int);
1190
+void scroll_sidebar(int, int);
1191
+void set_curbuffy(char*);
1192
+void set_buffystats(CONTEXT*);
1193
+
1194
+#endif /* SIDEBAR_H */

Return to bug 131752