summaryrefslogtreecommitdiffstats
path: root/buffy.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2016-06-04 11:32:03 -0700
committerKevin McCarthy <kevin@8t8.us>2016-06-04 11:32:03 -0700
commit086a5b8092544d68933d851af83c14c8dcbd834d (patch)
treeb364c239b68decdf274b0c4560f084ba1989aeca /buffy.c
parent389c74bb20b20ab31c14460962fbbb6bba82127d (diff)
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.
Diffstat (limited to 'buffy.c')
-rw-r--r--buffy.c104
1 files changed, 50 insertions, 54 deletions
diff --git a/buffy.c b/buffy.c
index 325a2d74..02e338b2 100644
--- a/buffy.c
+++ b/buffy.c
@@ -409,41 +409,41 @@ static int buffy_maildir_hasnew (BUFFY* mailbox)
static void
buffy_maildir_update_dir (BUFFY *mailbox, const char *dir)
{
- char path[_POSIX_PATH_MAX] = "";
- DIR *dirp = NULL;
- struct dirent *de = NULL;
- char *p = NULL;
- int read;
+ char path[_POSIX_PATH_MAX] = "";
+ DIR *dirp = NULL;
+ struct dirent *de = NULL;
+ char *p = NULL;
- snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir);
+ snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir);
- dirp = opendir (path);
- if (!dirp) {
- mailbox->magic = 0;
- return;
- }
+ dirp = opendir (path);
+ if (!dirp)
+ {
+ mailbox->magic = 0;
+ return;
+ }
- while ((de = readdir (dirp)) != NULL) {
- if (*de->d_name == '.')
- continue;
-
- /* Matches maildir_parse_flags logic */
- read = 0;
- mailbox->msg_count++;
- p = strstr (de->d_name, ":2,");
- if (p) {
- p += 3;
- if (strchr (p, 'S'))
- read = 1;
- if (strchr (p, 'F'))
- mailbox->msg_flagged++;
- }
- if (!read) {
- mailbox->msg_unread++;
- }
- }
+ while ((de = readdir (dirp)) != NULL)
+ {
+ if (*de->d_name == '.')
+ continue;
- closedir (dirp);
+ /* Matches maildir_parse_flags logic */
+ mailbox->msg_count++;
+ p = strstr (de->d_name, ":2,");
+ if (p)
+ {
+ p += 3;
+ if (strchr (p, 'T'))
+ continue;
+ if (!strchr (p, 'S'))
+ mailbox->msg_unread++;
+ if (strchr (p, 'F'))
+ mailbox->msg_flagged++;
+ }
+ }
+
+ closedir (dirp);
}
/**
@@ -470,9 +470,6 @@ buffy_maildir_update (BUFFY *mailbox)
buffy_maildir_update_dir (mailbox, "cur");
mailbox->sb_last_checked = time (NULL);
-
- /* make sure the updates are actually put on screen */
- sb_draw();
}
#endif
@@ -525,24 +522,22 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
void
buffy_mbox_update (BUFFY *mailbox, struct stat *sb)
{
- CONTEXT *ctx = NULL;
+ CONTEXT *ctx = NULL;
- if (!option (OPTSIDEBAR))
- return;
- if ((mailbox->sb_last_checked > sb->st_mtime) && (mailbox->msg_count != 0))
- return; /* no check necessary */
-
- ctx = mx_open_mailbox (mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK, NULL);
- if (ctx) {
- mailbox->msg_count = ctx->msgcount;
- mailbox->msg_unread = ctx->unread;
- mailbox->msg_flagged = ctx->flagged;
- mailbox->sb_last_checked = time (NULL);
- mx_close_mailbox (ctx, 0);
- }
+ if (!option (OPTSIDEBAR))
+ return;
+ if ((mailbox->sb_last_checked > sb->st_mtime) && (mailbox->msg_count != 0))
+ return; /* no check necessary */
- /* make sure the updates are actually put on screen */
- sb_draw();
+ ctx = mx_open_mailbox (mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK, NULL);
+ if (ctx)
+ {
+ mailbox->msg_count = ctx->msgcount;
+ mailbox->msg_unread = ctx->unread;
+ mailbox->msg_flagged = ctx->flagged;
+ mailbox->sb_last_checked = time (NULL);
+ mx_close_mailbox (ctx, 0);
+ }
}
#endif
@@ -641,10 +636,8 @@ int mutt_buffy_check (int force)
case MUTT_MH:
#ifdef USE_SIDEBAR
- if (sb_should_refresh()) {
+ if (should_refresh)
mh_buffy_update (tmp);
- sb_set_update_time();
- }
#endif
mh_buffy(tmp);
if (tmp->new)
@@ -662,7 +655,10 @@ int mutt_buffy_check (int force)
}
#ifdef USE_SIDEBAR
if (should_refresh)
- sb_set_update_time();
+ {
+ SidebarNeedsRedraw = 1;
+ sb_set_update_time();
+ }
#endif
BuffyDoneTime = BuffyTime;