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.
mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
- smime.c smtp.c utf8.c wcwidth.c \
+ sidebar.c smime.c smtp.c utf8.c wcwidth.c \
bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
README.SSL smime.h group.h \
muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
- ChangeLog mkchangelog.sh mutt_idna.h \
+ ChangeLog mkchangelog.sh mutt_idna.h sidebar.h OPS.sidebar \
snprintf.c regex.c crypt-gpgme.h hcachever.sh.in \
txt2c.c txt2c.sh version.sh check_sec.sh
EXTRA_SCRIPTS = smime_keys
-if BUILD_SIDEBAR
-mutt_SOURCES += sidebar.c sidebar.h
-endif
-
-EXTRA_DIST += OPS.SIDEBAR
-
mutt_dotlock_SOURCES = mutt_dotlock.c
mutt_dotlock_LDADD = $(LIBOBJS)
mutt_dotlock_DEPENDENCIES = $(LIBOBJS)
keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs
rm -f $@
- $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.PGP \
- $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \
+ $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP \
+ $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \
> keymap_alldefs.h
reldate.h: $(srcdir)/ChangeLog
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);
}
/**
buffy_maildir_update_dir (mailbox, "cur");
mailbox->sb_last_checked = time (NULL);
-
- /* make sure the updates are actually put on screen */
- sb_draw();
}
#endif
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
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)
}
#ifdef USE_SIDEBAR
if (should_refresh)
- sb_set_update_time();
+ {
+ SidebarNeedsRedraw = 1;
+ sb_set_update_time();
+ }
#endif
BuffyDoneTime = BuffyTime;
AC_ARG_ENABLE(sidebar, AC_HELP_STRING([--enable-sidebar], [Enable Sidebar support]),
[ if test x$enableval = xyes ; then
- AC_DEFINE(USE_SIDEBAR,1,[ Define if you want support for the sidebar. ])
+ AC_DEFINE(USE_SIDEBAR, 1, [Define if you want support for the sidebar.])
OPS="$OPS \$(srcdir)/OPS.SIDEBAR"
- need_sidebar="yes"
+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS sidebar.o"
fi
])
-AM_CONDITIONAL(BUILD_SIDEBAR, test x$need_sidebar = xyes)
AC_ARG_WITH(mixmaster, AS_HELP_STRING([--with-mixmaster@<:@=PATH@:>@],[Include Mixmaster support]),
[if test "$withval" != no
do_buffy_notify = 1;
}
-#ifdef USE_SIDEBAR
- if (option (OPTSIDEBAR))
- menu->redraw |= REDRAW_SIDEBAR;
-#endif
-
if (op != -1)
mutt_curs_set (0);
if (menu->redraw & REDRAW_FULL)
{
menu_redraw_full (menu);
-#ifdef USE_SIDEBAR
- sb_draw();
-#endif
mutt_show_error ();
}
-#ifdef USE_SIDEBAR
- else if (menu->redraw & REDRAW_SIDEBAR) {
- sb_draw();
- menu->redraw &= ~REDRAW_SIDEBAR;
- }
-#endif
if (menu->menu == MENU_MAIN)
{
+#ifdef USE_SIDEBAR
+ if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw)
+ {
+ sb_set_buffystats (Context);
+ menu_redraw_sidebar (menu);
+ }
+#endif
if (Context && Context->hdrs && !(menu->current >= Context->vcount))
{
menu_check_recenter (menu);
menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
mutt_window_move (MuttStatusWindow, 0, 0);
SETCOLOR (MT_COLOR_STATUS);
-#ifdef USE_SIDEBAR
- sb_set_buffystats (Context);
-#endif
mutt_paddstr (MuttStatusWindow->cols, buf);
NORMAL_COLOR;
menu->redraw &= ~REDRAW_STATUS;
break;
CHECK_MSGCOUNT;
-#ifdef USE_SIDEBAR
- CHECK_VISIBLE;
-#endif
CHECK_READONLY;
{
int oldvcount = Context->vcount;
break;
}
}
+#ifdef USE_SIDEBAR
+ else if (op == OP_SIDEBAR_OPEN)
+ {
+ const char *path = sb_get_highlight();
+ if (!path || !*path)
+ break;
+ strncpy (buf, path, sizeof (buf));
+ }
+#endif
else
{
mutt_buffy (buf, sizeof (buf));
-#ifdef USE_SIDEBAR
- if (op == OP_SIDEBAR_OPEN) {
- const char *path = sb_get_highlight();
- if (!path)
- break;
- strncpy (buf, path, sizeof (buf));
- } else
-#endif
- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
- {
- if (menu->menu == MENU_PAGER)
- {
- op = OP_DISPLAY_MESSAGE;
- continue;
- }
- else
- break;
- }
+ if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
+ {
+ if (menu->menu == MENU_PAGER)
+ {
+ op = OP_DISPLAY_MESSAGE;
+ continue;
+ }
+ else
+ break;
+ }
if (!buf[0])
{
mutt_window_clearline (MuttMessageWindow, 0);
#include "sort.h"
#include "mx.h"
-#ifdef USE_SIDEBAR
-#include "sidebar.h"
-#endif
-
void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
{
int changed = h->changed;
}
if (update)
+ {
mutt_set_header_color(ctx, h);
+#ifdef USE_SIDEBAR
+ SidebarNeedsRedraw = 1;
+#endif
+ }
/* if the message status has changed, we need to invalidate the cached
* search results so that any future search will match the current status
*/
if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
h->searched = 0;
-#ifdef USE_SIDEBAR
- sb_draw();
-#endif
}
void mutt_tag_set_flag (int flag, int bf)
WHERE short ScoreThresholdRead;
WHERE short ScoreThresholdFlag;
-/* This isn't excluded from the build because it's too entwined in the code.
- * For now. */
-WHERE short SidebarWidth;
#ifdef USE_SIDEBAR
+WHERE short SidebarWidth;
WHERE short SidebarRefreshTime;
WHERE LIST *SidebarWhitelist INITVAL(0);
+WHERE int SidebarNeedsRedraw INITVAL (0);
#endif
#ifdef USE_IMAP
}
#endif
- /* update sidebar stats */
- mutt_buffy_check(0);
-
timeout (i * 1000);
tmp = mutt_getch();
timeout (-1);
mutt_show_error ();
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+#ifdef USE_SIDEBAR
+ menu->redraw |= REDRAW_SIDEBAR;
+#endif
}
void menu_redraw_status (MUTTMENU *menu)
menu->redraw &= ~REDRAW_STATUS;
}
+#ifdef USE_SIDEBAR
+void menu_redraw_sidebar (MUTTMENU *menu)
+{
+ SidebarNeedsRedraw = 0;
+ sb_draw ();
+}
+#endif
+
void menu_redraw_index (MUTTMENU *menu)
{
char buf[LONG_STRING];
int do_color;
int attr;
-#ifdef USE_SIDEBAR
- sb_draw();
-#endif
for (i = menu->top; i < menu->top + menu->pagelen; i++)
{
if (i < menu->max)
if (menu->redraw & REDRAW_STATUS)
menu_redraw_status (menu);
+#ifdef USE_SIDEBAR
+ if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw)
+ menu_redraw_sidebar (menu);
+#endif
if (menu->redraw & REDRAW_INDEX)
menu_redraw_index (menu);
else if (menu->redraw & (REDRAW_MOTION | REDRAW_MOTION_RESYNCH))
void mutt_menu_init (void);
void menu_jump (MUTTMENU *);
void menu_redraw_full (MUTTMENU *);
+#ifdef USE_SIDEBAR
+void menu_redraw_sidebar (MUTTMENU *);
+#endif
void menu_redraw_index (MUTTMENU *);
void menu_redraw_status (MUTTMENU *);
void menu_redraw_motion (MUTTMENU *);
/* clear() doesn't optimize screen redraws */
move (0, 0);
clrtobot ();
-#ifdef USE_SIDEBAR
- sb_draw();
-#endif
if (IsHeader (extra) && Context->vcount + 1 < PagerIndexLines)
indexlen = Context->vcount + 1;
}
redraw |= REDRAW_BODY | REDRAW_INDEX | REDRAW_STATUS;
+#ifdef USE_SIDEBAR
+ redraw |= REDRAW_SIDEBAR;
+#endif
mutt_show_error ();
}
}
}
+#ifdef USE_SIDEBAR
+ if ((redraw & REDRAW_SIDEBAR) || SidebarNeedsRedraw)
+ {
+ SidebarNeedsRedraw = 0;
+ sb_draw ();
+ }
+#endif
+
if ((redraw & REDRAW_BODY) || topline != oldtopline)
{
do {
ch = 0;
}
- if (option (OPTFORCEREDRAWPAGER)) {
+ if (option (OPTFORCEREDRAWPAGER))
redraw = REDRAW_FULL;
-#ifdef USE_SIDEBAR
- sb_draw();
-#endif
- }
unset_option (OPTFORCEREDRAWINDEX);
unset_option (OPTFORCEREDRAWPAGER);
break;
default:
return;
}
- sb_draw();
+ SidebarNeedsRedraw = 1;
}
/**