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 */ |