mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add neomutt version of sidebar patch. (closes #3829)

This is the patch from neomutt; branch 'devel/win-sidebar'; commit
c796fa85f9cacefb69b8f7d8545fc9ba71674180 with the following changes:

- move the sample muttrc and vimrc to contrib.
- remove the README.sidebar.
- empty out the PATCHES file.

+2958 -8
+8 -2
Makefile.am
··· 77 77 78 78 EXTRA_SCRIPTS = smime_keys 79 79 80 + if BUILD_SIDEBAR 81 + mutt_SOURCES += sidebar.c sidebar.h 82 + endif 83 + 84 + EXTRA_DIST += OPS.SIDEBAR 85 + 80 86 mutt_dotlock_SOURCES = mutt_dotlock.c 81 87 mutt_dotlock_LDADD = $(LIBOBJS) 82 88 mutt_dotlock_DEPENDENCIES = $(LIBOBJS) ··· 129 135 keymap_defs.h: $(OPS) $(srcdir)/gen_defs 130 136 $(srcdir)/gen_defs $(OPS) > keymap_defs.h 131 137 132 - keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs 138 + keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs 133 139 rm -f $@ 134 140 $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.PGP \ 135 - $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \ 141 + $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \ 136 142 > keymap_alldefs.h 137 143 138 144 reldate.h: $(srcdir)/ChangeLog
+8
OPS.SIDEBAR
··· 1 + OP_SIDEBAR_NEXT "Move the highlight to next mailbox" 2 + OP_SIDEBAR_NEXT_NEW "Move the highlight to next mailbox with new mail" 3 + OP_SIDEBAR_OPEN "Open highlighted mailbox" 4 + OP_SIDEBAR_PAGE_DOWN "Scroll the Sidebar down 1 page" 5 + OP_SIDEBAR_PAGE_UP "Scroll the Sidebar up 1 page" 6 + OP_SIDEBAR_PREV "Move the highlight to previous mailbox" 7 + OP_SIDEBAR_PREV_NEW "Move the highlight to previous mailbox with new mail" 8 + OP_SIDEBAR_TOGGLE_VISIBLE "Make the Sidebar (in)visible"
+181 -2
buffy.c
··· 27 27 28 28 #include "mutt_curses.h" 29 29 30 + #ifdef USE_SIDEBAR 31 + #include "sidebar.h" 32 + #endif 33 + 30 34 #ifdef USE_IMAP 31 35 #include "imap.h" 32 36 #endif ··· 196 200 static BUFFY *buffy_new (const char *path) 197 201 { 198 202 BUFFY* buffy; 203 + #ifdef USE_SIDEBAR 204 + char rp[PATH_MAX] = ""; 205 + char *r = NULL; 206 + #endif 199 207 200 208 buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY)); 201 209 strfcpy (buffy->path, path, sizeof (buffy->path)); 210 + #ifdef USE_SIDEBAR 211 + r = realpath (path, rp); 212 + strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath)); 213 + #endif 202 214 buffy->next = NULL; 203 215 buffy->magic = 0; 204 216 ··· 215 227 BUFFY **tmp,*tmp1; 216 228 char buf[_POSIX_PATH_MAX]; 217 229 struct stat sb; 218 - char f1[PATH_MAX], f2[PATH_MAX]; 230 + char f1[PATH_MAX]; 231 + #ifndef USE_SIDEBAR 232 + char f2[PATH_MAX]; 233 + #endif 219 234 char *p, *q; 220 235 221 236 while (MoreArgs (s)) ··· 228 243 for (tmp = &Incoming; *tmp;) 229 244 { 230 245 tmp1=(*tmp)->next; 246 + #ifdef USE_SIDEBAR 247 + sb_notify_mailbox (*tmp, 0); 248 + #endif 231 249 buffy_free (tmp); 232 250 *tmp=tmp1; 233 251 } ··· 243 261 p = realpath (buf, f1); 244 262 for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next)) 245 263 { 264 + #ifdef USE_SIDEBAR 265 + q = (*tmp)->realpath; 266 + if (mutt_strcmp (p ? p : buf, q) == 0) 267 + #else 246 268 q = realpath ((*tmp)->path, f2); 247 269 if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0) 270 + #endif 248 271 { 249 272 dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path)); 250 273 break; ··· 256 279 if(*tmp) 257 280 { 258 281 tmp1=(*tmp)->next; 282 + #ifdef USE_SIDEBAR 283 + sb_notify_mailbox (*tmp, 0); 284 + #endif 259 285 buffy_free (tmp); 260 286 *tmp=tmp1; 261 287 } 262 288 continue; 263 289 } 264 290 265 - if (!*tmp) 291 + if (!*tmp) { 266 292 *tmp = buffy_new (buf); 293 + #ifdef USE_SIDEBAR 294 + sb_notify_mailbox (*tmp, 1); 295 + #endif 296 + } 267 297 268 298 (*tmp)->new = 0; 269 299 (*tmp)->notified = 1; ··· 306 336 return 0; 307 337 } 308 338 339 + #ifdef USE_SIDEBAR 340 + if (option (OPTSIDEBAR) && mailbox->msg_unread > 0) { 341 + mailbox->new = 1; 342 + return 1; 343 + } 344 + #endif 345 + 309 346 if ((dirp = opendir (path)) == NULL) 310 347 { 311 348 mailbox->magic = 0; ··· 357 394 358 395 return 0; 359 396 } 397 + 398 + #ifdef USE_SIDEBAR 399 + /** 400 + * buffy_maildir_update_dir - Update counts for one directory 401 + * @mailbox: BUFFY representing a maildir mailbox 402 + * @dir: Which directory to search 403 + * 404 + * Look through one directory of a maildir mailbox. The directory could 405 + * be either "new" or "cur". 406 + * 407 + * Count how many new, or flagged, messages there are. 408 + */ 409 + static void 410 + buffy_maildir_update_dir (BUFFY *mailbox, const char *dir) 411 + { 412 + char path[_POSIX_PATH_MAX] = ""; 413 + DIR *dirp = NULL; 414 + struct dirent *de = NULL; 415 + char *p = NULL; 416 + int read; 417 + 418 + snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir); 419 + 420 + dirp = opendir (path); 421 + if (!dirp) { 422 + mailbox->magic = 0; 423 + return; 424 + } 425 + 426 + while ((de = readdir (dirp)) != NULL) { 427 + if (*de->d_name == '.') 428 + continue; 429 + 430 + /* Matches maildir_parse_flags logic */ 431 + read = 0; 432 + mailbox->msg_count++; 433 + p = strstr (de->d_name, ":2,"); 434 + if (p) { 435 + p += 3; 436 + if (strchr (p, 'S')) 437 + read = 1; 438 + if (strchr (p, 'F')) 439 + mailbox->msg_flagged++; 440 + } 441 + if (!read) { 442 + mailbox->msg_unread++; 443 + } 444 + } 445 + 446 + closedir (dirp); 447 + } 448 + 449 + /** 450 + * buffy_maildir_update - Update messages counts for a maildir mailbox 451 + * @mailbox: BUFFY representing a maildir mailbox 452 + * 453 + * Open a mailbox directories and update our record of how many new, or 454 + * flagged, messages there are. 455 + */ 456 + void 457 + buffy_maildir_update (BUFFY *mailbox) 458 + { 459 + if (!option (OPTSIDEBAR)) 460 + return; 461 + 462 + mailbox->msg_count = 0; 463 + mailbox->msg_unread = 0; 464 + mailbox->msg_flagged = 0; 465 + 466 + buffy_maildir_update_dir (mailbox, "new"); 467 + if (mailbox->msg_count) { 468 + mailbox->new = 1; 469 + } 470 + buffy_maildir_update_dir (mailbox, "cur"); 471 + 472 + mailbox->sb_last_checked = time (NULL); 473 + 474 + /* make sure the updates are actually put on screen */ 475 + sb_draw(); 476 + } 477 + 478 + #endif 479 + 360 480 /* returns 1 if mailbox has new mail */ 361 481 static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) 362 482 { ··· 368 488 else 369 489 statcheck = sb->st_mtime > sb->st_atime 370 490 || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime); 491 + #ifdef USE_SIDEBAR 492 + if ((!option (OPTSIDEBAR) && statcheck) || (option (OPTSIDEBAR) && mailbox->msg_unread > 0)) 493 + #else 371 494 if (statcheck) 495 + #endif 372 496 { 373 497 if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited) 374 498 { ··· 388 512 return rc; 389 513 } 390 514 515 + #ifdef USE_SIDEBAR 516 + /** 517 + * buffy_mbox_update - Update messages counts for an mbox mailbox 518 + * @mailbox: BUFFY representing an mbox mailbox 519 + * @sb: stat(2) infomation about the mailbox file 520 + * 521 + * Open a mbox file and update our record of how many new, or flagged, 522 + * messages there are. If the mailbox hasn't changed since the last call, 523 + * the function does nothing. 524 + */ 525 + void 526 + buffy_mbox_update (BUFFY *mailbox, struct stat *sb) 527 + { 528 + CONTEXT *ctx = NULL; 529 + 530 + if (!option (OPTSIDEBAR)) 531 + return; 532 + if ((mailbox->sb_last_checked > sb->st_mtime) && (mailbox->msg_count != 0)) 533 + return; /* no check necessary */ 534 + 535 + ctx = mx_open_mailbox (mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK, NULL); 536 + if (ctx) { 537 + mailbox->msg_count = ctx->msgcount; 538 + mailbox->msg_unread = ctx->unread; 539 + mailbox->msg_flagged = ctx->flagged; 540 + mailbox->sb_last_checked = time (NULL); 541 + mx_close_mailbox (ctx, 0); 542 + } 543 + 544 + /* make sure the updates are actually put on screen */ 545 + sb_draw(); 546 + } 547 + #endif 548 + 391 549 int mutt_buffy_check (int force) 392 550 { 393 551 BUFFY *tmp; ··· 428 586 contex_sb.st_ino=0; 429 587 } 430 588 589 + #ifdef USE_SIDEBAR 590 + int should_refresh = sb_should_refresh(); 591 + #endif 431 592 for (tmp = Incoming; tmp; tmp = tmp->next) 432 593 { 433 594 if (tmp->magic != MUTT_IMAP) ··· 461 622 { 462 623 case MUTT_MBOX: 463 624 case MUTT_MMDF: 625 + #ifdef USE_SIDEBAR 626 + if (should_refresh) 627 + buffy_mbox_update (tmp, &sb); 628 + #endif 464 629 if (buffy_mbox_hasnew (tmp, &sb) > 0) 465 630 BuffyCount++; 466 631 break; 467 632 468 633 case MUTT_MAILDIR: 634 + #ifdef USE_SIDEBAR 635 + if (should_refresh) 636 + buffy_maildir_update (tmp); 637 + #endif 469 638 if (buffy_maildir_hasnew (tmp) > 0) 470 639 BuffyCount++; 471 640 break; 472 641 473 642 case MUTT_MH: 643 + #ifdef USE_SIDEBAR 644 + if (sb_should_refresh()) { 645 + mh_buffy_update (tmp); 646 + sb_set_update_time(); 647 + } 648 + #endif 474 649 mh_buffy(tmp); 475 650 if (tmp->new) 476 651 BuffyCount++; ··· 485 660 else if (!tmp->notified) 486 661 BuffyNotify++; 487 662 } 663 + #ifdef USE_SIDEBAR 664 + if (should_refresh) 665 + sb_set_update_time(); 666 + #endif 488 667 489 668 BuffyDoneTime = BuffyTime; 490 669 return (BuffyCount);
+20
buffy.h
··· 16 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 17 */ 18 18 19 + #ifndef _BUFFY_H 20 + #define _BUFFY_H 21 + 19 22 /*parameter to mutt_parse_mailboxes*/ 20 23 #define MUTT_MAILBOXES 1 21 24 #define MUTT_UNMAILBOXES 2 ··· 23 26 typedef struct buffy_t 24 27 { 25 28 char path[_POSIX_PATH_MAX]; 29 + #ifdef USE_SIDEBAR 30 + char realpath[_POSIX_PATH_MAX]; 31 + #endif 26 32 off_t size; 27 33 struct buffy_t *next; 34 + #ifdef USE_SIDEBAR 35 + struct buffy_t *prev; 36 + #endif 28 37 short new; /* mailbox has new mail */ 38 + #ifdef USE_SIDEBAR 39 + int msg_count; /* total number of messages */ 40 + int msg_unread; /* number of unread messages */ 41 + int msg_flagged; /* number of flagged messages */ 42 + short is_hidden; /* is hidden from the sidebar */ 43 + #endif 29 44 short notified; /* user has been notified */ 30 45 short magic; /* mailbox type */ 31 46 short newly_created; /* mbox or mmdf just popped into existence */ 32 47 time_t last_visited; /* time of last exit from this mailbox */ 48 + #ifdef USE_SIDEBAR 49 + time_t sb_last_checked; /* time of last buffy check from sidebar */ 50 + #endif 33 51 } 34 52 BUFFY; 35 53 ··· 49 67 void mutt_buffy_setnotified (const char *path); 50 68 51 69 void mh_buffy (BUFFY *); 70 + 71 + #endif /* _BUFFY_H */
+11
color.c
··· 94 94 { "underline", MT_COLOR_UNDERLINE }, 95 95 { "index", MT_COLOR_INDEX }, 96 96 { "prompt", MT_COLOR_PROMPT }, 97 + #ifdef USE_SIDEBAR 98 + { "sidebar_divider", MT_COLOR_DIVIDER }, 99 + { "sidebar_flagged", MT_COLOR_FLAGGED }, 100 + { "sidebar_highlight",MT_COLOR_HIGHLIGHT }, 101 + { "sidebar_indicator",MT_COLOR_SB_INDICATOR }, 102 + { "sidebar_new", MT_COLOR_NEW }, 103 + { "sidebar_spoolfile",MT_COLOR_SB_SPOOLFILE }, 104 + #endif 97 105 { NULL, 0 } 98 106 }; 99 107 ··· 146 154 ColorDefs[MT_COLOR_INDICATOR] = A_REVERSE; 147 155 ColorDefs[MT_COLOR_SEARCH] = A_REVERSE; 148 156 ColorDefs[MT_COLOR_MARKERS] = A_REVERSE; 157 + #ifdef USE_SIDEBAR 158 + ColorDefs[MT_COLOR_HIGHLIGHT] = A_UNDERLINE; 159 + #endif 149 160 /* special meaning: toggle the relevant attribute */ 150 161 ColorDefs[MT_COLOR_BOLD] = 0; 151 162 ColorDefs[MT_COLOR_UNDERLINE] = 0;
+9
configure.ac
··· 175 175 SMIMEAUX_TARGET="smime_keys" 176 176 fi 177 177 178 + AC_ARG_ENABLE(sidebar, AC_HELP_STRING([--enable-sidebar], [Enable Sidebar support]), 179 + [ if test x$enableval = xyes ; then 180 + AC_DEFINE(USE_SIDEBAR,1,[ Define if you want support for the sidebar. ]) 181 + OPS="$OPS \$(srcdir)/OPS.SIDEBAR" 182 + need_sidebar="yes" 183 + fi 184 + ]) 185 + AM_CONDITIONAL(BUILD_SIDEBAR, test x$need_sidebar = xyes) 186 + 178 187 AC_ARG_WITH(mixmaster, AS_HELP_STRING([--with-mixmaster@<:@=PATH@:>@],[Include Mixmaster support]), 179 188 [if test "$withval" != no 180 189 then
+116
contrib/sample.muttrc-sidebar
··· 1 + # This is a complete list of sidebar-related configuration. 2 + 3 + # -------------------------------------------------------------------------- 4 + # VARIABLES - shown with their default values 5 + # -------------------------------------------------------------------------- 6 + 7 + # Should the Sidebar be shown? 8 + set sidebar_visible = no 9 + 10 + # How wide should the Sidebar be in screen columns? 11 + # Note: Some characters, e.g. Chinese, take up two columns each. 12 + set sidebar_width = 20 13 + 14 + # Should the mailbox paths be abbreviated? 15 + set sidebar_short_path = no 16 + 17 + # When abbreviating mailbox path names, use any of these characters as path 18 + # separators. Only the part after the last separators will be shown. 19 + # For file folders '/' is good. For IMAP folders, often '.' is useful. 20 + set sidebar_delim_chars = '/.' 21 + 22 + # If the mailbox path is abbreviated, should it be indented? 23 + set sidebar_folder_indent = no 24 + 25 + # Indent mailbox paths with this string. 26 + set sidebar_indent_string = ' ' 27 + 28 + # Make the Sidebar only display mailboxes that contain new, or flagged, 29 + # mail. 30 + set sidebar_new_mail_only = no 31 + 32 + # Any mailboxes that are whitelisted will always be visible, even if the 33 + # sidebar_new_mail_only option is enabled. 34 + sidebar_whitelist '/home/user/mailbox1' 35 + sidebar_whitelist '/home/user/mailbox2' 36 + 37 + # When searching for mailboxes containing new mail, should the search wrap 38 + # around when it reaches the end of the list? 39 + set sidebar_next_new_wrap = no 40 + 41 + # The character to use as the divider between the Sidebar and the other Mutt 42 + # panels. 43 + # Note: Only the first character of this string is used. 44 + set sidebar_divider_char = '|' 45 + 46 + # Display the Sidebar mailboxes using this format string. 47 + set sidebar_format = '%B%?F? [%F]?%* %?N?%N/?%S' 48 + 49 + # Sidebar will not refresh its list of mailboxes any more frequently than 50 + # this number of seconds. This will help reduce disk/network traffic. 51 + set sidebar_refresh_time = 60 52 + 53 + # Sort the mailboxes in the Sidebar using this method: 54 + # count - total number of messages 55 + # flagged - number of flagged messages 56 + # new - number of new messages 57 + # path - mailbox path 58 + # unsorted - do not sort the mailboxes 59 + set sidebar_sort_method = 'unsorted' 60 + 61 + # -------------------------------------------------------------------------- 62 + # FUNCTIONS - shown with an example mapping 63 + # -------------------------------------------------------------------------- 64 + 65 + # Move the highlight to the previous mailbox 66 + bind index,pager \Cp sidebar-prev 67 + 68 + # Move the highlight to the next mailbox 69 + bind index,pager \Cn sidebar-next 70 + 71 + # Open the highlighted mailbox 72 + bind index,pager \Co sidebar-open 73 + 74 + # Move the highlight to the previous page 75 + # This is useful if you have a LOT of mailboxes. 76 + bind index,pager <F3> sidebar-page-up 77 + 78 + # Move the highlight to the next page 79 + # This is useful if you have a LOT of mailboxes. 80 + bind index,pager <F4> sidebar-page-down 81 + 82 + # Move the highlight to the previous mailbox containing new, or flagged, 83 + # mail. 84 + bind index,pager <F5> sidebar-prev-new 85 + 86 + # Move the highlight to the next mailbox containing new, or flagged, mail. 87 + bind index,pager <F6> sidebar-next-new 88 + 89 + # Toggle the visibility of the Sidebar. 90 + bind index,pager B sidebar-toggle-visible 91 + 92 + # -------------------------------------------------------------------------- 93 + # COLORS - some unpleasant examples are given 94 + # -------------------------------------------------------------------------- 95 + # Note: All color operations are of the form: 96 + # color OBJECT FOREGROUND BACKGROUND 97 + 98 + # Color of the current, open, mailbox 99 + # Note: This is a general Mutt option which colors all selected items. 100 + color indicator cyan black 101 + 102 + # Color of the highlighted, but not open, mailbox. 103 + color sidebar_highlight black color8 104 + 105 + # Color of the divider separating the Sidebar from Mutt panels 106 + color sidebar_divider color8 black 107 + 108 + # Color to give mailboxes containing flagged mail 109 + color sidebar_flagged red black 110 + 111 + # Color to give mailboxes containing new mail 112 + color sidebar_new green black 113 + 114 + # -------------------------------------------------------------------------- 115 + 116 + # vim: syntax=muttrc
+35
contrib/sample.vimrc-sidebar
··· 1 + " Vim syntax file for the mutt sidebar patch 2 + 3 + syntax keyword muttrcVarBool skipwhite contained sidebar_folder_indent nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 4 + syntax keyword muttrcVarBool skipwhite contained sidebar_new_mail_only nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 5 + syntax keyword muttrcVarBool skipwhite contained sidebar_next_new_wrap nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 6 + syntax keyword muttrcVarBool skipwhite contained sidebar_short_path nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 7 + syntax keyword muttrcVarBool skipwhite contained sidebar_visible nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 8 + 9 + syntax keyword muttrcVarNum skipwhite contained sidebar_refresh_time nextgroup=muttrcSetNumAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 10 + syntax keyword muttrcVarNum skipwhite contained sidebar_width nextgroup=muttrcSetNumAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 11 + 12 + syntax keyword muttrcVarStr contained skipwhite sidebar_divider_char nextgroup=muttrcVarEqualsIdxFmt 13 + syntax keyword muttrcVarStr contained skipwhite sidebar_delim_chars nextgroup=muttrcVarEqualsIdxFmt 14 + syntax keyword muttrcVarStr contained skipwhite sidebar_format nextgroup=muttrcVarEqualsIdxFmt 15 + syntax keyword muttrcVarStr contained skipwhite sidebar_indent_string nextgroup=muttrcVarEqualsIdxFmt 16 + syntax keyword muttrcVarStr contained skipwhite sidebar_sort_method nextgroup=muttrcVarEqualsIdxFmt 17 + 18 + syntax keyword muttrcCommand sidebar_whitelist 19 + 20 + syntax match muttrcFunction contained "\<sidebar-next\>" 21 + syntax match muttrcFunction contained "\<sidebar-next-new\>" 22 + syntax match muttrcFunction contained "\<sidebar-open\>" 23 + syntax match muttrcFunction contained "\<sidebar-page-down\>" 24 + syntax match muttrcFunction contained "\<sidebar-page-up\>" 25 + syntax match muttrcFunction contained "\<sidebar-prev\>" 26 + syntax match muttrcFunction contained "\<sidebar-prev-new\>" 27 + syntax match muttrcFunction contained "\<sidebar-toggle-visible\>" 28 + 29 + syntax keyword muttrcColorField contained sidebar_divider 30 + syntax keyword muttrcColorField contained sidebar_flagged 31 + syntax keyword muttrcColorField contained sidebar_highlight 32 + syntax keyword muttrcColorField contained sidebar_indicator 33 + syntax keyword muttrcColorField contained sidebar_new 34 + 35 + " vim: syntax=vim
+61 -2
curs_main.c
··· 26 26 #include "mailbox.h" 27 27 #include "mapping.h" 28 28 #include "sort.h" 29 + #include "buffy.h" 29 30 #include "mx.h" 31 + 32 + #ifdef USE_SIDEBAR 33 + #include "sidebar.h" 34 + #endif 30 35 31 36 #ifdef USE_POP 32 37 #include "pop.h" ··· 593 598 menu->redraw |= REDRAW_STATUS; 594 599 if (do_buffy_notify) 595 600 { 596 - if (mutt_buffy_notify () && option (OPTBEEPNEW)) 597 - beep (); 601 + if (mutt_buffy_notify()) 602 + { 603 + menu->redraw |= REDRAW_STATUS; 604 + if (option (OPTBEEPNEW)) 605 + beep(); 606 + } 598 607 } 599 608 else 600 609 do_buffy_notify = 1; 601 610 } 611 + 612 + #ifdef USE_SIDEBAR 613 + if (option (OPTSIDEBAR)) 614 + menu->redraw |= REDRAW_SIDEBAR; 615 + #endif 602 616 603 617 if (op != -1) 604 618 mutt_curs_set (0); ··· 606 620 if (menu->redraw & REDRAW_FULL) 607 621 { 608 622 menu_redraw_full (menu); 623 + #ifdef USE_SIDEBAR 624 + sb_draw(); 625 + #endif 609 626 mutt_show_error (); 610 627 } 628 + #ifdef USE_SIDEBAR 629 + else if (menu->redraw & REDRAW_SIDEBAR) { 630 + sb_draw(); 631 + menu->redraw &= ~REDRAW_SIDEBAR; 632 + } 633 + #endif 611 634 612 635 if (menu->menu == MENU_MAIN) 613 636 { ··· 631 654 menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); 632 655 mutt_window_move (MuttStatusWindow, 0, 0); 633 656 SETCOLOR (MT_COLOR_STATUS); 657 + #ifdef USE_SIDEBAR 658 + sb_set_buffystats (Context); 659 + #endif 634 660 mutt_paddstr (MuttStatusWindow->cols, buf); 635 661 NORMAL_COLOR; 636 662 menu->redraw &= ~REDRAW_STATUS; ··· 1090 1116 break; 1091 1117 1092 1118 CHECK_MSGCOUNT; 1119 + #ifdef USE_SIDEBAR 1120 + CHECK_VISIBLE; 1121 + #endif 1093 1122 CHECK_READONLY; 1094 1123 { 1095 1124 int oldvcount = Context->vcount; ··· 1149 1178 menu->redraw = REDRAW_FULL; 1150 1179 break; 1151 1180 1181 + #ifdef USE_SIDEBAR 1182 + case OP_SIDEBAR_OPEN: 1183 + #endif 1152 1184 case OP_MAIN_CHANGE_FOLDER: 1153 1185 case OP_MAIN_NEXT_UNREAD_MAILBOX: 1154 1186 ··· 1180 1212 { 1181 1213 mutt_buffy (buf, sizeof (buf)); 1182 1214 1215 + #ifdef USE_SIDEBAR 1216 + if (op == OP_SIDEBAR_OPEN) { 1217 + const char *path = sb_get_highlight(); 1218 + if (!path) 1219 + break; 1220 + strncpy (buf, path, sizeof (buf)); 1221 + } else 1222 + #endif 1183 1223 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 1184 1224 { 1185 1225 if (menu->menu == MENU_PAGER) ··· 1198 1238 } 1199 1239 1200 1240 mutt_expand_path (buf, sizeof (buf)); 1241 + #ifdef USE_SIDEBAR 1242 + sb_set_open_buffy (buf); 1243 + #endif 1201 1244 if (mx_get_magic (buf) <= 0) 1202 1245 { 1203 1246 mutt_error (_("%s is not a mailbox."), buf); ··· 2309 2352 mutt_what_key(); 2310 2353 break; 2311 2354 2355 + #ifdef USE_SIDEBAR 2356 + case OP_SIDEBAR_NEXT: 2357 + case OP_SIDEBAR_NEXT_NEW: 2358 + case OP_SIDEBAR_PAGE_DOWN: 2359 + case OP_SIDEBAR_PAGE_UP: 2360 + case OP_SIDEBAR_PREV: 2361 + case OP_SIDEBAR_PREV_NEW: 2362 + sb_change_mailbox (op); 2363 + break; 2364 + 2365 + case OP_SIDEBAR_TOGGLE_VISIBLE: 2366 + toggle_option (OPTSIDEBAR); 2367 + mutt_reflow_windows(); 2368 + menu->redraw = REDRAW_FULL; 2369 + break; 2370 + #endif 2312 2371 default: 2313 2372 if (menu->menu == MENU_MAIN) 2314 2373 km_error_key (MENU_MAIN);
+1091
doc/manual.xml.head
··· 405 405 406 406 </sect2> 407 407 408 + <sect2 id="intro-sidebar"> 409 + <title>Sidebar</title> 410 + <para> 411 + The Sidebar shows a list of all your mailboxes. The list can be 412 + turned on and off, it can be themed and the list style can be 413 + configured. 414 + </para> 415 + <para> 416 + This part of the manual is suitable for beginners. 417 + If you already know Mutt you could skip ahead to the main 418 + <link linkend="sidebar">Sidebar guide</link>. 419 + If you just want to get started, you could use the sample 420 + <link linkend="sidebar-muttrc">Sidebar muttrc</link>. 421 + </para> 422 + <para> 423 + This version of Sidebar is based on Terry Chan's 424 + <ulink url="http://www.lunar-linux.org/mutt-sidebar/">2015-11-11 release</ulink>. 425 + It contains many 426 + <emphasis role="bold"><link linkend="intro-sidebar-features">new features</link></emphasis>, 427 + lots of 428 + <emphasis role="bold"><link linkend="intro-sidebar-bugfixes">bugfixes</link></emphasis> 429 + and a generous helping of 430 + <emphasis role="bold">new documentation</emphasis> which you are already reading. 431 + </para> 432 + <para> 433 + To check if Mutt supports <quote>Sidebar</quote>, look for the string 434 + <literal>+USE_SIDEBAR</literal> in the mutt version. 435 + </para> 436 + <screen> 437 + mutt -v 438 + </screen> 439 + <para> 440 + <emphasis role="bold">Let's turn on the Sidebar:</emphasis> 441 + </para> 442 + <screen>set sidebar_visible</screen> 443 + <para> 444 + You will see something like this. 445 + A list of mailboxes on the left. 446 + A list of emails, from the selected mailbox, on the right. 447 + </para> 448 + <screen> 449 + <emphasis role="indicator">Fruit [1] 3/8</emphasis>| 1 + Jan 24 Rhys Lee (192) Yew 450 + Animals [1] 2/6| 2 + Feb 11 Grace Hall (167) Ilama 451 + Cars 4| 3 Feb 23 Aimee Scott (450) Nectarine 452 + Seas 1/7| 4 ! Feb 28 Summer Jackson (264) Lemon 453 + | 5 Mar 07 Callum Harrison (464) Raspberry 454 + |<emphasis role="indicator"> 6 N + Mar 24 Samuel Harris (353) Tangerine </emphasis> 455 + | 7 N + Sep 05 Sofia Graham (335) Cherry 456 + | 8 N Sep 16 Ewan Brown (105) Ugli 457 + | 458 + | 459 + </screen> 460 + <para> 461 + This user has four mailboxes: <quote>Fruit</quote>, 462 + <quote>Cars</quote>, <quote>Animals</quote> and 463 + <quote>Seas</quote>. 464 + </para> 465 + <para> 466 + The current, open, mailbox is <quote>Fruit</quote>. We can 467 + also see information about the other mailboxes. For example: 468 + The <quote>Animals</quote> mailbox contains, 1 flagged email, 2 469 + new emails out of a total of 6 emails. 470 + </para> 471 + <sect3 id="intro-sidebar-navigation"> 472 + <title>Navigation</title> 473 + <para> 474 + The Sidebar adds some new <link linkend="sidebar-functions">functions</link> 475 + to Mutt. 476 + </para> 477 + <para> 478 + The user pressed the <quote>c</quote> key to 479 + <literal>&lt;change-folder&gt;</literal> to the 480 + <quote>Animals</quote> mailbox. The Sidebar automatically 481 + updated the indicator to match. 482 + </para> 483 + <screen> 484 + Fruit [1] 3/8| 1 Jan 03 Tia Gibson (362) Caiman 485 + <emphasis role="indicator">Animals [1] 2/6</emphasis>| 2 + Jan 22 Rhys Lee ( 48) Dolphin 486 + Cars 4| 3 ! Aug 16 Ewan Brown (333) Hummingbird 487 + Seas 1/7| 4 Sep 25 Grace Hall ( 27) Capybara 488 + |<emphasis role="indicator"> 5 N + Nov 12 Evelyn Rogers (453) Tapir </emphasis> 489 + | 6 N + Nov 16 Callum Harrison (498) Hedgehog 490 + | 491 + | 492 + | 493 + | 494 + </screen> 495 + <para> 496 + Let's map some functions: 497 + </para> 498 + <screen> 499 + bind index,pager \CP sidebar-prev <emphasis role="comment"># Ctrl-Shift-P - Previous Mailbox</emphasis> 500 + bind index,pager \CN sidebar-next <emphasis role="comment"># Ctrl-Shift-N - Next Mailbox</emphasis> 501 + bind index,pager \CO sidebar-open <emphasis role="comment"># Ctrl-Shift-O - Open Highlighted Mailbox</emphasis> 502 + </screen> 503 + <para> 504 + Press <quote>Ctrl-Shift-N</quote> (Next mailbox) twice will 505 + move the Sidebar <emphasis role="bold">highlight</emphasis> to 506 + down to the <quote>Seas</quote> mailbox. 507 + </para> 508 + <screen> 509 + Fruit [1] 3/8| 1 Jan 03 Tia Gibson (362) Caiman 510 + <emphasis role="indicator">Animals [1] 2/6</emphasis>| 2 + Jan 22 Rhys Lee ( 48) Dolphin 511 + Cars 4| 3 ! Aug 16 Ewan Brown (333) Hummingbird 512 + <emphasis role="highlight">Seas 1/7</emphasis>| 4 Sep 25 Grace Hall ( 27) Capybara 513 + |<emphasis role="indicator"> 5 N + Nov 12 Evelyn Rogers (453) Tapir </emphasis> 514 + | 6 N + Nov 16 Callum Harrison (498) Hedgehog 515 + | 516 + | 517 + | 518 + | 519 + </screen> 520 + <note> 521 + Functions <literal>&lt;sidebar-next&gt;</literal> and 522 + <literal>&lt;sidebar-prev&gt;</literal> move the Sidebar 523 + <emphasis role="bold">highlight</emphasis>. 524 + They <emphasis role="bold">do not</emphasis> change the open 525 + mailbox. 526 + </note> 527 + <para> 528 + Press <quote>Ctrl-Shift-O</quote> 529 + (<literal>&lt;sidebar-open&gt;</literal>) 530 + to open the highlighted mailbox. 531 + </para> 532 + <screen> 533 + Fruit [1] 3/8| 1 ! Mar 07 Finley Jones (139) Molucca Sea 534 + Animals [1] 2/6| 2 + Mar 24 Summer Jackson ( 25) Arafura Sea 535 + Cars 4| 3 + Feb 28 Imogen Baker (193) Pechora Sea 536 + <emphasis role="indicator">Seas 1/7</emphasis>|<emphasis role="indicator"> 4 N + Feb 23 Isla Hussain (348) Balearic Sea </emphasis> 537 + | 538 + | 539 + | 540 + | 541 + | 542 + | 543 + </screen> 544 + </sect3> 545 + <sect3 id="intro-sidebar-features"> 546 + <title>Features</title> 547 + <para> 548 + The Sidebar shows a list of mailboxes in a panel. 549 + <para> 550 + </para> 551 + Everything about the Sidebar can be configured. 552 + </para> 553 + <itemizedlist> 554 + <title><link linkend="intro-sidebar-basics">State of the Sidebar</link></title> 555 + <listitem><para>Visibility</para></listitem> 556 + <listitem><para>Width</para></listitem> 557 + </itemizedlist> 558 + <itemizedlist> 559 + <title><link linkend="intro-sidebar-limit">Which mailboxes are displayed</link></title> 560 + <listitem><para>Display all</para></listitem> 561 + <listitem><para>Limit to mailboxes with new mail</para></listitem> 562 + <listitem><para>Whitelist mailboxes to display always</para></listitem> 563 + </itemizedlist> 564 + <itemizedlist> 565 + <title><link linkend="sidebar-sort">The order in which mailboxes are displayed</link></title> 566 + <title></title> 567 + <listitem><para>Unsorted (order of mailboxes commands)</para></listitem> 568 + <listitem><para>Sorted alphabetically</para></listitem> 569 + <listitem><para>Sorted by number of new mails</para></listitem> 570 + </itemizedlist> 571 + <itemizedlist> 572 + <title><link linkend="intro-sidebar-colors">Color</link></title> 573 + <listitem><para>Sidebar indicators and divider</para></listitem> 574 + <listitem><para>Mailboxes depending on their type</para></listitem> 575 + <listitem><para>Mailboxes depending on their contents</para></listitem> 576 + </itemizedlist> 577 + <itemizedlist> 578 + <title><link linkend="sidebar-functions">Key bindings</link></title> 579 + <listitem><para>Hide/Unhide the Sidebar</para></listitem> 580 + <listitem><para>Select previous/next mailbox</para></listitem> 581 + <listitem><para>Select previous/next mailbox with new mail</para></listitem> 582 + <listitem><para>Page up/down through a list of mailboxes</para></listitem> 583 + </itemizedlist> 584 + <itemizedlist> 585 + <title>Misc</title> 586 + <listitem><para><link linkend="intro-sidebar-format">Formatting string for mailbox</link></para></listitem> 587 + <listitem><para><link linkend="sidebar-next-new-wrap">Wraparound searching</link></para></listitem> 588 + <listitem><para><link linkend="intro-sidebar-abbrev">Flexible mailbox abbreviations</link></para></listitem> 589 + <listitem><para>Support for Unicode mailbox names (utf-8)</para></listitem> 590 + </itemizedlist> 591 + </sect3> 592 + <sect3 id="intro-sidebar-display"> 593 + <title>Display</title> 594 + <para> 595 + Everything about the Sidebar can be configured. 596 + </para> 597 + <itemizedlist> 598 + <title>For a quick reference:</title> 599 + <listitem><para><link linkend="sidebar-variables">Sidebar variables to set</link> </para></listitem> 600 + <listitem><para><link linkend="sidebar-colors">Sidebar colors to apply</link></para></listitem> 601 + <listitem><para><link linkend="sidebar-sort">Sidebar sort methods</link></para></listitem> 602 + </itemizedlist> 603 + <sect4 id="intro-sidebar-basics"> 604 + <title>Sidebar Basics</title> 605 + <para> 606 + The most important variable is <literal>$sidebar_visible</literal>. 607 + You can set this in your <quote>muttrc</quote>, or bind a key to the 608 + function <literal>&lt;sidebar-toggle-visible&gt;</literal>. 609 + </para> 610 + <screen> 611 + set sidebar_visible <emphasis role="comment"># Make the Sidebar visible by default</emphasis> 612 + bind index,pager B sidebar-toggle-visible <emphasis role="comment"># Use 'B' to switch the Sidebar on and off</emphasis> 613 + </screen> 614 + <para> 615 + Next, decide how wide you want the Sidebar to be. 25 616 + characters might be enough for the mailbox name and some numbers. 617 + Remember, you can hide/show the Sidebar at the press of button. 618 + </para> 619 + <para> 620 + Finally, you might want to change the divider character. 621 + By default, Sidebar draws an ASCII line between it and the Index panel 622 + If your terminal supports it, you can use a Unicode line-drawing character. 623 + </para> 624 + <screen> 625 + set sidebar_width = 25 <emphasis role="comment"># Plenty of space</emphasis> 626 + set sidebar_divider_char = '│' <emphasis role="comment"># Pretty line-drawing character</emphasis> 627 + </screen> 628 + </sect4> 629 + <sect4 id="intro-sidebar-format"> 630 + <title>Sidebar Format String</title> 631 + <para> 632 + <literal>$sidebar_format</literal> allows you to customize the Sidebar display. 633 + For an introduction, read <link linkend="index-format">format strings</link> 634 + including the section about <link linkend="formatstrings-conditionals">conditionals</link>. 635 + </para> 636 + <para> 637 + The default value is <literal>%B%?F? [%F]?%* %?N?%N/?%S</literal> 638 + </para> 639 + <itemizedlist> 640 + <title>Which breaks down as:</title> 641 + <listitem><para><literal>%B</literal> - Mailbox name</para></listitem> 642 + <listitem><para><literal>%?F? [%F]?</literal> - If flagged emails <literal>[%F]</literal>, otherwise nothing</para></listitem> 643 + <listitem><para><literal>%* </literal> - Pad with spaces</para></listitem> 644 + <listitem><para><literal>%?N?%N/?</literal> - If new emails <literal>%N/</literal>, otherwise nothing</para></listitem> 645 + <listitem><para><literal>%S</literal> - Total number of emails</para></listitem> 646 + </itemizedlist> 647 + <table> 648 + <title>sidebar_format</title> 649 + <tgroup cols="3"> 650 + <thead> 651 + <row> 652 + <entry>Format</entry> 653 + <entry>Notes</entry> 654 + <entry>Description</entry> 655 + </row> 656 + </thead> 657 + <tbody> 658 + <row> 659 + <entry>%B</entry> 660 + <entry></entry> 661 + <entry>Name of the mailbox</entry> 662 + </row> 663 + <row> 664 + <entry>%S</entry> 665 + <entry>*</entry> 666 + <entry>Size of mailbox (total number of messages)</entry> 667 + </row> 668 + <row> 669 + <entry>%N</entry> 670 + <entry>*</entry> 671 + <entry>Number of New messages in the mailbox</entry> 672 + </row> 673 + <row> 674 + <entry>%F</entry> 675 + <entry>*</entry> 676 + <entry>Number of Flagged messages in the mailbox</entry> 677 + </row> 678 + <row> 679 + <entry>%!</entry> 680 + <entry></entry> 681 + <entry> 682 + <quote>!</quote>: one flagged message; 683 + <quote>!!</quote>: two flagged messages; 684 + <quote>n!</quote>: n flagged messages (for n &gt; 2). 685 + Otherwise prints nothing. 686 + </entry> 687 + </row> 688 + <row> 689 + <entry>%d</entry> 690 + <entry>* ‡</entry> 691 + <entry>Number of deleted messages</entry> 692 + </row> 693 + <row> 694 + <entry>%L</entry> 695 + <entry>* ‡</entry> 696 + <entry>Number of messages after limiting</entry> 697 + </row> 698 + <row> 699 + <entry>%t</entry> 700 + <entry>* ‡</entry> 701 + <entry>Number of tagged messages</entry> 702 + </row> 703 + <row> 704 + <entry>%&gt;X</entry> 705 + <entry></entry> 706 + <entry>Right justify the rest of the string and pad with <quote>X</quote></entry> 707 + </row> 708 + <row> 709 + <entry>%|X</entry> 710 + <entry></entry> 711 + <entry>Pad to the end of the line with 712 + <quote>X</quote></entry> 713 + </row> 714 + <row> 715 + <entry>%*X</entry> 716 + <entry></entry> 717 + <entry>Soft-fill with character <quote>X</quote>as pad</entry> 718 + </row> 719 + </tbody> 720 + </tgroup> 721 + </table> 722 + <para> 723 + * = Can be optionally printed if nonzero 724 + </para> 725 + <para> 726 + ‡ = Only applicable to the current folder 727 + </para> 728 + <para> 729 + Here are some examples. 730 + They show the number of (F)lagged, (N)ew and (S)ize. 731 + </para> 732 + <table> 733 + <title>sidebar_format</title> 734 + <tgroup cols="2"> 735 + <thead> 736 + <row> 737 + <entry>Format</entry> 738 + <entry>Example</entry> 739 + </row> 740 + </thead> 741 + <tbody> 742 + <row> 743 + <entry><literal>%B%?F? [%F]?%* %?N?%N/?%S</literal></entry> 744 + <entry><screen>mailbox [F] N/S</screen></entry> 745 + </row> 746 + <row> 747 + <entry><literal>%B%* %F:%N:%S</literal></entry> 748 + <entry><screen>mailbox F:N:S</screen></entry> 749 + </row> 750 + <row> 751 + <entry><literal>%B %?N?(%N)?%* %S</literal></entry> 752 + <entry><screen>mailbox (N) S</screen></entry> 753 + </row> 754 + <row> 755 + <entry><literal>%B%* ?F?%F/?%N</literal></entry> 756 + <entry><screen>mailbox F/S</screen></entry> 757 + </row> 758 + </tbody> 759 + </tgroup> 760 + </table> 761 + </sect4> 762 + <sect4 id="intro-sidebar-abbrev"> 763 + <title>Abbreviating Mailbox Names</title> 764 + <para> 765 + <literal>$sidebar_delim_chars</literal> tells Sidebar 766 + how to split up mailbox paths. For local directories 767 + use <quote>/</quote>; for IMAP folders use <quote>.</quote> 768 + </para> 769 + <sect5 id="intro-sidebar-abbrev-ex1"> 770 + <title>Example 1</title> 771 + <para> 772 + This example works well if your mailboxes have unique names 773 + after the last separator. 774 + </para> 775 + <para> 776 + Add some mailboxes of diffent depths. 777 + </para> 778 + <screen> 779 + set folder="~/mail" 780 + mailboxes =fruit/apple =fruit/banana =fruit/cherry 781 + mailboxes =water/sea/sicily =water/sea/archipelago =water/sea/sibuyan 782 + mailboxes =water/ocean/atlantic =water/ocean/pacific =water/ocean/arctic 783 + </screen> 784 + <para> 785 + Shorten the names: 786 + </para> 787 + <screen> 788 + set sidebar_short_path <emphasis role="comment"># Shorten mailbox names</emphasis> 789 + set sidebar_delim_chars="/" <emphasis role="comment"># Delete everything up to the last / character</emphasis> 790 + </screen> 791 + <para> 792 + The screenshot below shows what the Sidebar would look like 793 + before and after shortening. 794 + </para> 795 + <screen> 796 + |fruit/apple |apple 797 + |fruit/banana |banana 798 + |fruit/cherry |cherry 799 + |water/sea/sicily |sicily 800 + |water/sea/archipelago |archipelago 801 + |water/sea/sibuyan |sibuyan 802 + |water/ocean/atlantic |atlantic 803 + |water/ocean/pacific |pacific 804 + |water/ocean/arctic |arctic 805 + </screen> 806 + </sect5> 807 + <sect5 id="intro-sidebar-abbrev-ex2"> 808 + <title>Example 2</title> 809 + <para> 810 + This example works well if you have lots of mailboxes which are arranged 811 + in a tree. 812 + </para> 813 + <para> 814 + Add some mailboxes of diffent depths. 815 + </para> 816 + <screen> 817 + set folder="~/mail" 818 + mailboxes =fruit 819 + mailboxes =fruit/apple =fruit/banana =fruit/cherry 820 + mailboxes =water 821 + mailboxes =water/sea 822 + mailboxes =water/sea/sicily =water/sea/archipelago =water/sea/sibuyan 823 + mailboxes =water/ocean 824 + mailboxes =water/ocean/atlantic =water/ocean/pacific =water/ocean/arctic 825 + </screen> 826 + <para> 827 + Shorten the names: 828 + </para> 829 + <screen> 830 + set sidebar_short_path <emphasis role="comment"># Shorten mailbox names</emphasis> 831 + set sidebar_delim_chars="/" <emphasis role="comment"># Delete everything up to the last / character</emphasis> 832 + set sidebar_folder_indent <emphasis role="comment"># Indent folders whose names we've shortened</emphasis> 833 + set sidebar_indent_string=" " <emphasis role="comment"># Indent with two spaces</emphasis> 834 + </screen> 835 + <para> 836 + The screenshot below shows what the Sidebar would look like 837 + before and after shortening. 838 + </para> 839 + <screen> 840 + |fruit |fruit 841 + |fruit/apple | apple 842 + |fruit/banana | banana 843 + |fruit/cherry | cherry 844 + |water |water 845 + |water/sea | sea 846 + |water/sea/sicily | sicily 847 + |water/sea/archipelago | archipelago 848 + |water/sea/sibuyan | sibuyan 849 + |water/ocean | ocean 850 + |water/ocean/atlantic | atlantic 851 + |water/ocean/pacific | pacific 852 + |water/ocean/arctic | arctic 853 + </screen> 854 + <para> 855 + Sometimes, it will be necessary to add mailboxes, that you 856 + don't use, to fill in part of the tree. This will trade 857 + vertical space for horizonal space (but it looks good). 858 + </para> 859 + </sect5> 860 + </sect4> 861 + <sect4 id="intro-sidebar-limit"> 862 + <title>Limiting the Number of Mailboxes</title> 863 + <para> 864 + If you have a lot of mailboxes, sometimes it can be useful to hide 865 + the ones you aren't using. <literal>$sidebar_new_mail_only</literal> 866 + tells Sidebar to only show mailboxes that contain new, or flagged, email. 867 + </para> 868 + <para> 869 + If you want some mailboxes to be always visible, then use the 870 + <literal>sidebar_whitelist</literal> command. It takes a list of 871 + mailboxes as parameters. 872 + </para> 873 + <screen> 874 + set sidebar_new_mail_only <emphasis role="comment"># Only mailboxes with new/flagged email</emphasis> 875 + sidebar_whitelist fruit fruit/apple <emphasis role="comment"># Always display these two mailboxes</emphasis> 876 + </screen> 877 + </sect4> 878 + </sect3> 879 + <sect3 id="intro-sidebar-colors"> 880 + <title>Colors</title> 881 + <para> 882 + Here is a sample color scheme: 883 + </para> 884 + <screen> 885 + color sidebar_indicator default color17 <emphasis role="comment"># Dark blue background</emphasis> 886 + color sidebar_highlight white color238 <emphasis role="comment"># Grey background</emphasis> 887 + color sidebar_spoolfile yellow default <emphasis role="comment"># Yellow</emphasis> 888 + color sidebar_new green default <emphasis role="comment"># Green</emphasis> 889 + color sidebar_flagged red default <emphasis role="comment"># Red</emphasis> 890 + color sidebar_divider color8 default <emphasis role="comment"># Dark grey</emphasis> 891 + </screen> 892 + <para> 893 + There is a priority order when coloring Sidebar mailboxes. 894 + e.g. If a mailbox has new mail it will have the 895 + <literal>sidebar_new</literal> color, even if it also contains 896 + flagged mails. 897 + </para> 898 + <table id="table-intro-sidebar-colors"> 899 + <title>Sidebar Color Priority</title> 900 + <tgroup cols="3"> 901 + <thead> 902 + <row> 903 + <entry>Priority</entry> 904 + <entry>Color</entry> 905 + <entry>Description</entry> 906 + </row> 907 + </thead> 908 + <tbody> 909 + <row> 910 + <entry>Highest</entry> 911 + <entry><literal>sidebar_indicator</literal></entry> 912 + <entry>Mailbox is open</entry> 913 + </row> 914 + <row> 915 + <entry></entry> 916 + <entry><literal>sidebar_highlight</literal></entry> 917 + <entry>Mailbox is highlighed</entry> 918 + </row> 919 + <row> 920 + <entry></entry> 921 + <entry><literal>sidebar_spoolfile</literal></entry> 922 + <entry>Mailbox is the spoolfile (receives incoming mail)</entry> 923 + </row> 924 + <row> 925 + <entry></entry> 926 + <entry><literal>sidebar_new</literal></entry> 927 + <entry>Mailbox contains new mail</entry> 928 + </row> 929 + <row> 930 + <entry></entry> 931 + <entry><literal>sidebar_flagged</literal></entry> 932 + <entry>Mailbox contains flagged mail</entry> 933 + </row> 934 + <row> 935 + <entry>Lowest</entry> 936 + <entry>(None)</entry> 937 + <entry>Mailbox does not match above</entry> 938 + </row> 939 + </tbody> 940 + </tgroup> 941 + </table> 942 + </sect3> 943 + <sect3 id="intro-sidebar-bugfixes"> 944 + <title>Bug-fixes</title> 945 + <para> 946 + If you haven't used Sidebar before, you can ignore this section. 947 + </para> 948 + <para> 949 + These bugs have been fixed since the previous Sidebar release: 2015-11-11. 950 + </para> 951 + <itemizedlist> 952 + <listitem><para>Fix bug when starting in compose mode</para></listitem> 953 + <listitem><para>Fix bug with empty sidebar_divider_char string</para></listitem> 954 + <listitem><para>Fix bug with header wrapping</para></listitem> 955 + <listitem><para>Correctly handle utf8 character sequences</para></listitem> 956 + <listitem><para>Fix a bug in mh_buffy_update</para></listitem> 957 + <listitem><para>Fix refresh -- time overflowed short</para></listitem> 958 + <listitem><para>Protect against empty format strings</para></listitem> 959 + <listitem><para>Limit Sidebar width to COLS</para></listitem> 960 + <listitem><para>Handle unmailboxes * safely</para></listitem> 961 + <listitem><para>Refresh Sidebar after timeout</para></listitem> 962 + </itemizedlist> 963 + </sect3> 964 + <sect3 id="intro-sidebar-config-changes"> 965 + <title>Config Changes</title> 966 + <para> 967 + If you haven't used Sidebar before, you can ignore this section. 968 + </para> 969 + <para> 970 + Some of the Sidebar config has been changed to make its meaning clearer. 971 + These changes have been made since the previous Sidebar release: 2015-11-11. 972 + </para> 973 + <table id="table-intro-sidebar-config-changes"> 974 + <title>Config Changes</title> 975 + <tgroup cols="2"> 976 + <thead> 977 + <row> 978 + <entry>Old Name</entry> 979 + <entry>New Name</entry> 980 + </row> 981 + </thead> 982 + <tbody> 983 + <row> 984 + <entry><literal>$sidebar_delim</literal></entry> 985 + <entry><literal>$sidebar_divider_char</literal></entry> 986 + </row> 987 + <row> 988 + <entry><literal>$sidebar_folderindent</literal></entry> 989 + <entry><literal>$sidebar_folder_indent</literal></entry> 990 + </row> 991 + <row> 992 + <entry><literal>$sidebar_indentstr</literal></entry> 993 + <entry><literal>$sidebar_indent_string</literal></entry> 994 + </row> 995 + <row> 996 + <entry><literal>$sidebar_newmail_only</literal></entry> 997 + <entry><literal>$sidebar_new_mail_only</literal></entry> 998 + </row> 999 + <row> 1000 + <entry><literal>$sidebar_refresh</literal></entry> 1001 + <entry><literal>$sidebar_refresh_time</literal></entry> 1002 + </row> 1003 + <row> 1004 + <entry><literal>$sidebar_shortpath</literal></entry> 1005 + <entry><literal>$sidebar_short_path</literal></entry> 1006 + </row> 1007 + <row> 1008 + <entry><literal>$sidebar_sort</literal></entry> 1009 + <entry><literal>$sidebar_sort_method</literal></entry> 1010 + </row> 1011 + <row> 1012 + <entry><literal>&lt;sidebar-scroll-down&gt;</literal></entry> 1013 + <entry><literal>&lt;sidebar-page-down&gt;</literal></entry> 1014 + </row> 1015 + <row> 1016 + <entry><literal>&lt;sidebar-scroll-up&gt;</literal></entry> 1017 + <entry><literal>&lt;sidebar-page-up&gt;</literal></entry> 1018 + </row> 1019 + </tbody> 1020 + </tgroup> 1021 + </table> 1022 + </sect3> 1023 + </sect2> 1024 + 408 1025 <sect2 id="intro-help"> 409 1026 <title>Help</title> 410 1027 ··· 8092 8709 8093 8710 </sect1> 8094 8711 8712 + <sect1 id="sidebar"> 8713 + <title>Sidebar Patch</title> 8714 + <subtitle>Overview of mailboxes</subtitle> 8715 + 8716 + <sect2 id="sidebar-patch"> 8717 + <title>Patch</title> 8718 + 8719 + <para> 8720 + To check if Mutt supports <quote>Sidebar</quote>, look for 8721 + <quote>+USE_SIDEBAR</quote> in the mutt version. 8722 + See: <xref linkend="compile-time-features"/>. 8723 + </para> 8724 + 8725 + <itemizedlist> 8726 + <title>Dependencies:</title> 8727 + <listitem><para>mutt-1.5.24</para></listitem> 8728 + </itemizedlist> 8729 + 8730 + <para>This patch is part of the <ulink url="http://www.neomutt.org/">NeoMutt Project</ulink>.</para> 8731 + </sect2> 8732 + 8733 + <sect2 id="sidebar-intro"> 8734 + <title>Introduction</title> 8735 + 8736 + <para> 8737 + The Sidebar shows a list of all your mailboxes. The list can be 8738 + turned on and off, it can be themed and the list style can be 8739 + configured. 8740 + </para> 8741 + 8742 + <para> 8743 + This part of the manual is a reference guide. 8744 + If you want a simple introduction with examples see the 8745 + <link linkend="intro-sidebar">Sidebar Howto</link>. 8746 + If you just want to get started, you could use the sample 8747 + <link linkend="sidebar-muttrc">Sidebar muttrc</link>. 8748 + </para> 8749 + 8750 + <para> 8751 + This version of Sidebar is based on Terry Chan's 8752 + <ulink url="http://www.lunar-linux.org/mutt-sidebar/">2015-11-11 release</ulink>. 8753 + It contains many 8754 + <emphasis role="bold"><link linkend="intro-sidebar-features">new features</link></emphasis>, 8755 + lots of 8756 + <emphasis role="bold"><link linkend="intro-sidebar-bugfixes">bugfixes</link></emphasis>. 8757 + </para> 8758 + </sect2> 8759 + 8760 + <sect2 id="sidebar-variables"> 8761 + <title>Variables</title> 8762 + 8763 + <table id="table-sidebar-variables"> 8764 + <title>Sidebar Variables</title> 8765 + <tgroup cols="3"> 8766 + <thead> 8767 + <row> 8768 + <entry>Name</entry> 8769 + <entry>Type</entry> 8770 + <entry>Default</entry> 8771 + </row> 8772 + </thead> 8773 + <tbody> 8774 + <row> 8775 + <entry><literal>sidebar_delim_chars</literal></entry> 8776 + <entry>string</entry> 8777 + <entry><literal>/.</literal></entry> 8778 + </row> 8779 + <row> 8780 + <entry><literal>sidebar_divider_char</literal></entry> 8781 + <entry>string</entry> 8782 + <entry><literal>|</literal></entry> 8783 + </row> 8784 + <row> 8785 + <entry><literal>sidebar_folder_indent</literal></entry> 8786 + <entry>boolean</entry> 8787 + <entry><literal>no</literal></entry> 8788 + </row> 8789 + <row> 8790 + <entry><literal>sidebar_format</literal></entry> 8791 + <entry>string</entry> 8792 + <entry><literal>%B%?F? [%F]?%* %?N?%N/?%S</literal></entry> 8793 + </row> 8794 + <row> 8795 + <entry><literal>sidebar_indent_string</literal></entry> 8796 + <entry>string</entry> 8797 + <entry><literal>&nbsp;&nbsp;</literal> (two spaces)</entry> 8798 + </row> 8799 + <row> 8800 + <entry><literal>sidebar_new_mail_only</literal></entry> 8801 + <entry>boolean</entry> 8802 + <entry><literal>no</literal></entry> 8803 + </row> 8804 + <row> 8805 + <entry><literal>sidebar_next_new_wrap</literal></entry> 8806 + <entry>boolean</entry> 8807 + <entry><literal>no</literal></entry> 8808 + </row> 8809 + <row> 8810 + <entry><literal>sidebar_refresh_time</literal></entry> 8811 + <entry>number</entry> 8812 + <entry><literal>60</literal></entry> 8813 + </row> 8814 + <row> 8815 + <entry><literal>sidebar_short_path</literal></entry> 8816 + <entry>boolean</entry> 8817 + <entry><literal>no</literal></entry> 8818 + </row> 8819 + <row> 8820 + <entry><literal>sidebar_sort_method</literal></entry> 8821 + <entry>enum</entry> 8822 + <entry><literal>SORT_ORDER</literal></entry> 8823 + </row> 8824 + <row> 8825 + <entry><literal>sidebar_visible</literal></entry> 8826 + <entry>boolean</entry> 8827 + <entry><literal>no</literal></entry> 8828 + </row> 8829 + <row> 8830 + <entry><literal>sidebar_whitelist</literal></entry> 8831 + <entry>list</entry> 8832 + <entry>(empty)</entry> 8833 + </row> 8834 + <row> 8835 + <entry><literal>sidebar_width</literal></entry> 8836 + <entry>number</entry> 8837 + <entry><literal>20</literal></entry> 8838 + </row> 8839 + </tbody> 8840 + </tgroup> 8841 + </table> 8842 + </sect2> 8843 + 8844 + <sect2 id="sidebar-functions"> 8845 + <title>Functions</title> 8846 + 8847 + <para> 8848 + Sidebar adds the following functions to Mutt. 8849 + By default, none of them are bound to keys. 8850 + </para> 8851 + 8852 + <table id="table-sidebar-functions"> 8853 + <title>Sidebar Functions</title> 8854 + <tgroup cols="3"> 8855 + <thead> 8856 + <row> 8857 + <entry>Menus</entry> 8858 + <entry>Function</entry> 8859 + <entry>Description</entry> 8860 + </row> 8861 + </thead> 8862 + <tbody> 8863 + <row> 8864 + <entry>index,pager</entry> 8865 + <entry><literal>&lt;sidebar-next&gt;</literal></entry> 8866 + <entry>Move the highlight to next mailbox</entry> 8867 + </row> 8868 + <row> 8869 + <entry>index,pager</entry> 8870 + <entry><literal>&lt;sidebar-next-new&gt;</literal></entry> 8871 + <entry>Move the highlight to next mailbox with new mail</entry> 8872 + </row> 8873 + <row> 8874 + <entry>index,pager</entry> 8875 + <entry><literal>&lt;sidebar-open&gt;</literal></entry> 8876 + <entry>Open highlighted mailbox</entry> 8877 + </row> 8878 + <row> 8879 + <entry>index,pager</entry> 8880 + <entry><literal>&lt;sidebar-page-down&gt;</literal></entry> 8881 + <entry>Scroll the Sidebar down 1 page</entry> 8882 + </row> 8883 + <row> 8884 + <entry>index,pager</entry> 8885 + <entry><literal>&lt;sidebar-page-up&gt;</literal></entry> 8886 + <entry>Scroll the Sidebar up 1 page</entry> 8887 + </row> 8888 + <row> 8889 + <entry>index,pager</entry> 8890 + <entry><literal>&lt;sidebar-prev&gt;</literal></entry> 8891 + <entry>Move the highlight to previous mailbox</entry> 8892 + </row> 8893 + <row> 8894 + <entry>index,pager</entry> 8895 + <entry><literal>&lt;sidebar-prev-new&gt;</literal></entry> 8896 + <entry>Move the highlight to previous mailbox with new mail</entry> 8897 + </row> 8898 + <row> 8899 + <entry>index,pager</entry> 8900 + <entry><literal>&lt;sidebar-toggle-visible&gt;</literal></entry> 8901 + <entry>Make the Sidebar (in)visible</entry> 8902 + </row> 8903 + </tbody> 8904 + </tgroup> 8905 + </table> 8906 + </sect2> 8907 + 8908 + <sect2 id="sidebar-commands"> 8909 + <title>Commands</title> 8910 + <cmdsynopsis> 8911 + <command>sidebar_whitelist</command> 8912 + <arg choice="plain"> 8913 + <replaceable class="parameter">mailbox</replaceable> 8914 + </arg> 8915 + <arg choice="opt" rep="repeat"> 8916 + <replaceable class="parameter">mailbox</replaceable> 8917 + </arg> 8918 + </cmdsynopsis> 8919 + </sect2> 8920 + 8921 + <sect2 id="sidebar-colors"> 8922 + <title>Colors</title> 8923 + 8924 + <table id="table-sidebar-colors"> 8925 + <title>Sidebar Colors</title> 8926 + <tgroup cols="3"> 8927 + <thead> 8928 + <row> 8929 + <entry>Name</entry> 8930 + <entry>Default Color</entry> 8931 + <entry>Description</entry> 8932 + </row> 8933 + </thead> 8934 + <tbody> 8935 + <row> 8936 + <entry><literal>sidebar_divider</literal></entry> 8937 + <entry>default</entry> 8938 + <entry>The dividing line between the Sidebar and the Index/Pager panels</entry> 8939 + </row> 8940 + <row> 8941 + <entry><literal>sidebar_flagged</literal></entry> 8942 + <entry>default</entry> 8943 + <entry>Mailboxes containing flagged mail</entry> 8944 + </row> 8945 + <row> 8946 + <entry><literal>sidebar_highlight</literal></entry> 8947 + <entry>underline</entry> 8948 + <entry>Cursor to select a mailbox</entry> 8949 + </row> 8950 + <row> 8951 + <entry><literal>sidebar_indicator</literal></entry> 8952 + <entry>mutt <literal>indicator</literal></entry> 8953 + <entry>The mailbox open in the Index panel</entry> 8954 + </row> 8955 + <row> 8956 + <entry><literal>sidebar_new</literal></entry> 8957 + <entry>default</entry> 8958 + <entry>Mailboxes containing new mail</entry> 8959 + </row> 8960 + <row> 8961 + <entry><literal>sidebar_spoolfile</literal></entry> 8962 + <entry>default</entry> 8963 + <entry>Mailbox that receives incoming mail</entry> 8964 + </row> 8965 + </tbody> 8966 + </tgroup> 8967 + </table> 8968 + 8969 + If the <literal>sidebar_indicator</literal> color isn't set, then the default Mutt 8970 + indicator color will be used (the color used in the index panel). 8971 + </sect2> 8972 + 8973 + <sect2 id="sidebar-sort"> 8974 + <title>Sort</title> 8975 + 8976 + <table id="table-sidebar-sort"> 8977 + <title>Sidebar Sort</title> 8978 + <tgroup cols="2"> 8979 + <thead> 8980 + <row> 8981 + <entry>Sort</entry> 8982 + <entry>Description</entry> 8983 + </row> 8984 + </thead> 8985 + <tbody> 8986 + <row> 8987 + <entry><literal>alpha</literal></entry> 8988 + <entry>Alphabetically by path</entry> 8989 + </row> 8990 + <row> 8991 + <entry><literal>count</literal></entry> 8992 + <entry>Total number of messages</entry> 8993 + </row> 8994 + <row> 8995 + <entry><literal>flagged</literal></entry> 8996 + <entry>Number of flagged messages</entry> 8997 + </row> 8998 + <row> 8999 + <entry><literal>name</literal></entry> 9000 + <entry>Alphabetically by path</entry> 9001 + </row> 9002 + <row> 9003 + <entry><literal>new</literal></entry> 9004 + <entry>Number of new messages</entry> 9005 + </row> 9006 + <row> 9007 + <entry><literal>path</literal></entry> 9008 + <entry>Alphabetically by path</entry> 9009 + </row> 9010 + <row> 9011 + <entry><literal>unsorted</literal></entry> 9012 + <entry>Do not resort the paths</entry> 9013 + </row> 9014 + </tbody> 9015 + </tgroup> 9016 + </table> 9017 + </sect2> 9018 + 9019 + <sect2 id="sidebar-muttrc"> 9020 + <title>Muttrc</title> 9021 + <screen> 9022 + <emphasis role="comment"># This is a complete list of sidebar-related configuration. 9023 + 9024 + # -------------------------------------------------------------------------- 9025 + # VARIABLES - shown with their default values 9026 + # -------------------------------------------------------------------------- 9027 + 9028 + # Should the Sidebar be shown?</emphasis> 9029 + set sidebar_visible = no 9030 + 9031 + <emphasis role="comment"># How wide should the Sidebar be in screen columns? 9032 + # Note: Some characters, e.g. Chinese, take up two columns each.</emphasis> 9033 + set sidebar_width = 20 9034 + 9035 + <emphasis role="comment"># Should the mailbox paths be abbreviated?</emphasis> 9036 + set sidebar_short_path = no 9037 + 9038 + <emphasis role="comment"># When abbreviating mailbox path names, use any of these characters as path 9039 + # separators. Only the part after the last separators will be shown. 9040 + # For file folders '/' is good. For IMAP folders, often '.' is useful.</emphasis> 9041 + set sidebar_delim_chars = '/.' 9042 + 9043 + <emphasis role="comment"># If the mailbox path is abbreviated, should it be indented?</emphasis> 9044 + set sidebar_folder_indent = no 9045 + 9046 + <emphasis role="comment"># Indent mailbox paths with this string.</emphasis> 9047 + set sidebar_indent_string = ' ' 9048 + 9049 + <emphasis role="comment"># Make the Sidebar only display mailboxes that contain new, or flagged, 9050 + # mail.</emphasis> 9051 + set sidebar_new_mail_only = no 9052 + 9053 + <emphasis role="comment"># Any mailboxes that are whitelisted will always be visible, even if the 9054 + # sidebar_new_mail_only option is enabled.</emphasis> 9055 + sidebar_whitelist '/home/user/mailbox1' 9056 + sidebar_whitelist '/home/user/mailbox2' 9057 + 9058 + <emphasis role="comment"># When searching for mailboxes containing new mail, should the search wrap 9059 + # around when it reaches the end of the list?</emphasis> 9060 + set sidebar_next_new_wrap = no 9061 + 9062 + <emphasis role="comment"># The character to use as the divider between the Sidebar and the other Mutt 9063 + # panels. 9064 + # Note: Only the first character of this string is used.</emphasis> 9065 + set sidebar_divider_char = '|' 9066 + 9067 + <emphasis role="comment"># Display the Sidebar mailboxes using this format string.</emphasis> 9068 + set sidebar_format = '%B%?F? [%F]?%* %?N?%N/?%S' 9069 + 9070 + <emphasis role="comment"># Sidebar will not refresh its list of mailboxes any more frequently than 9071 + # this number of seconds. This will help reduce disk/network traffic.</emphasis> 9072 + set sidebar_refresh_time = 60 9073 + 9074 + <emphasis role="comment"># Sort the mailboxes in the Sidebar using this method: 9075 + # count - total number of messages 9076 + # flagged - number of flagged messages 9077 + # new - number of new messages 9078 + # path - mailbox path 9079 + # unsorted - do not sort the mailboxes</emphasis> 9080 + set sidebar_sort_method = 'unsorted' 9081 + 9082 + <emphasis role="comment"># -------------------------------------------------------------------------- 9083 + # FUNCTIONS - shown with an example mapping 9084 + # -------------------------------------------------------------------------- 9085 + 9086 + # Move the highlight to the previous mailbox</emphasis> 9087 + bind index,pager \Cp sidebar-prev 9088 + 9089 + <emphasis role="comment"># Move the highlight to the next mailbox</emphasis> 9090 + bind index,pager \Cn sidebar-next 9091 + 9092 + <emphasis role="comment"># Open the highlighted mailbox</emphasis> 9093 + bind index,pager \Co sidebar-open 9094 + 9095 + <emphasis role="comment"># Move the highlight to the previous page 9096 + # This is useful if you have a LOT of mailboxes.</emphasis> 9097 + bind index,pager &lt;F3&gt; sidebar-page-up 9098 + 9099 + <emphasis role="comment"># Move the highlight to the next page 9100 + # This is useful if you have a LOT of mailboxes.</emphasis> 9101 + bind index,pager &lt;F4&gt; sidebar-page-down 9102 + 9103 + <emphasis role="comment"># Move the highlight to the previous mailbox containing new, or flagged, 9104 + # mail.</emphasis> 9105 + bind index,pager &lt;F5&gt; sidebar-prev-new 9106 + 9107 + <emphasis role="comment"># Move the highlight to the next mailbox containing new, or flagged, mail.</emphasis> 9108 + bind index,pager &lt;F6&gt; sidebar-next-new 9109 + 9110 + <emphasis role="comment"># Toggle the visibility of the Sidebar.</emphasis> 9111 + bind index,pager B sidebar-toggle-visible 9112 + 9113 + <emphasis role="comment"># -------------------------------------------------------------------------- 9114 + # COLORS - some unpleasant examples are given 9115 + # -------------------------------------------------------------------------- 9116 + # Note: All color operations are of the form: 9117 + # color OBJECT FOREGROUND BACKGROUND 9118 + 9119 + # Color of the current, open, mailbox 9120 + # Note: This is a general Mutt option which colors all selected items.</emphasis> 9121 + color indicator cyan black 9122 + 9123 + <emphasis role="comment"># Color of the highlighted, but not open, mailbox.</emphasis> 9124 + color sidebar_highlight black color8 9125 + 9126 + <emphasis role="comment"># Color of the divider separating the Sidebar from Mutt panels</emphasis> 9127 + color sidebar_divider color8 black 9128 + 9129 + <emphasis role="comment"># Color to give mailboxes containing flagged mail</emphasis> 9130 + color sidebar_flagged red black 9131 + 9132 + <emphasis role="comment"># Color to give mailboxes containing new mail</emphasis> 9133 + color sidebar_new green black 9134 + 9135 + <emphasis role="comment"># -------------------------------------------------------------------------- 9136 + 9137 + # vim: syntax=muttrc</emphasis> 9138 + </screen> 9139 + </sect2> 9140 + 9141 + <sect2 id="sidebar-see-also"> 9142 + <title>See Also</title> 9143 + 9144 + <itemizedlist> 9145 + <listitem><para><link linkend="regexp">Regular Expressions</link></para></listitem> 9146 + <listitem><para><link linkend="patterns">Patterns</link></para></listitem> 9147 + <listitem><para><link linkend="color">Color command</link></para></listitem> 9148 + <listitem><para><link linkend="notmuch">notmuch patch</link></para></listitem> 9149 + </itemizedlist> 9150 + </sect2> 9151 + 9152 + <sect2 id="sidebar-known-bugs"> 9153 + <title>Known Bugs</title> 9154 + Unsorted isn't 9155 + </sect2> 9156 + 9157 + <sect2 id="sidebar-credits"> 9158 + <title>Credits</title> 9159 + <itemizedlist> 9160 + <listitem><para>Justin Hibbits <email>jrh29@po.cwru.edu</email></para></listitem> 9161 + <listitem><para>Thomer M. Gil <email>mutt@thomer.com</email></para></listitem> 9162 + <listitem><para>David Sterba <email>dsterba@suse.cz</email></para></listitem> 9163 + <listitem><para>Evgeni Golov <email>evgeni@debian.org</email></para></listitem> 9164 + <listitem><para>Fabian Groffen <email>grobian@gentoo.org</email></para></listitem> 9165 + <listitem><para>Jason DeTiberus <email>jdetiber@redhat.com</email></para></listitem> 9166 + <listitem><para>Stefan Assmann <email>sassmann@kpanic.de</email></para></listitem> 9167 + <listitem><para>Steve Kemp <email>steve@steve.org.uk</email></para></listitem> 9168 + <listitem><para>Terry Chan <email>tchan@lunar-linux.org</email></para></listitem> 9169 + <listitem><para>Tyler Earnest <email>tylere@rne.st</email></para></listitem> 9170 + <listitem><para>Richard Russon <email>rich@flatcap.org</email></para></listitem> 9171 + </itemizedlist> 9172 + </sect2> 9173 + </sect1> 9174 + 8095 9175 </chapter> 8096 9176 8097 9177 <chapter id="security"> ··· 9246 10326 </cmdsynopsis> 9247 10327 </listitem> 9248 10328 10329 + <listitem> 10330 + <cmdsynopsis> 10331 + <command>sidebar_whitelist</command> 10332 + <arg choice="plain"> 10333 + <replaceable class="parameter">item</replaceable> 10334 + </arg> 10335 + <arg choice="plain"> 10336 + <replaceable class="parameter">command</replaceable> 10337 + </arg> 10338 + </cmdsynopsis> 10339 + </listitem> 9249 10340 <listitem> 9250 10341 <cmdsynopsis> 9251 10342 <command><link linkend="source">source</link></command>
+7
flags.c
··· 25 25 #include "sort.h" 26 26 #include "mx.h" 27 27 28 + #ifdef USE_SIDEBAR 29 + #include "sidebar.h" 30 + #endif 31 + 28 32 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) 29 33 { 30 34 int changed = h->changed; ··· 263 267 */ 264 268 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) 265 269 h->searched = 0; 270 + #ifdef USE_SIDEBAR 271 + sb_draw(); 272 + #endif 266 273 } 267 274 268 275 void mutt_tag_set_flag (int flag, int bf)
+21
functions.h
··· 168 168 { "decrypt-copy", OP_DECRYPT_COPY, NULL }, 169 169 { "decrypt-save", OP_DECRYPT_SAVE, NULL }, 170 170 171 + #ifdef USE_SIDEBAR 172 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 173 + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL }, 174 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 175 + { "sidebar-page-down", OP_SIDEBAR_PAGE_DOWN, NULL }, 176 + { "sidebar-page-up", OP_SIDEBAR_PAGE_UP, NULL }, 177 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 178 + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL }, 179 + { "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE, NULL }, 180 + #endif 171 181 172 182 { NULL, 0, NULL } 173 183 }; ··· 271 281 { "decrypt-save", OP_DECRYPT_SAVE, NULL }, 272 282 273 283 { "what-key", OP_WHAT_KEY, NULL }, 284 + 285 + #ifdef USE_SIDEBAR 286 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 287 + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL }, 288 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 289 + { "sidebar-page-down", OP_SIDEBAR_PAGE_DOWN, NULL }, 290 + { "sidebar-page-up", OP_SIDEBAR_PAGE_UP, NULL }, 291 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 292 + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL }, 293 + { "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE, NULL }, 294 + #endif 274 295 275 296 { NULL, 0, NULL } 276 297 };
+14
globals.h
··· 118 118 WHERE char *SendCharset; 119 119 WHERE char *Sendmail; 120 120 WHERE char *Shell; 121 + #ifdef USE_SIDEBAR 122 + WHERE char *SidebarDelimChars; 123 + WHERE char *SidebarDividerChar; 124 + WHERE char *SidebarFormat; 125 + WHERE char *SidebarIndentString; 126 + #endif 121 127 WHERE char *Signature; 122 128 WHERE char *SimpleSearch; 123 129 #if USE_SMTP ··· 213 219 WHERE short ScoreThresholdDelete; 214 220 WHERE short ScoreThresholdRead; 215 221 WHERE short ScoreThresholdFlag; 222 + 223 + /* This isn't excluded from the build because it's too entwined in the code. 224 + * For now. */ 225 + WHERE short SidebarWidth; 226 + #ifdef USE_SIDEBAR 227 + WHERE short SidebarRefreshTime; 228 + WHERE LIST *SidebarWhitelist INITVAL(0); 229 + #endif 216 230 217 231 #ifdef USE_IMAP 218 232 WHERE short ImapKeepalive;
+8
imap/command.c
··· 1016 1016 opened */ 1017 1017 status->uidnext = oldun; 1018 1018 1019 + #ifdef USE_SIDEBAR 1020 + /* Make the sidebar show the correct numbers */ 1021 + if (status->messages) { 1022 + inc->msg_count = status->messages; 1023 + inc->msg_unread = status->unseen; 1024 + } 1025 + #endif 1026 + 1019 1027 FREE (&value); 1020 1028 return; 1021 1029 }
+4
imap/imap.c
··· 1559 1559 1560 1560 imap_munge_mbox_name (idata, munged, sizeof (munged), name); 1561 1561 snprintf (command, sizeof (command), 1562 + #ifdef USE_SIDEBAR 1563 + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); 1564 + #else 1562 1565 "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); 1566 + #endif 1563 1567 1564 1568 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) 1565 1569 {
+3
init.c
··· 2175 2175 case DT_SORT_AUX: 2176 2176 map = SortAuxMethods; 2177 2177 break; 2178 + case DT_SORT_SIDEBAR: 2179 + map = SortSidebarMethods; 2180 + break; 2178 2181 default: 2179 2182 map = SortMethods; 2180 2183 break;
+158 -1
init.h
··· 42 42 #define DTYPE(x) ((x) & DT_MASK) 43 43 44 44 /* subtypes */ 45 - #define DT_SUBTYPE_MASK 0xf0 45 + #define DT_SUBTYPE_MASK 0xff0 46 46 #define DT_SORT_ALIAS 0x10 47 47 #define DT_SORT_BROWSER 0x20 48 48 #define DT_SORT_KEYS 0x40 49 49 #define DT_SORT_AUX 0x80 50 + #define DT_SORT_SIDEBAR 0x100 50 51 51 52 /* flags to parse_set() */ 52 53 #define MUTT_SET_INV (1<<0) /* default is to invert all vars */ ··· 2666 2667 ** Command to use when spawning a subshell. By default, the user's login 2667 2668 ** shell from \fC/etc/passwd\fP is used. 2668 2669 */ 2670 + #ifdef USE_SIDEBAR 2671 + { "sidebar_divider_char", DT_STR, R_BOTH, UL &SidebarDividerChar, UL "|" }, 2672 + /* 2673 + ** .pp 2674 + ** This specifies the characters to be drawn between the sidebar (when 2675 + ** visible) and the other Mutt panels. ASCII and Unicode line-drawing 2676 + ** characters are supported. 2677 + */ 2678 + { "sidebar_delim_chars", DT_STR, R_NONE, UL &SidebarDelimChars, UL "/." }, 2679 + /* 2680 + ** .pp 2681 + ** This contains the list of characters which you would like to treat 2682 + ** as folder separators for displaying paths in the sidebar. 2683 + ** .pp 2684 + ** Local mail is often arranged in directories: `dir1/dir2/mailbox'. 2685 + ** .ts 2686 + ** set sidebar_delim_chars='/' 2687 + ** .te 2688 + ** IMAP mailboxes are often named: `folder1.folder2.mailbox'. 2689 + ** .ts 2690 + ** set sidebar_delim_chars='.' 2691 + ** .te 2692 + ** .pp 2693 + ** \fBSee also:\fP $$sidebar_short_path, $$sidebar_folder_indent, $$sidebar_indent_string. 2694 + */ 2695 + { "sidebar_folder_indent", DT_BOOL, R_BOTH, OPTSIDEBARFOLDERINDENT, 0 }, 2696 + /* 2697 + ** .pp 2698 + ** Set this to indent mailboxes in the sidebar. 2699 + ** .pp 2700 + ** \fBSee also:\fP $$sidebar_short_path, $$sidebar_indent_string, $$sidebar_delim_chars. 2701 + */ 2702 + { "sidebar_format", DT_STR, R_NONE, UL &SidebarFormat, UL "%B%?F? [%F]?%* %?N?%N/?%S" }, 2703 + /* 2704 + ** .pp 2705 + ** This variable allows you to customize the sidebar display. This string is 2706 + ** similar to $$index_format, but has its own set of \fCprintf(3)\fP-like 2707 + ** sequences: 2708 + ** .dl 2709 + ** .dt %B .dd Name of the mailbox 2710 + ** .dt %S .dd * Size of mailbox (total number of messages) 2711 + ** .dt %N .dd * Number of New messages in the mailbox 2712 + ** .dt %F .dd * Number of Flagged messages in the mailbox 2713 + ** .dt %! .dd ``!'' : one flagged message; 2714 + ** ``!!'' : two flagged messages; 2715 + ** ``n!'' : n flagged messages (for n > 2). 2716 + ** Otherwise prints nothing. 2717 + ** .dt %d .dd * @ Number of deleted messages 2718 + ** .dt %L .dd * @ Number of messages after limiting 2719 + ** .dt %t .dd * @ Number of tagged messages 2720 + ** .dt %>X .dd right justify the rest of the string and pad with ``X'' 2721 + ** .dt %|X .dd pad to the end of the line with ``X'' 2722 + ** .dt %*X .dd soft-fill with character ``X'' as pad 2723 + ** .de 2724 + ** .pp 2725 + ** * = Can be optionally printed if nonzero 2726 + ** @ = Only applicable to the current folder 2727 + */ 2728 + { "sidebar_indent_string", DT_STR, R_BOTH, UL &SidebarIndentString, UL " " }, 2729 + /* 2730 + ** .pp 2731 + ** This specifies the string that is used to indent mailboxes in the sidebar. 2732 + ** It defaults to two spaces. 2733 + ** .pp 2734 + ** \fBSee also:\fP $$sidebar_short_path, $$sidebar_folder_indent, $$sidebar_delim_chars. 2735 + */ 2736 + { "sidebar_new_mail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, 0 }, 2737 + /* 2738 + ** .pp 2739 + ** When set, the sidebar will only display mailboxes containing new, or 2740 + ** flagged, mail. 2741 + ** .pp 2742 + ** \fBSee also:\fP $sidebar_whitelist. 2743 + */ 2744 + { "sidebar_next_new_wrap", DT_BOOL, R_BOTH, UL OPTSIDEBARNEXTNEWWRAP, 0 }, 2745 + /* 2746 + ** .pp 2747 + ** When set, the \fC<sidebar-next-new>\fP command will not stop and the end of 2748 + ** the list of mailboxes, but wrap around to the beginning. The 2749 + ** \fC<sidebar-prev-new>\fP command is similarly affected, wrapping around to 2750 + ** the end of the list. 2751 + */ 2752 + { "sidebar_refresh_time", DT_NUM, R_BOTH, UL &SidebarRefreshTime, 60 }, 2753 + /* 2754 + ** .pp 2755 + ** Set sidebar_refresh_time to the minimum number of seconds between refreshes. 2756 + ** This will reduced network traffic. 2757 + ** .pp 2758 + ** \fBNote:\fP Set to 0 to disable refreshing. 2759 + */ 2760 + { "sidebar_short_path", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 0 }, 2761 + /* 2762 + ** .pp 2763 + ** By default the sidebar will show the mailbox's path, relative to the 2764 + ** $$folder variable. Setting \fCsidebar_shortpath=yes\fP will shorten the 2765 + ** names relative to the previous name. Here's an example: 2766 + ** .dl 2767 + ** .dt \fBshortpath=no\fP .dd \fBshortpath=yes\fP .dd \fBshortpath=yes, folderindent=yes, indentstr=".."\fP 2768 + ** .dt \fCfruit\fP .dd \fCfruit\fP .dd \fCfruit\fP 2769 + ** .dt \fCfruit.apple\fP .dd \fCapple\fP .dd \fC..apple\fP 2770 + ** .dt \fCfruit.banana\fP .dd \fCbanana\fP .dd \fC..banana\fP 2771 + ** .dt \fCfruit.cherry\fP .dd \fCcherry\fP .dd \fC..cherry\fP 2772 + ** .de 2773 + ** .pp 2774 + ** \fBSee also:\fP $$sidebar_delim_chars, $$sidebar_folder_indent, $$sidebar_indent_string. 2775 + */ 2776 + { "sidebar_sort_method", DT_SORT|DT_SORT_SIDEBAR, R_NONE, UL &SidebarSortMethod, SORT_ORDER }, 2777 + /* 2778 + ** .pp 2779 + ** Specifies how to sort entries in the file browser. By default, the 2780 + ** entries are sorted alphabetically. Valid values: 2781 + ** .il 2782 + ** .dd alpha (alphabetically) 2783 + ** .dd count (all message count) 2784 + ** .dd date 2785 + ** .dd desc (description) 2786 + ** .dd new (new message count) 2787 + ** .dd size 2788 + ** .dd unsorted 2789 + ** .ie 2790 + ** .pp 2791 + ** You may optionally use the ``reverse-'' prefix to specify reverse sorting 2792 + ** order (example: ``\fCset sort_browser=reverse-date\fP''). 2793 + */ 2794 + { "sidebar_visible", DT_BOOL, R_BOTH|R_REFLOW, OPTSIDEBAR, 0 }, 2795 + /* 2796 + ** .pp 2797 + ** This specifies whether or not to show sidebar. The sidebar shows a list of 2798 + ** all your mailboxes. 2799 + ** .pp 2800 + ** \fBSee also:\fP $$sidebar_format, $$sidebar_width 2801 + */ 2802 + { "sidebar_width", DT_NUM, R_BOTH|R_REFLOW, UL &SidebarWidth, 30 }, 2803 + /* 2804 + ** .pp 2805 + ** This controls the width of the sidebar. It is measured in screen columns. 2806 + ** For example: sidebar_width=20 could display 20 ASCII characters, or 10 2807 + ** Chinese characters. 2808 + */ 2809 + #endif 2669 2810 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 }, 2670 2811 /* 2671 2812 ** .pp ··· 3653 3794 { NULL, 0 } 3654 3795 }; 3655 3796 3797 + const struct mapping_t SortSidebarMethods[] = { 3798 + { "alpha", SORT_PATH }, 3799 + { "count", SORT_COUNT }, 3800 + { "desc", SORT_DESC }, 3801 + { "flagged", SORT_FLAGGED }, 3802 + { "mailbox-order", SORT_ORDER }, 3803 + { "name", SORT_PATH }, 3804 + { "new", SORT_COUNT_NEW }, 3805 + { "path", SORT_PATH }, 3806 + { "unsorted", SORT_ORDER }, 3807 + { NULL, 0 } 3808 + }; 3809 + 3656 3810 3657 3811 /* functions used to parse commands in a rc file */ 3658 3812 ··· 3742 3896 { "send-hook", mutt_parse_hook, MUTT_SENDHOOK }, 3743 3897 { "send2-hook", mutt_parse_hook, MUTT_SEND2HOOK }, 3744 3898 { "set", parse_set, 0 }, 3899 + #ifdef USE_SIDEBAR 3900 + { "sidebar_whitelist",parse_list, UL &SidebarWhitelist }, 3901 + #endif 3745 3902 { "source", parse_source, 0 }, 3746 3903 { "spam", parse_spam_list, MUTT_SPAM }, 3747 3904 { "nospam", parse_spam_list, MUTT_NOSPAM },
+3
keymap.c
··· 457 457 } 458 458 #endif 459 459 460 + /* update sidebar stats */ 461 + mutt_buffy_check(0); 462 + 460 463 timeout (i * 1000); 461 464 tmp = mutt_getch(); 462 465 timeout (-1);
+3
mailbox.h
··· 27 27 #define MUTT_NEWFOLDER (1<<4) /* create a new folder - same as MUTT_APPEND, but uses 28 28 * safe_fopen() for mbox-style folders. 29 29 */ 30 + #ifdef USE_SIDEBAR 31 + #define MUTT_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ 32 + #endif 30 33 31 34 /* mx_open_new_message() */ 32 35 #define MUTT_ADD_FROM (1<<0) /* add a From_ line */
+25
main.c
··· 31 31 #include "url.h" 32 32 #include "mutt_crypt.h" 33 33 #include "mutt_idna.h" 34 + #ifdef USE_SIDEBAR 35 + #include "sidebar.h" 36 + #endif 34 37 35 38 #ifdef USE_SASL 36 39 #include "mutt_sasl.h" ··· 485 488 "-USE_HCACHE " 486 489 #endif 487 490 491 + #ifdef USE_SIDEBAR 492 + "+USE_SIDEBAR " 493 + #else 494 + "-USE_SIDEBAR " 495 + #endif 496 + 488 497 ); 489 498 490 499 #ifdef ISPELL ··· 558 567 559 568 int main (int argc, char **argv) 560 569 { 570 + #ifdef USE_SIDEBAR 571 + char folder[PATH_MAX] = ""; 572 + #else 561 573 char folder[_POSIX_PATH_MAX] = ""; 574 + #endif 562 575 char *subject = NULL; 563 576 char *includeFile = NULL; 564 577 char *draftFile = NULL; ··· 1189 1202 strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); 1190 1203 mutt_expand_path (folder, sizeof (folder)); 1191 1204 1205 + #ifdef USE_SIDEBAR 1206 + { 1207 + char tmpfolder[PATH_MAX] = ""; 1208 + strfcpy (tmpfolder, folder, sizeof (tmpfolder)); 1209 + if (!realpath (tmpfolder, folder)) 1210 + strfcpy (folder, tmpfolder, sizeof (tmpfolder)); 1211 + } 1212 + #endif 1213 + 1192 1214 mutt_str_replace (&CurrentFolder, folder); 1193 1215 mutt_str_replace (&LastFolder, folder); 1194 1216 ··· 1211 1233 if((Context = mx_open_mailbox (folder, ((flags & MUTT_RO) || option (OPTREADONLY)) ? MUTT_READONLY : 0, NULL)) 1212 1234 || !explicit_folder) 1213 1235 { 1236 + #ifdef USE_SIDEBAR 1237 + sb_set_open_buffy (folder); 1238 + #endif 1214 1239 mutt_index_menu (); 1215 1240 if (Context) 1216 1241 FREE (&Context);
+6
mbox.c
··· 100 100 mutt_perror (ctx->path); 101 101 return (-1); 102 102 } 103 + #ifdef USE_SIDEBAR 104 + ctx->atime = sb.st_atime; 105 + #endif 103 106 ctx->mtime = sb.st_mtime; 104 107 ctx->size = sb.st_size; 105 108 ··· 251 254 252 255 ctx->size = sb.st_size; 253 256 ctx->mtime = sb.st_mtime; 257 + #ifdef USE_SIDEBAR 258 + ctx->atime = sb.st_atime; 259 + #endif 254 260 255 261 #ifdef NFS_ATTRIBUTE_HACK 256 262 if (sb.st_mtime > sb.st_atime)
+6
menu.c
··· 24 24 #include "mutt_curses.h" 25 25 #include "mutt_menu.h" 26 26 #include "mbyte.h" 27 + #ifdef USE_SIDEBAR 28 + #include "sidebar.h" 29 + #endif 27 30 28 31 char* SearchBuffers[MENU_MAX]; 29 32 ··· 235 238 int do_color; 236 239 int attr; 237 240 241 + #ifdef USE_SIDEBAR 242 + sb_draw(); 243 + #endif 238 244 for (i = menu->top; i < menu->top + menu->pagelen; i++) 239 245 { 240 246 if (i < menu->max)
+43
mh.c
··· 298 298 mhs_free_sequences (&mhs); 299 299 } 300 300 301 + #ifdef USE_SIDEBAR 302 + /** 303 + * mh_buffy_update - Update messages counts for an mh mailbox 304 + * @mailbox: BUFFY representing a maildir mailbox 305 + * 306 + * Read through an mh mailbox and count messages. Save the number of new, 307 + * flagged messages and a timestamp for now. 308 + */ 309 + void 310 + mh_buffy_update (BUFFY *mailbox) 311 + { 312 + if (!mailbox) 313 + return; 314 + 315 + if (!option (OPTSIDEBAR)) 316 + return; 317 + 318 + struct mh_sequences mhs; 319 + memset (&mhs, 0, sizeof (mhs)); 320 + 321 + if (mh_read_sequences (&mhs, mailbox->path) < 0) 322 + return; 323 + 324 + mailbox->msg_count = 0; 325 + mailbox->msg_unread = 0; 326 + mailbox->msg_flagged = 0; 327 + 328 + int i; 329 + for (i = 0; i <= mhs.max; i++) { 330 + mailbox->msg_count++; 331 + } 332 + if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { 333 + mailbox->msg_unread++; 334 + } 335 + if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) { 336 + mailbox->msg_flagged++; 337 + } 338 + mhs_free_sequences (&mhs); 339 + mailbox->sb_last_checked = time (NULL); 340 + } 341 + 342 + #endif 343 + 301 344 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) 302 345 { 303 346 int fd;
+13
mutt.h
··· 428 428 OPTSAVEEMPTY, 429 429 OPTSAVENAME, 430 430 OPTSCORE, 431 + #ifdef USE_SIDEBAR 432 + OPTSIDEBAR, 433 + OPTSIDEBARFOLDERINDENT, 434 + OPTSIDEBARNEWMAILONLY, 435 + OPTSIDEBARNEXTNEWWRAP, 436 + OPTSIDEBARSHORTPATH, 437 + #endif 431 438 OPTSIGDASHES, 432 439 OPTSIGONTOP, 433 440 OPTSORTRE, ··· 893 900 { 894 901 char *path; 895 902 FILE *fp; 903 + #ifdef USE_SIDEBAR 904 + time_t atime; 905 + #endif 896 906 time_t mtime; 897 907 off_t size; 898 908 off_t vsize; ··· 927 937 unsigned int quiet : 1; /* inhibit status messages? */ 928 938 unsigned int collapsed : 1; /* are all threads collapsed? */ 929 939 unsigned int closing : 1; /* mailbox is being closed */ 940 + #ifdef USE_SIDEBAR 941 + unsigned int peekonly : 1; /* just taking a glance, revert atime */ 942 + #endif 930 943 931 944 /* driver hooks */ 932 945 void *data; /* driver specific data */
+8
mutt_curses.h
··· 123 123 MT_COLOR_UNDERLINE, 124 124 MT_COLOR_INDEX, 125 125 MT_COLOR_PROMPT, 126 + #ifdef USE_SIDEBAR 127 + MT_COLOR_DIVIDER, 128 + MT_COLOR_FLAGGED, 129 + MT_COLOR_HIGHLIGHT, 130 + MT_COLOR_NEW, 131 + MT_COLOR_SB_INDICATOR, 132 + MT_COLOR_SB_SPOOLFILE, 133 + #endif 126 134 MT_COLOR_MAX 127 135 }; 128 136
+3
mutt_menu.h
··· 35 35 #define REDRAW_FULL (1<<5) 36 36 #define REDRAW_BODY (1<<6) 37 37 #define REDRAW_SIGWINCH (1<<7) 38 + #ifdef USE_SIDEBAR 39 + #define REDRAW_SIDEBAR (1<<8) 40 + #endif 38 41 39 42 #define MUTT_MODEFMT "-- Mutt: %s" 40 43
+31
mx.c
··· 29 29 #include "copy.h" 30 30 #include "keymap.h" 31 31 #include "url.h" 32 + #ifdef USE_SIDEBAR 33 + #include "sidebar.h" 34 + #endif 32 35 33 36 #ifdef USE_IMAP 34 37 #include "imap.h" ··· 613 616 * MUTT_APPEND open mailbox for appending 614 617 * MUTT_READONLY open mailbox in read-only mode 615 618 * MUTT_QUIET only print error messages 619 + * MUTT_PEEK revert atime where applicable 616 620 * ctx if non-null, context struct to use 617 621 */ 618 622 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) ··· 635 639 ctx->quiet = 1; 636 640 if (flags & MUTT_READONLY) 637 641 ctx->readonly = 1; 642 + #ifdef USE_SIDEBAR 643 + if (flags & MUTT_PEEK) 644 + ctx->peekonly = 1; 645 + #endif 638 646 639 647 if (flags & (MUTT_APPEND|MUTT_NEWFOLDER)) 640 648 { ··· 708 716 if(!ctx) 709 717 return; 710 718 719 + #ifdef USE_SIDEBAR 720 + /* fix up the times so buffy won't get confused */ 721 + struct utimbuf ut; 722 + if (ctx->peekonly && ctx->path && (ctx->mtime > ctx->atime)) { 723 + ut.actime = ctx->atime; 724 + ut.modtime = ctx->mtime; 725 + utime (ctx->path, &ut); 726 + } 727 + #endif 728 + 711 729 /* never announce that a mailbox we've just left has new mail. #3290 712 730 * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ 731 + #ifdef USE_SIDEBAR 732 + if (!ctx->peekonly) 733 + #endif 713 734 mutt_buffy_setnotified(ctx->path); 714 735 715 736 if (ctx->mx_ops) ··· 722 743 mutt_clear_threads (ctx); 723 744 for (i = 0; i < ctx->msgcount; i++) 724 745 mutt_free_header (&ctx->hdrs[i]); 746 + #ifdef USE_SIDEBAR 747 + ctx->msgcount -= ctx->deleted; 748 + sb_set_buffystats (ctx); 749 + #endif 725 750 FREE (&ctx->hdrs); 726 751 FREE (&ctx->v2r); 727 752 FREE (&ctx->path); ··· 815 840 if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 816 841 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED))) 817 842 read_msgs++; 843 + #ifdef USE_SIDEBAR 844 + if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read) 845 + ctx->unread--; 846 + if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged) 847 + ctx->flagged--; 848 + #endif 818 849 } 819 850 820 851 if (read_msgs && quadoption (OPT_MOVE) != MUTT_NO)
+4
mx.h
··· 26 26 #define _MX_H 27 27 28 28 #include "mailbox.h" 29 + #include "buffy.h" 29 30 30 31 /* supported mailbox formats */ 31 32 enum ··· 52 53 void mbox_reset_atime (CONTEXT *, struct stat *); 53 54 54 55 int mh_sync_mailbox (CONTEXT *, int *); 56 + #ifdef USE_SIDEBAR 57 + void mh_buffy_update (BUFFY *mailbox); 58 + #endif 55 59 int mh_check_empty (const char *); 56 60 57 61 int maildir_check_empty (const char *);
+28 -1
pager.c
··· 29 29 #include "pager.h" 30 30 #include "attach.h" 31 31 #include "mbyte.h" 32 + #ifdef USE_SIDEBAR 33 + #include "sidebar.h" 34 + #endif 32 35 33 36 #include "mutt_crypt.h" 34 37 ··· 1668 1671 /* clear() doesn't optimize screen redraws */ 1669 1672 move (0, 0); 1670 1673 clrtobot (); 1674 + #ifdef USE_SIDEBAR 1675 + sb_draw(); 1676 + #endif 1671 1677 1672 1678 if (IsHeader (extra) && Context->vcount + 1 < PagerIndexLines) 1673 1679 indexlen = Context->vcount + 1; ··· 2537 2543 ch = 0; 2538 2544 } 2539 2545 2540 - if (option (OPTFORCEREDRAWPAGER)) 2546 + if (option (OPTFORCEREDRAWPAGER)) { 2541 2547 redraw = REDRAW_FULL; 2548 + #ifdef USE_SIDEBAR 2549 + sb_draw(); 2550 + #endif 2551 + } 2542 2552 unset_option (OPTFORCEREDRAWINDEX); 2543 2553 unset_option (OPTFORCEREDRAWPAGER); 2544 2554 break; ··· 2815 2825 case OP_WHAT_KEY: 2816 2826 mutt_what_key (); 2817 2827 break; 2828 + 2829 + #ifdef USE_SIDEBAR 2830 + case OP_SIDEBAR_NEXT: 2831 + case OP_SIDEBAR_NEXT_NEW: 2832 + case OP_SIDEBAR_PAGE_DOWN: 2833 + case OP_SIDEBAR_PAGE_UP: 2834 + case OP_SIDEBAR_PREV: 2835 + case OP_SIDEBAR_PREV_NEW: 2836 + sb_change_mailbox (ch); 2837 + break; 2838 + 2839 + case OP_SIDEBAR_TOGGLE_VISIBLE: 2840 + toggle_option (OPTSIDEBAR); 2841 + mutt_reflow_windows(); 2842 + redraw = REDRAW_FULL; 2843 + break; 2844 + #endif 2818 2845 2819 2846 default: 2820 2847 ch = -1;
+987
sidebar.c
··· 1 + /* Copyright (C) 2004 Justin Hibbits <jrh29@po.cwru.edu> 2 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> 3 + * Copyright (C) 2015-2016 Richard Russon <rich@flatcap.org> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 18 + */ 19 + 20 + #if HAVE_CONFIG_H 21 + # include "config.h" 22 + #endif 23 + 24 + #include "mutt.h" 25 + #include "buffy.h" 26 + #include "keymap.h" 27 + #include "mutt_curses.h" 28 + #include "mutt_menu.h" 29 + #include "sort.h" 30 + 31 + /* Previous values for some sidebar config */ 32 + static short PreviousSort; /* sidebar_sort_method */ 33 + static time_t LastRefresh; /* Time of last refresh */ 34 + 35 + /* Keep track of various BUFFYs */ 36 + static BUFFY *TopBuffy; /* First mailbox visible in sidebar */ 37 + static BUFFY *OpnBuffy; /* Current (open) mailbox */ 38 + static BUFFY *HilBuffy; /* Highlighted mailbox */ 39 + static BUFFY *BotBuffy; /* Last mailbox visible in sidebar */ 40 + static BUFFY *Outgoing; /* Last mailbox in the linked list */ 41 + 42 + /** 43 + * struct sidebar_entry - Info about folders in the sidebar 44 + * 45 + * Used in the mutt_FormatString callback 46 + */ 47 + struct sidebar_entry { 48 + char box[SHORT_STRING]; 49 + BUFFY *buffy; 50 + }; 51 + 52 + 53 + /** 54 + * find_next_new - Find the next folder that contains new mail 55 + * @wrap: Wrap around to the beginning if the end is reached 56 + * 57 + * Search down the list of mail folders for one containing new mail. 58 + * 59 + * Returns: 60 + * BUFFY*: Success 61 + * NULL: Failure 62 + */ 63 + static BUFFY * 64 + find_next_new (int wrap) 65 + { 66 + BUFFY *b = HilBuffy; 67 + if (!b) 68 + return NULL; 69 + 70 + do { 71 + b = b->next; 72 + if (!b && wrap) { 73 + b = Incoming; 74 + } 75 + if (!b || (b == HilBuffy)) { 76 + break; 77 + } 78 + if (b->msg_unread > 0) { 79 + return b; 80 + } 81 + } while (b); 82 + 83 + return NULL; 84 + } 85 + 86 + /** 87 + * find_prev_new - Find the previous folder that contains new mail 88 + * @wrap: Wrap around to the beginning if the end is reached 89 + * 90 + * Search up the list of mail folders for one containing new mail. 91 + * 92 + * Returns: 93 + * BUFFY*: Success 94 + * NULL: Failure 95 + */ 96 + static BUFFY * 97 + find_prev_new (int wrap) 98 + { 99 + BUFFY *b = HilBuffy; 100 + if (!b) 101 + return NULL; 102 + 103 + do { 104 + b = b->prev; 105 + if (!b && wrap) { 106 + b = Outgoing; 107 + } 108 + if (!b || (b == HilBuffy)) { 109 + break; 110 + } 111 + if (b->msg_unread > 0) { 112 + return b; 113 + } 114 + } while (b); 115 + 116 + return NULL; 117 + } 118 + 119 + /** 120 + * cb_format_str - Create the string to show in the sidebar 121 + * @dest: Buffer in which to save string 122 + * @destlen: Buffer length 123 + * @col: Starting column, UNUSED 124 + * @op: printf-like operator, e.g. 'B' 125 + * @src: printf-like format string 126 + * @prefix: Field formatting string, UNUSED 127 + * @ifstring: If condition is met, display this string 128 + * @elsestring: Otherwise, display this string 129 + * @data: Pointer to our sidebar_entry 130 + * @flags: Format flags, e.g. MUTT_FORMAT_OPTIONAL 131 + * 132 + * cb_format_str is a callback function for mutt_FormatString. It understands 133 + * five operators. '%B' : Mailbox name, '%F' : Number of flagged messages, 134 + * '%N' : Number of new messages, '%S' : Size (total number of messages), 135 + * '%!' : Icon denoting number of flagged messages. 136 + * 137 + * Returns: src (unchanged) 138 + */ 139 + static const char * 140 + cb_format_str (char *dest, size_t destlen, size_t col, int cols, char op, 141 + const char *src, const char *prefix, const char *ifstring, 142 + const char *elsestring, unsigned long data, format_flag flags) 143 + { 144 + struct sidebar_entry *sbe = (struct sidebar_entry *) data; 145 + unsigned int optional; 146 + char fmt[SHORT_STRING], buf[SHORT_STRING]; 147 + 148 + if (!sbe || !dest) 149 + return src; 150 + 151 + dest[0] = 0; /* Just in case there's nothing to do */ 152 + 153 + BUFFY *b = sbe->buffy; 154 + if (!b) 155 + return src; 156 + 157 + int c = Context && (mutt_strcmp (Context->path, b->path) == 0); 158 + 159 + optional = flags & MUTT_FORMAT_OPTIONAL; 160 + 161 + switch (op) { 162 + case 'B': 163 + mutt_format_s (dest, destlen, prefix, sbe->box); 164 + break; 165 + 166 + case 'd': 167 + if (!optional) { 168 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 169 + snprintf (dest, destlen, fmt, c ? Context->deleted : 0); 170 + } else if ((c && Context->deleted == 0) || !c) { 171 + optional = 0; 172 + } 173 + break; 174 + 175 + case 'F': 176 + if (!optional) { 177 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 178 + snprintf (dest, destlen, fmt, b->msg_flagged); 179 + } else if (b->msg_flagged == 0) { 180 + optional = 0; 181 + } 182 + break; 183 + 184 + case 'L': 185 + if (!optional) { 186 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 187 + snprintf (dest, destlen, fmt, c ? Context->vcount : b->msg_count); 188 + } else if ((c && Context->vcount == b->msg_count) || !c) { 189 + optional = 0; 190 + } 191 + break; 192 + 193 + case 'N': 194 + if (!optional) { 195 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 196 + snprintf (dest, destlen, fmt, b->msg_unread); 197 + } else if (b->msg_unread == 0) { 198 + optional = 0; 199 + } 200 + break; 201 + 202 + case 'S': 203 + if (!optional) { 204 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 205 + snprintf (dest, destlen, fmt, b->msg_count); 206 + } else if (b->msg_count == 0) { 207 + optional = 0; 208 + } 209 + break; 210 + 211 + case 't': 212 + if (!optional) { 213 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 214 + snprintf (dest, destlen, fmt, c ? Context->tagged : 0); 215 + } else if ((c && Context->tagged == 0) || !c) { 216 + optional = 0; 217 + } 218 + break; 219 + 220 + case '!': 221 + if (b->msg_flagged == 0) { 222 + mutt_format_s (dest, destlen, prefix, ""); 223 + } else if (b->msg_flagged == 1) { 224 + mutt_format_s (dest, destlen, prefix, "!"); 225 + } else if (b->msg_flagged == 2) { 226 + mutt_format_s (dest, destlen, prefix, "!!"); 227 + } else { 228 + snprintf (buf, sizeof (buf), "%d!", b->msg_flagged); 229 + mutt_format_s (dest, destlen, prefix, buf); 230 + } 231 + break; 232 + } 233 + 234 + if (optional) 235 + mutt_FormatString (dest, destlen, col, SidebarWidth, ifstring, cb_format_str, (unsigned long) sbe, flags); 236 + else if (flags & MUTT_FORMAT_OPTIONAL) 237 + mutt_FormatString (dest, destlen, col, SidebarWidth, elsestring, cb_format_str, (unsigned long) sbe, flags); 238 + 239 + /* We return the format string, unchanged */ 240 + return src; 241 + } 242 + 243 + /** 244 + * make_sidebar_entry - Turn mailbox data into a sidebar string 245 + * @buf: Buffer in which to save string 246 + * @buflen: Buffer length 247 + * @width: Desired width in screen cells 248 + * @box: Mailbox name 249 + * @b: Mailbox object 250 + * 251 + * Take all the relevant mailbox data and the desired screen width and then get 252 + * mutt_FormatString to do the actual work. mutt_FormatString will callback to 253 + * us using cb_format_str() for the sidebar specific formatting characters. 254 + */ 255 + static void 256 + make_sidebar_entry (char *buf, unsigned int buflen, int width, char *box, 257 + BUFFY *b) 258 + { 259 + struct sidebar_entry sbe; 260 + 261 + if (!buf || !box || !b) 262 + return; 263 + 264 + sbe.buffy = b; 265 + strncpy (sbe.box, box, sizeof (sbe.box) - 1); 266 + 267 + int box_len = strlen (box); 268 + sbe.box[box_len] = '\0'; 269 + 270 + mutt_FormatString (buf, buflen, 0, width, NONULL(SidebarFormat), cb_format_str, (unsigned long) &sbe, 0); 271 + 272 + /* Force string to be exactly the right width */ 273 + int w = mutt_strwidth (buf); 274 + int s = strlen (buf); 275 + if (w < width) { 276 + /* Pad with spaces */ 277 + memset (buf + s, ' ', width - w); 278 + buf[s + width - w] = 0; 279 + } else if (w > width) { 280 + /* Truncate to fit */ 281 + int len = mutt_wstr_trunc (buf, buflen, width, NULL); 282 + buf[len] = 0; 283 + } 284 + } 285 + 286 + /** 287 + * cb_qsort_buffy - qsort callback to sort BUFFYs 288 + * @a: First BUFFY to compare 289 + * @b: Second BUFFY to compare 290 + * 291 + * Compare the paths of two BUFFYs taking the locale into account. 292 + * 293 + * Returns: 294 + * -1: a precedes b 295 + * 0: a and b are identical 296 + * 1: b precedes a 297 + */ 298 + static int 299 + cb_qsort_buffy (const void *a, const void *b) 300 + { 301 + const BUFFY *b1 = *(const BUFFY **) a; 302 + const BUFFY *b2 = *(const BUFFY **) b; 303 + 304 + /* Special case -- move hidden BUFFYs to the end */ 305 + if (b1->is_hidden != b2->is_hidden) { 306 + if (b1->is_hidden) 307 + return 1; 308 + else 309 + return -1; 310 + } 311 + 312 + int result = 0; 313 + 314 + switch ((SidebarSortMethod & SORT_MASK)) { 315 + case SORT_COUNT: 316 + result = (b2->msg_count - b1->msg_count); 317 + break; 318 + case SORT_COUNT_NEW: 319 + result = (b2->msg_unread - b1->msg_unread); 320 + break; 321 + case SORT_FLAGGED: 322 + result = (b2->msg_flagged - b1->msg_flagged); 323 + break; 324 + case SORT_PATH: 325 + result = mutt_strcasecmp (b1->path, b2->path); 326 + break; 327 + } 328 + 329 + if (SidebarSortMethod & SORT_REVERSE) 330 + result = -result; 331 + 332 + return result; 333 + } 334 + 335 + /** 336 + * buffy_going - Prevent our pointers becoming invalid 337 + * @b: BUFFY about to be deleted 338 + * 339 + * If we receive a delete-notification for a BUFFY, we need to change any 340 + * pointers we have to reference a different BUFFY, or set them to NULL. 341 + * 342 + * We don't update the prev/next pointers, they'll be fixed on the next 343 + * call to prepare_sidebar(). 344 + * 345 + * Returns: 346 + * A valid alternative BUFFY, or NULL 347 + */ 348 + static BUFFY * 349 + buffy_going (const BUFFY *b) 350 + { 351 + if (!b) 352 + return NULL; 353 + 354 + if (b->prev) { 355 + b->prev->next = NULL; 356 + } 357 + 358 + if (b->next) { 359 + b->next->prev = NULL; 360 + return b->next; 361 + } 362 + 363 + return b->prev; 364 + } 365 + 366 + /** 367 + * update_buffy_visibility - Should a BUFFY be displayed in the sidebar 368 + * @arr: array of BUFFYs 369 + * @arr_len: number of BUFFYs in array 370 + * 371 + * For each BUFFY in the array, check whether we should display it. 372 + * This is determined by several criteria. If the BUFFY: 373 + * is the currently open mailbox 374 + * is the currently highlighted mailbox 375 + * has unread messages 376 + * has flagged messages 377 + * is whitelisted 378 + */ 379 + static void 380 + update_buffy_visibility (BUFFY **arr, int arr_len) 381 + { 382 + if (!arr) 383 + return; 384 + 385 + short new_only = option (OPTSIDEBARNEWMAILONLY); 386 + 387 + BUFFY *b; 388 + int i; 389 + for (i = 0; i < arr_len; i++) { 390 + b = arr[i]; 391 + 392 + b->is_hidden = 0; 393 + 394 + if (!new_only) 395 + continue; 396 + 397 + if ((b == OpnBuffy) || (b->msg_unread > 0) || 398 + (b == HilBuffy) || (b->msg_flagged > 0)) { 399 + continue; 400 + } 401 + 402 + if (Context && (strcmp (b->path, Context->path) == 0)) { 403 + /* Spool directory */ 404 + continue; 405 + } 406 + 407 + if (mutt_find_list (SidebarWhitelist, b->path)) { 408 + /* Explicitly asked to be visible */ 409 + continue; 410 + } 411 + 412 + b->is_hidden = 1; 413 + } 414 + } 415 + 416 + /** 417 + * sort_buffy_array - Sort an array of BUFFY pointers 418 + * @arr: array of BUFFYs 419 + * @arr_len: number of BUFFYs in array 420 + * 421 + * Sort an array of BUFFY pointers according to the current sort config 422 + * option "sidebar_sort_method". This calls qsort to do the work which calls our 423 + * callback function "cb_qsort_buffy". 424 + * 425 + * Once sorted, the prev/next links will be reconstructed. 426 + */ 427 + static void 428 + sort_buffy_array (BUFFY **arr, int arr_len) 429 + { 430 + if (!arr) 431 + return; 432 + 433 + /* These are the only sort methods we understand */ 434 + short ssm = (SidebarSortMethod & SORT_MASK); 435 + if ((ssm == SORT_COUNT) || 436 + (ssm == SORT_COUNT_NEW) || 437 + (ssm == SORT_DESC) || 438 + (ssm == SORT_FLAGGED) || 439 + (ssm == SORT_PATH)) { 440 + qsort (arr, arr_len, sizeof (*arr), cb_qsort_buffy); 441 + } 442 + 443 + int i; 444 + for (i = 0; i < (arr_len - 1); i++) { 445 + arr[i]->next = arr[i + 1]; 446 + } 447 + arr[arr_len - 1]->next = NULL; 448 + 449 + for (i = 1; i < arr_len; i++) { 450 + arr[i]->prev = arr[i - 1]; 451 + } 452 + arr[0]->prev = NULL; 453 + } 454 + 455 + /** 456 + * prepare_sidebar - Prepare the list of BUFFYs for the sidebar display 457 + * @page_size: The number of lines on a page 458 + * 459 + * Before painting the sidebar, we count the BUFFYs, determine which are 460 + * visible, sort them and set up our page pointers. 461 + * 462 + * This is a lot of work to do each refresh, but there are many things that 463 + * can change outside of the sidebar that we don't hear about. 464 + * 465 + * Returns: 466 + * 0: No, don't draw the sidebar 467 + * 1: Yes, draw the sidebar 468 + */ 469 + static int 470 + prepare_sidebar (int page_size) 471 + { 472 + BUFFY *b = Incoming; 473 + if (!b) 474 + return 0; 475 + 476 + int count = 0; 477 + for (; b; b = b->next) 478 + count++; 479 + 480 + BUFFY **arr = safe_malloc (count * sizeof (*arr)); 481 + if (!arr) 482 + return 0; 483 + 484 + int i = 0; 485 + for (b = Incoming; b; b = b->next, i++) { 486 + arr[i] = b; 487 + } 488 + 489 + update_buffy_visibility (arr, count); 490 + sort_buffy_array (arr, count); 491 + 492 + Incoming = arr[0]; 493 + 494 + int top_index = 0; 495 + int opn_index = -1; 496 + int hil_index = -1; 497 + int bot_index = -1; 498 + 499 + for (i = 0; i < count; i++) { 500 + if (OpnBuffy == arr[i]) 501 + opn_index = i; 502 + if (HilBuffy == arr[i]) 503 + hil_index = i; 504 + } 505 + 506 + if (!HilBuffy || (SidebarSortMethod != PreviousSort)) { 507 + if (OpnBuffy) { 508 + HilBuffy = OpnBuffy; 509 + hil_index = opn_index; 510 + } else { 511 + HilBuffy = arr[0]; 512 + hil_index = 0; 513 + } 514 + } 515 + if (TopBuffy) { 516 + top_index = (hil_index / page_size) * page_size; 517 + } else { 518 + top_index = hil_index; 519 + } 520 + TopBuffy = arr[top_index]; 521 + 522 + bot_index = top_index + page_size - 1; 523 + if (bot_index > (count - 1)) { 524 + bot_index = count - 1; 525 + } 526 + BotBuffy = arr[bot_index]; 527 + 528 + Outgoing = arr[count - 1]; 529 + 530 + PreviousSort = SidebarSortMethod; 531 + free (arr); 532 + return 1; 533 + } 534 + 535 + /** 536 + * draw_divider - Draw a line between the sidebar and the rest of mutt 537 + * @num_rows: Height of the Sidebar 538 + * @num_cols: Width of the Sidebar 539 + * 540 + * Draw a divider using characters from the config option "sidebar_divider_char". 541 + * This can be an ASCII or Unicode character. First we calculate this 542 + * characters' width in screen columns, then subtract that from the config 543 + * option "sidebar_width". 544 + * 545 + * Returns: 546 + * -1: Error: bad character, etc 547 + * 0: Error: 0 width character 548 + * n: Success: character occupies n screen columns 549 + */ 550 + static int 551 + draw_divider (int num_rows, int num_cols) 552 + { 553 + /* Calculate the width of the delimiter in screen cells */ 554 + int delim_len = mutt_strwidth (SidebarDividerChar); 555 + 556 + if (delim_len < 1) 557 + return delim_len; 558 + 559 + if (delim_len > num_cols) 560 + return 0; 561 + 562 + SETCOLOR(MT_COLOR_DIVIDER); 563 + 564 + int i; 565 + for (i = 0; i < num_rows; i++) { 566 + mutt_window_move (MuttSidebarWindow, i, SidebarWidth - delim_len); //RAR 0 for rhs 567 + addstr (NONULL(SidebarDividerChar)); 568 + } 569 + 570 + return delim_len; 571 + } 572 + 573 + /** 574 + * fill_empty_space - Wipe the remaining Sidebar space 575 + * @first_row: Window line to start (0-based) 576 + * @num_rows: Number of rows to fill 577 + * @width: Width of the Sidebar (minus the divider) 578 + * 579 + * Write spaces over the area the sidebar isn't using. 580 + */ 581 + static void 582 + fill_empty_space (int first_row, int num_rows, int width) 583 + { 584 + /* Fill the remaining rows with blank space */ 585 + SETCOLOR(MT_COLOR_NORMAL); 586 + 587 + int r; 588 + for (r = 0; r < num_rows; r++) { 589 + mutt_window_move (MuttSidebarWindow, first_row + r, 0); //RAR rhs 590 + int i; 591 + for (i = 0; i < width; i++) 592 + addch (' '); 593 + } 594 + } 595 + 596 + /** 597 + * draw_sidebar - Write out a list of mailboxes, on the left 598 + * @num_rows: Height of the Sidebar 599 + * @num_cols: Width of the Sidebar 600 + * @div_width: Width in screen characters taken by the divider 601 + * 602 + * Display a list of mailboxes in a panel on the left. What's displayed will 603 + * depend on our index markers: TopBuffy, OpnBuffy, HilBuffy, BotBuffy. 604 + * On the first run they'll be NULL, so we display the top of Mutt's list 605 + * (Incoming). 606 + * 607 + * TopBuffy - first visible mailbox 608 + * BotBuffy - last visible mailbox 609 + * OpnBuffy - mailbox shown in Mutt's Index Panel 610 + * HilBuffy - Unselected mailbox (the paging follows this) 611 + * 612 + * The entries are formatted using "sidebar_format" and may be abbreviated: 613 + * "sidebar_short_path", indented: "sidebar_folder_indent", 614 + * "sidebar_indent_string" and sorted: "sidebar_sort_method". Finally, they're 615 + * trimmed to fit the available space. 616 + */ 617 + static void 618 + draw_sidebar (int num_rows, int num_cols, int div_width) 619 + { 620 + BUFFY *b = TopBuffy; 621 + if (!b) 622 + return; 623 + 624 + int w = MIN(num_cols, (SidebarWidth - div_width)); 625 + int row = 0; 626 + for (b = TopBuffy; b && (row < num_rows); b = b->next) { 627 + if (b->is_hidden) { 628 + continue; 629 + } 630 + 631 + if (b == OpnBuffy) { 632 + if ((ColorDefs[MT_COLOR_SB_INDICATOR] != 0)) { 633 + SETCOLOR(MT_COLOR_SB_INDICATOR); 634 + } else { 635 + SETCOLOR(MT_COLOR_INDICATOR); 636 + } 637 + } else if (b == HilBuffy) { 638 + SETCOLOR(MT_COLOR_HIGHLIGHT); 639 + } else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) && 640 + (mutt_strcmp (b->path, Spoolfile) == 0)) { 641 + SETCOLOR(MT_COLOR_SB_SPOOLFILE); 642 + } else if (b->msg_unread > 0) { 643 + SETCOLOR(MT_COLOR_NEW); 644 + } else if (b->msg_flagged > 0) { 645 + SETCOLOR(MT_COLOR_FLAGGED); 646 + } else { 647 + SETCOLOR(MT_COLOR_NORMAL); 648 + } 649 + 650 + mutt_window_move (MuttSidebarWindow, row, 0); 651 + if (Context && Context->path && 652 + (!strcmp (b->path, Context->path)|| 653 + !strcmp (b->realpath, Context->path))) { 654 + b->msg_unread = Context->unread; 655 + b->msg_count = Context->msgcount; 656 + b->msg_flagged = Context->flagged; 657 + } 658 + 659 + /* compute length of Maildir without trailing separator */ 660 + size_t maildirlen = strlen (Maildir); 661 + if (SidebarDelimChars && strchr (SidebarDelimChars, Maildir[maildirlen - 1])) { 662 + maildirlen--; 663 + } 664 + 665 + /* check whether Maildir is a prefix of the current folder's path */ 666 + short maildir_is_prefix = 0; 667 + if ((strlen (b->path) > maildirlen) && (strncmp (Maildir, b->path, maildirlen) == 0)) { 668 + maildir_is_prefix = 1; 669 + } 670 + /* calculate depth of current folder and generate its display name with indented spaces */ 671 + int sidebar_folder_depth = 0; 672 + char *sidebar_folder_name; 673 + int i; 674 + if (option (OPTSIDEBARSHORTPATH)) { 675 + /* disregard a trailing separator, so strlen() - 2 */ 676 + sidebar_folder_name = b->path; 677 + for (i = strlen (sidebar_folder_name) - 2; i >= 0; i--) { 678 + if (SidebarDelimChars && 679 + strchr (SidebarDelimChars, sidebar_folder_name[i])) { 680 + sidebar_folder_name += (i + 1); 681 + break; 682 + } 683 + } 684 + } else { 685 + sidebar_folder_name = b->path + maildir_is_prefix * (maildirlen + 1); 686 + } 687 + if (maildir_is_prefix && option (OPTSIDEBARFOLDERINDENT)) { 688 + const char *tmp_folder_name; 689 + int lastsep = 0; 690 + tmp_folder_name = b->path + maildirlen + 1; 691 + int tmplen = (int) strlen (tmp_folder_name) - 1; 692 + for (i = 0; i < tmplen; i++) { 693 + if (SidebarDelimChars && strchr (SidebarDelimChars, tmp_folder_name[i])) { 694 + sidebar_folder_depth++; 695 + lastsep = i + 1; 696 + } 697 + } 698 + if (sidebar_folder_depth > 0) { 699 + if (option (OPTSIDEBARSHORTPATH)) { 700 + tmp_folder_name += lastsep; /* basename */ 701 + } 702 + sidebar_folder_name = malloc (strlen (tmp_folder_name) + sidebar_folder_depth*strlen (NONULL(SidebarIndentString)) + 1); 703 + sidebar_folder_name[0]=0; 704 + for (i=0; i < sidebar_folder_depth; i++) 705 + strncat (sidebar_folder_name, NONULL(SidebarIndentString), strlen (NONULL(SidebarIndentString))); 706 + strncat (sidebar_folder_name, tmp_folder_name, strlen (tmp_folder_name)); 707 + } 708 + } 709 + char str[SHORT_STRING]; 710 + make_sidebar_entry (str, sizeof (str), w, sidebar_folder_name, b); 711 + printw ("%s", str); 712 + if (sidebar_folder_depth > 0) 713 + free (sidebar_folder_name); 714 + row++; 715 + } 716 + 717 + fill_empty_space (row, num_rows - row, w); 718 + } 719 + 720 + 721 + /** 722 + * sb_draw - Completely redraw the sidebar 723 + * 724 + * Completely refresh the sidebar region. First draw the divider; then, for 725 + * each BUFFY, call make_sidebar_entry; finally blank out any remaining space. 726 + */ 727 + void 728 + sb_draw (void) 729 + { 730 + if (!option (OPTSIDEBAR)) 731 + return; 732 + 733 + int num_rows = MuttSidebarWindow->rows; 734 + int num_cols = MuttSidebarWindow->cols; 735 + 736 + int div_width = draw_divider (num_rows, num_cols); 737 + if (div_width < 0) 738 + return; 739 + 740 + if (!Incoming) { 741 + fill_empty_space (0, num_rows, SidebarWidth - div_width); 742 + return; 743 + } 744 + 745 + if (!prepare_sidebar (num_rows)) 746 + return; 747 + 748 + draw_sidebar (num_rows, num_cols, div_width); 749 + } 750 + 751 + /** 752 + * sb_should_refresh - Check if the sidebar is due to be refreshed 753 + * 754 + * The "sidebar_refresh_time" config option allows the user to limit the frequency 755 + * with which the sidebar is refreshed. 756 + * 757 + * Returns: 758 + * 1 Yes, refresh is due 759 + * 0 No, refresh happened recently 760 + */ 761 + int 762 + sb_should_refresh (void) 763 + { 764 + if (!option (OPTSIDEBAR)) 765 + return 0; 766 + 767 + if (SidebarRefreshTime == 0) 768 + return 0; 769 + 770 + time_t diff = (time (NULL) - LastRefresh); 771 + 772 + return (diff >= SidebarRefreshTime); 773 + } 774 + 775 + /** 776 + * sb_change_mailbox - Change the selected mailbox 777 + * @op: Operation code 778 + * 779 + * Change the selected mailbox, e.g. "Next mailbox", "Previous Mailbox 780 + * with new mail". The operations are listed OPS.SIDEBAR which is built 781 + * into an enum in keymap_defs.h. 782 + * 783 + * If the operation is successful, HilBuffy will be set to the new mailbox. 784 + * This function only *selects* the mailbox, doesn't *open* it. 785 + * 786 + * Allowed values are: OP_SIDEBAR_NEXT, OP_SIDEBAR_NEXT_NEW, 787 + * OP_SIDEBAR_PAGE_DOWN, OP_SIDEBAR_PAGE_UP, OP_SIDEBAR_PREV, 788 + * OP_SIDEBAR_PREV_NEW. 789 + */ 790 + void 791 + sb_change_mailbox (int op) 792 + { 793 + if (!option (OPTSIDEBAR)) 794 + return; 795 + 796 + BUFFY *b; 797 + if (!HilBuffy) /* It'll get reset on the next draw */ 798 + return; 799 + 800 + switch (op) { 801 + case OP_SIDEBAR_NEXT: 802 + if (!HilBuffy->next) 803 + return; 804 + if (HilBuffy->next->is_hidden) 805 + return; 806 + HilBuffy = HilBuffy->next; 807 + break; 808 + case OP_SIDEBAR_NEXT_NEW: 809 + b = find_next_new (option (OPTSIDEBARNEXTNEWWRAP)); 810 + if (!b) { 811 + return; 812 + } else { 813 + HilBuffy = b; 814 + } 815 + break; 816 + case OP_SIDEBAR_PAGE_DOWN: 817 + HilBuffy = BotBuffy; 818 + if (HilBuffy->next) { 819 + HilBuffy = HilBuffy->next; 820 + } 821 + break; 822 + case OP_SIDEBAR_PAGE_UP: 823 + HilBuffy = TopBuffy; 824 + if (HilBuffy != Incoming) { 825 + HilBuffy = HilBuffy->prev; 826 + } 827 + break; 828 + case OP_SIDEBAR_PREV: 829 + if (!HilBuffy->prev) 830 + return; 831 + if (HilBuffy->prev->is_hidden) /* Can't happen, we've sorted the hidden to the end */ 832 + return; 833 + HilBuffy = HilBuffy->prev; 834 + break; 835 + case OP_SIDEBAR_PREV_NEW: 836 + b = find_prev_new (option (OPTSIDEBARNEXTNEWWRAP)); 837 + if (!b) { 838 + return; 839 + } else { 840 + HilBuffy = b; 841 + } 842 + break; 843 + default: 844 + return; 845 + } 846 + sb_draw(); 847 + } 848 + 849 + /** 850 + * sb_set_buffystats - Update the BUFFY's message counts from the CONTEXT 851 + * @ctx: A mailbox CONTEXT 852 + * 853 + * Given a mailbox CONTEXT, find a matching mailbox BUFFY and copy the message 854 + * counts into it. 855 + */ 856 + void 857 + sb_set_buffystats (const CONTEXT *ctx) 858 + { 859 + /* Even if the sidebar's hidden, 860 + * we should take note of the new data. */ 861 + BUFFY *b = Incoming; 862 + if (!ctx || !b) 863 + return; 864 + 865 + for (; b; b = b->next) { 866 + if (!strcmp (b->path, ctx->path) || 867 + !strcmp (b->realpath, ctx->path)) { 868 + b->msg_unread = ctx->unread; 869 + b->msg_count = ctx->msgcount; 870 + b->msg_flagged = ctx->flagged; 871 + break; 872 + } 873 + } 874 + } 875 + 876 + /** 877 + * sb_get_highlight - Get the BUFFY that's highlighted in the sidebar 878 + * 879 + * Get the path of the mailbox that's highlighted in the sidebar. 880 + * 881 + * Returns: 882 + * Mailbox path 883 + */ 884 + const char * 885 + sb_get_highlight (void) 886 + { 887 + if (!option (OPTSIDEBAR)) 888 + return NULL; 889 + 890 + if (!HilBuffy) 891 + return NULL; 892 + 893 + return HilBuffy->path; 894 + } 895 + 896 + /** 897 + * sb_set_open_buffy - Set the OpnBuffy based on a mailbox path 898 + * @path: Mailbox path 899 + * 900 + * Search through the list of mailboxes. If a BUFFY has a matching path, set 901 + * OpnBuffy to it. 902 + */ 903 + BUFFY * 904 + sb_set_open_buffy (const char *path) 905 + { 906 + /* Even if the sidebar is hidden */ 907 + 908 + BUFFY *b = Incoming; 909 + 910 + if (!path || !b) 911 + return NULL; 912 + 913 + OpnBuffy = NULL; 914 + 915 + for (; b; b = b->next) { 916 + if (!strcmp (b->path, path) || 917 + !strcmp (b->realpath, path)) { 918 + OpnBuffy = b; 919 + HilBuffy = b; 920 + break; 921 + } 922 + } 923 + 924 + return OpnBuffy; 925 + } 926 + 927 + /** 928 + * sb_set_update_time - Note the time that the sidebar was updated 929 + * 930 + * Update the timestamp representing the last sidebar update. If the user 931 + * configures "sidebar_refresh_time", this will help to reduce traffic. 932 + */ 933 + void 934 + sb_set_update_time (void) 935 + { 936 + /* XXX - should this be public? */ 937 + 938 + LastRefresh = time (NULL); 939 + } 940 + 941 + /** 942 + * sb_notify_mailbox - The state of a BUFFY is about to change 943 + * 944 + * We receive a notification: 945 + * After a new BUFFY has been created 946 + * Before a BUFFY is deleted 947 + * 948 + * Before a deletion, check that our pointers won't be invalidated. 949 + */ 950 + void 951 + sb_notify_mailbox (BUFFY *b, int created) 952 + { 953 + if (!b) 954 + return; 955 + 956 + /* Any new/deleted mailboxes will cause a refresh. As long as 957 + * they're valid, our pointers will be updated in prepare_sidebar() */ 958 + 959 + if (created) { 960 + if (!TopBuffy) 961 + TopBuffy = b; 962 + if (!HilBuffy) 963 + HilBuffy = b; 964 + if (!BotBuffy) 965 + BotBuffy = b; 966 + if (!Outgoing) 967 + Outgoing = b; 968 + if (!OpnBuffy && Context) { 969 + /* This might happen if the user "unmailboxes *", then 970 + * "mailboxes" our current mailbox back again */ 971 + if (mutt_strcmp (b->path, Context->path) == 0) { 972 + OpnBuffy = b; 973 + } 974 + } 975 + } else { 976 + if (TopBuffy == b) 977 + TopBuffy = buffy_going (TopBuffy); 978 + if (OpnBuffy == b) 979 + OpnBuffy = buffy_going (OpnBuffy); 980 + if (HilBuffy == b) 981 + HilBuffy = buffy_going (HilBuffy); 982 + if (BotBuffy == b) 983 + BotBuffy = buffy_going (BotBuffy); 984 + if (Outgoing == b) 985 + Outgoing = buffy_going (Outgoing); 986 + } 987 + }
+36
sidebar.h
··· 1 + /* Copyright (C) 2004 Justin Hibbits <jrh29@po.cwru.edu> 2 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> 3 + * Copyright (C) 2015-2016 Richard Russon <rich@flatcap.org> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 18 + */ 19 + 20 + #ifndef SIDEBAR_H 21 + #define SIDEBAR_H 22 + 23 + #include "mutt.h" 24 + #include "buffy.h" 25 + 26 + void sb_change_mailbox (int op); 27 + void sb_draw (void); 28 + const char * sb_get_highlight (void); 29 + void sb_init (void); 30 + void sb_notify_mailbox (BUFFY *b, int created); 31 + void sb_set_buffystats (const CONTEXT *ctx); 32 + BUFFY * sb_set_open_buffy (const char *path); 33 + void sb_set_update_time (void); 34 + int sb_should_refresh (void); 35 + 36 + #endif /* SIDEBAR_H */
+7
sort.h
··· 31 31 #define SORT_KEYID 12 32 32 #define SORT_TRUST 13 33 33 #define SORT_SPAM 14 34 + #define SORT_COUNT 15 35 + #define SORT_COUNT_NEW 16 36 + #define SORT_DESC 17 37 + #define SORT_FLAGGED 18 38 + #define SORT_PATH 19 39 + 34 40 /* dgc: Sort & SortAux are shorts, so I'm bumping these bitflags up from 35 41 * bits 4 & 5 to bits 8 & 9 to make room for more sort keys in the future. */ 36 42 #define SORT_MASK 0xff ··· 50 56 WHERE short Sort INITVAL (SORT_DATE); 51 57 WHERE short SortAux INITVAL (SORT_DATE); /* auxiliary sorting method */ 52 58 WHERE short SortAlias INITVAL (SORT_ALIAS); 59 + WHERE short SidebarSortMethod INITVAL (SORT_ORDER); 53 60 54 61 /* FIXME: This one does not belong to here */ 55 62 WHERE short PgpSortKeys INITVAL (SORT_ADDRESS);