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