mutt stable branch with some hacks
0
fork

Configure Feed

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

Sidebar clean up: building and drawing logic.

Fix the autoconf/makefile.am changes to be consistent.

Create a global SidebarNeedsRedraw to indicate a redraw is needed,
instead of putting sb_draw() everywhere in the code.

Create a menu_redraw_sidebar() function and use the REDRAW_SIDEBAR
flag instead of piggy-backing it inside the index loop.

Fix curs_main.c and pager.c to be a bit cleaner by using the global and
REDRAW_SIDEBAR.

Start to clean up some of the buffy code, but this needs to refactored
and fixed.

+119 -129
+4 -10
Makefile.am
··· 56 56 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ 57 57 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ 58 58 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ 59 - smime.c smtp.c utf8.c wcwidth.c \ 59 + sidebar.c smime.c smtp.c utf8.c wcwidth.c \ 60 60 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h 61 61 62 62 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \ ··· 71 71 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ 72 72 README.SSL smime.h group.h \ 73 73 muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \ 74 - ChangeLog mkchangelog.sh mutt_idna.h \ 74 + ChangeLog mkchangelog.sh mutt_idna.h sidebar.h OPS.sidebar \ 75 75 snprintf.c regex.c crypt-gpgme.h hcachever.sh.in \ 76 76 txt2c.c txt2c.sh version.sh check_sec.sh 77 77 78 78 EXTRA_SCRIPTS = smime_keys 79 - 80 - if BUILD_SIDEBAR 81 - mutt_SOURCES += sidebar.c sidebar.h 82 - endif 83 - 84 - EXTRA_DIST += OPS.SIDEBAR 85 79 86 80 mutt_dotlock_SOURCES = mutt_dotlock.c 87 81 mutt_dotlock_LDADD = $(LIBOBJS) ··· 137 131 138 132 keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs 139 133 rm -f $@ 140 - $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.PGP \ 141 - $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \ 134 + $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP \ 135 + $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \ 142 136 > keymap_alldefs.h 143 137 144 138 reldate.h: $(srcdir)/ChangeLog
+49 -53
buffy.c
··· 409 409 static void 410 410 buffy_maildir_update_dir (BUFFY *mailbox, const char *dir) 411 411 { 412 - char path[_POSIX_PATH_MAX] = ""; 413 - DIR *dirp = NULL; 414 - struct dirent *de = NULL; 415 - char *p = NULL; 416 - int read; 412 + char path[_POSIX_PATH_MAX] = ""; 413 + DIR *dirp = NULL; 414 + struct dirent *de = NULL; 415 + char *p = NULL; 417 416 418 - snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir); 417 + snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir); 419 418 420 - dirp = opendir (path); 421 - if (!dirp) { 422 - mailbox->magic = 0; 423 - return; 424 - } 419 + dirp = opendir (path); 420 + if (!dirp) 421 + { 422 + mailbox->magic = 0; 423 + return; 424 + } 425 425 426 - while ((de = readdir (dirp)) != NULL) { 427 - if (*de->d_name == '.') 428 - continue; 426 + while ((de = readdir (dirp)) != NULL) 427 + { 428 + if (*de->d_name == '.') 429 + continue; 429 430 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 - } 431 + /* Matches maildir_parse_flags logic */ 432 + mailbox->msg_count++; 433 + p = strstr (de->d_name, ":2,"); 434 + if (p) 435 + { 436 + p += 3; 437 + if (strchr (p, 'T')) 438 + continue; 439 + if (!strchr (p, 'S')) 440 + mailbox->msg_unread++; 441 + if (strchr (p, 'F')) 442 + mailbox->msg_flagged++; 443 + } 444 + } 445 445 446 - closedir (dirp); 446 + closedir (dirp); 447 447 } 448 448 449 449 /** ··· 470 470 buffy_maildir_update_dir (mailbox, "cur"); 471 471 472 472 mailbox->sb_last_checked = time (NULL); 473 - 474 - /* make sure the updates are actually put on screen */ 475 - sb_draw(); 476 473 } 477 474 478 475 #endif ··· 525 522 void 526 523 buffy_mbox_update (BUFFY *mailbox, struct stat *sb) 527 524 { 528 - CONTEXT *ctx = NULL; 525 + CONTEXT *ctx = NULL; 529 526 530 - if (!option (OPTSIDEBAR)) 531 - return; 532 - if ((mailbox->sb_last_checked > sb->st_mtime) && (mailbox->msg_count != 0)) 533 - return; /* no check necessary */ 527 + if (!option (OPTSIDEBAR)) 528 + return; 529 + if ((mailbox->sb_last_checked > sb->st_mtime) && (mailbox->msg_count != 0)) 530 + return; /* no check necessary */ 534 531 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(); 532 + ctx = mx_open_mailbox (mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK, NULL); 533 + if (ctx) 534 + { 535 + mailbox->msg_count = ctx->msgcount; 536 + mailbox->msg_unread = ctx->unread; 537 + mailbox->msg_flagged = ctx->flagged; 538 + mailbox->sb_last_checked = time (NULL); 539 + mx_close_mailbox (ctx, 0); 540 + } 546 541 } 547 542 #endif 548 543 ··· 641 636 642 637 case MUTT_MH: 643 638 #ifdef USE_SIDEBAR 644 - if (sb_should_refresh()) { 639 + if (should_refresh) 645 640 mh_buffy_update (tmp); 646 - sb_set_update_time(); 647 - } 648 641 #endif 649 642 mh_buffy(tmp); 650 643 if (tmp->new) ··· 662 655 } 663 656 #ifdef USE_SIDEBAR 664 657 if (should_refresh) 665 - sb_set_update_time(); 658 + { 659 + SidebarNeedsRedraw = 1; 660 + sb_set_update_time(); 661 + } 666 662 #endif 667 663 668 664 BuffyDoneTime = BuffyTime;
+2 -3
configure.ac
··· 177 177 178 178 AC_ARG_ENABLE(sidebar, AC_HELP_STRING([--enable-sidebar], [Enable Sidebar support]), 179 179 [ if test x$enableval = xyes ; then 180 - AC_DEFINE(USE_SIDEBAR,1,[ Define if you want support for the sidebar. ]) 180 + AC_DEFINE(USE_SIDEBAR, 1, [Define if you want support for the sidebar.]) 181 181 OPS="$OPS \$(srcdir)/OPS.SIDEBAR" 182 - need_sidebar="yes" 182 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS sidebar.o" 183 183 fi 184 184 ]) 185 - AM_CONDITIONAL(BUILD_SIDEBAR, test x$need_sidebar = xyes) 186 185 187 186 AC_ARG_WITH(mixmaster, AS_HELP_STRING([--with-mixmaster@<:@=PATH@:>@],[Include Mixmaster support]), 188 187 [if test "$withval" != no
+26 -38
curs_main.c
··· 609 609 do_buffy_notify = 1; 610 610 } 611 611 612 - #ifdef USE_SIDEBAR 613 - if (option (OPTSIDEBAR)) 614 - menu->redraw |= REDRAW_SIDEBAR; 615 - #endif 616 - 617 612 if (op != -1) 618 613 mutt_curs_set (0); 619 614 620 615 if (menu->redraw & REDRAW_FULL) 621 616 { 622 617 menu_redraw_full (menu); 623 - #ifdef USE_SIDEBAR 624 - sb_draw(); 625 - #endif 626 618 mutt_show_error (); 627 619 } 628 - #ifdef USE_SIDEBAR 629 - else if (menu->redraw & REDRAW_SIDEBAR) { 630 - sb_draw(); 631 - menu->redraw &= ~REDRAW_SIDEBAR; 632 - } 633 - #endif 634 620 635 621 if (menu->menu == MENU_MAIN) 636 622 { 623 + #ifdef USE_SIDEBAR 624 + if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw) 625 + { 626 + sb_set_buffystats (Context); 627 + menu_redraw_sidebar (menu); 628 + } 629 + #endif 637 630 if (Context && Context->hdrs && !(menu->current >= Context->vcount)) 638 631 { 639 632 menu_check_recenter (menu); ··· 654 647 menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); 655 648 mutt_window_move (MuttStatusWindow, 0, 0); 656 649 SETCOLOR (MT_COLOR_STATUS); 657 - #ifdef USE_SIDEBAR 658 - sb_set_buffystats (Context); 659 - #endif 660 650 mutt_paddstr (MuttStatusWindow->cols, buf); 661 651 NORMAL_COLOR; 662 652 menu->redraw &= ~REDRAW_STATUS; ··· 1116 1106 break; 1117 1107 1118 1108 CHECK_MSGCOUNT; 1119 - #ifdef USE_SIDEBAR 1120 - CHECK_VISIBLE; 1121 - #endif 1122 1109 CHECK_READONLY; 1123 1110 { 1124 1111 int oldvcount = Context->vcount; ··· 1208 1195 break; 1209 1196 } 1210 1197 } 1198 + #ifdef USE_SIDEBAR 1199 + else if (op == OP_SIDEBAR_OPEN) 1200 + { 1201 + const char *path = sb_get_highlight(); 1202 + if (!path || !*path) 1203 + break; 1204 + strncpy (buf, path, sizeof (buf)); 1205 + } 1206 + #endif 1211 1207 else 1212 1208 { 1213 1209 mutt_buffy (buf, sizeof (buf)); 1214 1210 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 1223 - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 1224 - { 1225 - if (menu->menu == MENU_PAGER) 1226 - { 1227 - op = OP_DISPLAY_MESSAGE; 1228 - continue; 1229 - } 1230 - else 1231 - break; 1232 - } 1211 + if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 1212 + { 1213 + if (menu->menu == MENU_PAGER) 1214 + { 1215 + op = OP_DISPLAY_MESSAGE; 1216 + continue; 1217 + } 1218 + else 1219 + break; 1220 + } 1233 1221 if (!buf[0]) 1234 1222 { 1235 1223 mutt_window_clearline (MuttMessageWindow, 0);
+5 -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 - 32 28 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) 33 29 { 34 30 int changed = h->changed; ··· 259 255 } 260 256 261 257 if (update) 258 + { 262 259 mutt_set_header_color(ctx, h); 260 + #ifdef USE_SIDEBAR 261 + SidebarNeedsRedraw = 1; 262 + #endif 263 + } 263 264 264 265 /* if the message status has changed, we need to invalidate the cached 265 266 * search results so that any future search will match the current status ··· 267 268 */ 268 269 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) 269 270 h->searched = 0; 270 - #ifdef USE_SIDEBAR 271 - sb_draw(); 272 - #endif 273 271 } 274 272 275 273 void mutt_tag_set_flag (int flag, int bf)
+2 -3
globals.h
··· 220 220 WHERE short ScoreThresholdRead; 221 221 WHERE short ScoreThresholdFlag; 222 222 223 - /* This isn't excluded from the build because it's too entwined in the code. 224 - * For now. */ 223 + #ifdef USE_SIDEBAR 225 224 WHERE short SidebarWidth; 226 - #ifdef USE_SIDEBAR 227 225 WHERE short SidebarRefreshTime; 228 226 WHERE LIST *SidebarWhitelist INITVAL(0); 227 + WHERE int SidebarNeedsRedraw INITVAL (0); 229 228 #endif 230 229 231 230 #ifdef USE_IMAP
-3
keymap.c
··· 457 457 } 458 458 #endif 459 459 460 - /* update sidebar stats */ 461 - mutt_buffy_check(0); 462 - 463 460 timeout (i * 1000); 464 461 tmp = mutt_getch(); 465 462 timeout (-1);
+15 -3
menu.c
··· 217 217 mutt_show_error (); 218 218 219 219 menu->redraw = REDRAW_INDEX | REDRAW_STATUS; 220 + #ifdef USE_SIDEBAR 221 + menu->redraw |= REDRAW_SIDEBAR; 222 + #endif 220 223 } 221 224 222 225 void menu_redraw_status (MUTTMENU *menu) ··· 231 234 menu->redraw &= ~REDRAW_STATUS; 232 235 } 233 236 237 + #ifdef USE_SIDEBAR 238 + void menu_redraw_sidebar (MUTTMENU *menu) 239 + { 240 + SidebarNeedsRedraw = 0; 241 + sb_draw (); 242 + } 243 + #endif 244 + 234 245 void menu_redraw_index (MUTTMENU *menu) 235 246 { 236 247 char buf[LONG_STRING]; ··· 238 249 int do_color; 239 250 int attr; 240 251 241 - #ifdef USE_SIDEBAR 242 - sb_draw(); 243 - #endif 244 252 for (i = menu->top; i < menu->top + menu->pagelen; i++) 245 253 { 246 254 if (i < menu->max) ··· 843 851 844 852 if (menu->redraw & REDRAW_STATUS) 845 853 menu_redraw_status (menu); 854 + #ifdef USE_SIDEBAR 855 + if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw) 856 + menu_redraw_sidebar (menu); 857 + #endif 846 858 if (menu->redraw & REDRAW_INDEX) 847 859 menu_redraw_index (menu); 848 860 else if (menu->redraw & (REDRAW_MOTION | REDRAW_MOTION_RESYNCH))
+3
mutt_menu.h
··· 90 90 void mutt_menu_init (void); 91 91 void menu_jump (MUTTMENU *); 92 92 void menu_redraw_full (MUTTMENU *); 93 + #ifdef USE_SIDEBAR 94 + void menu_redraw_sidebar (MUTTMENU *); 95 + #endif 93 96 void menu_redraw_index (MUTTMENU *); 94 97 void menu_redraw_status (MUTTMENU *); 95 98 void menu_redraw_motion (MUTTMENU *);
+12 -8
pager.c
··· 1671 1671 /* clear() doesn't optimize screen redraws */ 1672 1672 move (0, 0); 1673 1673 clrtobot (); 1674 - #ifdef USE_SIDEBAR 1675 - sb_draw(); 1676 - #endif 1677 1674 1678 1675 if (IsHeader (extra) && Context->vcount + 1 < PagerIndexLines) 1679 1676 indexlen = Context->vcount + 1; ··· 1767 1764 } 1768 1765 1769 1766 redraw |= REDRAW_BODY | REDRAW_INDEX | REDRAW_STATUS; 1767 + #ifdef USE_SIDEBAR 1768 + redraw |= REDRAW_SIDEBAR; 1769 + #endif 1770 1770 mutt_show_error (); 1771 1771 } 1772 1772 ··· 1784 1784 break; 1785 1785 } 1786 1786 } 1787 + 1788 + #ifdef USE_SIDEBAR 1789 + if ((redraw & REDRAW_SIDEBAR) || SidebarNeedsRedraw) 1790 + { 1791 + SidebarNeedsRedraw = 0; 1792 + sb_draw (); 1793 + } 1794 + #endif 1787 1795 1788 1796 if ((redraw & REDRAW_BODY) || topline != oldtopline) 1789 1797 { ··· 2543 2551 ch = 0; 2544 2552 } 2545 2553 2546 - if (option (OPTFORCEREDRAWPAGER)) { 2554 + if (option (OPTFORCEREDRAWPAGER)) 2547 2555 redraw = REDRAW_FULL; 2548 - #ifdef USE_SIDEBAR 2549 - sb_draw(); 2550 - #endif 2551 - } 2552 2556 unset_option (OPTFORCEREDRAWINDEX); 2553 2557 unset_option (OPTFORCEREDRAWPAGER); 2554 2558 break;
+1 -1
sidebar.c
··· 843 843 default: 844 844 return; 845 845 } 846 - sb_draw(); 846 + SidebarNeedsRedraw = 1; 847 847 } 848 848 849 849 /**