changeset: 6660:8ad6090903db
user:      Richard Russon <[email protected]>
date:      Sat Jun 04 11:31:56 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/8ad6090903db

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.

changeset: 6661:08f9ba9efab9
user:      Kevin McCarthy <[email protected]>
date:      Sat Jun 04 11:32:03 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/08f9ba9efab9

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.

changeset: 6662:39639dc7e9e7
user:      Kevin McCarthy <[email protected]>
date:      Sat Jun 04 11:32:04 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/39639dc7e9e7

Fix sidebar check_sec.sh warnings.

Use safe_malloc, FREE, and the safe_strcat functions.

changeset: 6663:517d4f0debab
user:      Kevin McCarthy <[email protected]>
date:      Sat Jun 04 11:32:06 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/517d4f0debab

Re-indent and style sidebar.c.

changeset: 6664:cb23ed20d035
user:      Kevin McCarthy <[email protected]>
date:      Sat Jun 04 11:32:07 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/cb23ed20d035

Clean up the sidebar manual.

Remove the introduction section.  It's a nice effort, but reads more
like a tutorial than something that belongs in section 2.  Will
probably put in on the website instead.

Remove references to a "patch", neomutt, and the history.

Remove the sample muttrc from the manual.

Fix validation errors for the documentation.

changeset: 6665:b542812c262e
user:      Kevin McCarthy <[email protected]>
date:      Sat Jun 04 11:32:08 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/b542812c262e

Add "mutt_" prefix to global sidebar functions.

Also, remove unused sb_init declaration.

changeset: 6666:5d117fd810a9
user:      Kevin McCarthy <[email protected]>
date:      Sat Jun 04 11:32:09 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/5d117fd810a9

Various fixes to the sidebar logic.

Use strfcpy instead of strncpy.  The current logic could write past
the end of the buffer.

Don't mess with BUFFY next pointers during removal.  The
mutt_parse_mailboxes() is fine, but this is still not something that
should be done inside sidebar.c.

On removal, set next->prev since we can.

Fix unmailboxes logic:
  * only fix the prev pointers once.
  * if we unmailbox the open mailbox, set it to NULL.

Lastly, flag a redraw on mailboxes/unmailboxes.

changeset: 6667:8e342d73159b
user:      Kevin McCarthy <[email protected]>
date:      Sat Jun 04 11:32:12 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/8e342d73159b

Start to fix sidebar buffy modifications.

The extended buffy for mh had incorrect placement of the loop
brackets.  The counters weren't being incremented in the loop.

Fix extended buffy for maildir to count a maildir message as new if it
doesn't have the info delimeter.

Remove shortcircuits added to the basic buffy stating there is new
mail when (msg_unread > 0).  This is not necessarily true, depending
on $mail_check_recent.

Note: the extended buffy still needs more fixes, which will be done
when it is refactored into its own option.

diffs (truncated from 2847 to 950 lines):

diff -r 52f48b083cc0 -r 8e342d73159b Makefile.am
--- a/Makefile.am       Tue May 31 13:20:28 2016 -0700
+++ b/Makefile.am       Sat Jun 04 11:32:12 2016 -0700
@@ -56,7 +56,7 @@
        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 \
@@ -71,7 +71,7 @@
        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
 
@@ -129,9 +129,9 @@
 keymap_defs.h: $(OPS) $(srcdir)/gen_defs
        $(srcdir)/gen_defs $(OPS) > keymap_defs.h
 
-keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX 
$(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs
+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)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR 
$(srcdir)/OPS.PGP \
                $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \
                        > keymap_alldefs.h
 
diff -r 52f48b083cc0 -r 8e342d73159b OPS.SIDEBAR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/OPS.SIDEBAR       Sat Jun 04 11:32:12 2016 -0700
@@ -0,0 +1,8 @@
+OP_SIDEBAR_NEXT "Move the highlight to next mailbox"
+OP_SIDEBAR_NEXT_NEW "Move the highlight to next mailbox with new mail"
+OP_SIDEBAR_OPEN "Open highlighted mailbox"
+OP_SIDEBAR_PAGE_DOWN "Scroll the Sidebar down 1 page"
+OP_SIDEBAR_PAGE_UP "Scroll the Sidebar up 1 page"
+OP_SIDEBAR_PREV "Move the highlight to previous mailbox"
+OP_SIDEBAR_PREV_NEW "Move the highlight to previous mailbox with new mail"
+OP_SIDEBAR_TOGGLE_VISIBLE "Make the Sidebar (in)visible"
diff -r 52f48b083cc0 -r 8e342d73159b buffy.c
--- a/buffy.c   Tue May 31 13:20:28 2016 -0700
+++ b/buffy.c   Sat Jun 04 11:32:12 2016 -0700
@@ -27,6 +27,10 @@
 
 #include "mutt_curses.h"
 
+#ifdef USE_SIDEBAR
+#include "sidebar.h"
+#endif
+
 #ifdef USE_IMAP
 #include "imap.h"
 #endif
@@ -196,9 +200,17 @@
 static BUFFY *buffy_new (const char *path)
 {
   BUFFY* buffy;
+#ifdef USE_SIDEBAR
+  char rp[PATH_MAX] = "";
+  char *r = NULL;
+#endif
 
   buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
   strfcpy (buffy->path, path, sizeof (buffy->path));
+#ifdef USE_SIDEBAR
+  r = realpath (path, rp);
+  strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
+#endif
   buffy->next = NULL;
   buffy->magic = 0;
 
@@ -215,7 +227,10 @@
   BUFFY **tmp,*tmp1;
   char buf[_POSIX_PATH_MAX];
   struct stat sb;
-  char f1[PATH_MAX], f2[PATH_MAX];
+  char f1[PATH_MAX];
+#ifndef USE_SIDEBAR
+  char f2[PATH_MAX];
+#endif
   char *p, *q;
 
   while (MoreArgs (s))
@@ -228,6 +243,9 @@
       for (tmp = &Incoming; *tmp;)
       {
         tmp1=(*tmp)->next;
+#ifdef USE_SIDEBAR
+       mutt_sb_notify_mailbox (*tmp, 0);
+#endif
         buffy_free (tmp);
         *tmp=tmp1;
       }
@@ -243,8 +261,13 @@
     p = realpath (buf, f1);
     for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
     {
+#ifdef USE_SIDEBAR
+      q = (*tmp)->realpath;
+      if (mutt_strcmp (p ? p : buf, q) == 0)
+#else
       q = realpath ((*tmp)->path, f2);
       if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0)
+#endif
       {
        dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, 
(*tmp)->path));
        break;
@@ -256,14 +279,21 @@
       if(*tmp)
       {
         tmp1=(*tmp)->next;
+#ifdef USE_SIDEBAR
+       mutt_sb_notify_mailbox (*tmp, 0);
+#endif
         buffy_free (tmp);
         *tmp=tmp1;
       }
       continue;
     }
 
-    if (!*tmp)
+    if (!*tmp) {
       *tmp = buffy_new (buf);
+#ifdef USE_SIDEBAR
+      mutt_sb_notify_mailbox (*tmp, 1);
+#endif
+    }
 
     (*tmp)->new = 0;
     (*tmp)->notified = 1;
@@ -357,6 +387,88 @@
 
   return 0;
 }
+
+#ifdef USE_SIDEBAR
+/**
+ * buffy_maildir_update_dir - Update counts for one directory
+ * @mailbox: BUFFY representing a maildir mailbox
+ * @dir:     Which directory to search
+ *
+ * Look through one directory of a maildir mailbox.  The directory could
+ * be either "new" or "cur".
+ *
+ * Count how many new, or flagged, messages there are.
+ */
+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;
+
+  snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir);
+
+  dirp = opendir (path);
+  if (!dirp)
+  {
+    mailbox->magic = 0;
+    return;
+  }
+
+  while ((de = readdir (dirp)) != NULL)
+  {
+    if (*de->d_name == '.')
+      continue;
+
+    /* 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++;
+    }
+    else
+      mailbox->msg_unread++;
+  }
+
+  closedir (dirp);
+}
+
+/**
+ * buffy_maildir_update - Update messages counts for a maildir mailbox
+ * @mailbox: BUFFY representing a maildir mailbox
+ *
+ * Open a mailbox directories and update our record of how many new, or
+ * flagged, messages there are.
+ */
+void
+buffy_maildir_update (BUFFY *mailbox)
+{
+       if (!option (OPTSIDEBAR))
+               return;
+
+       mailbox->msg_count   = 0;
+       mailbox->msg_unread  = 0;
+       mailbox->msg_flagged = 0;
+
+       buffy_maildir_update_dir (mailbox, "new");
+       if (mailbox->msg_count) {
+               mailbox->new = 1;
+       }
+       buffy_maildir_update_dir (mailbox, "cur");
+
+       mailbox->sb_last_checked = time (NULL);
+}
+
+#endif
+
 /* returns 1 if mailbox has new mail */ 
 static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
 {
@@ -388,6 +500,38 @@
   return rc;
 }
 
+#ifdef USE_SIDEBAR
+/**
+ * buffy_mbox_update - Update messages counts for an mbox mailbox
+ * @mailbox: BUFFY representing an mbox mailbox
+ * @sb:      stat(2) infomation about the mailbox file
+ *
+ * Open a mbox file and update our record of how many new, or flagged,
+ * messages there are. If the mailbox hasn't changed since the last call,
+ * the function does nothing.
+ */
+void
+buffy_mbox_update (BUFFY *mailbox, struct stat *sb)
+{
+  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);
+  }
+}
+#endif
+
 int mutt_buffy_check (int force)
 {
   BUFFY *tmp;
@@ -428,6 +572,9 @@
     contex_sb.st_ino=0;
   }
   
+#ifdef USE_SIDEBAR
+  int should_refresh = mutt_sb_should_refresh();
+#endif
   for (tmp = Incoming; tmp; tmp = tmp->next)
   {
     if (tmp->magic != MUTT_IMAP)
@@ -461,16 +608,28 @@
       {
       case MUTT_MBOX:
       case MUTT_MMDF:
+#ifdef USE_SIDEBAR
+       if (should_refresh)
+         buffy_mbox_update (tmp, &sb);
+#endif
        if (buffy_mbox_hasnew (tmp, &sb) > 0)
          BuffyCount++;
        break;
 
       case MUTT_MAILDIR:
+#ifdef USE_SIDEBAR
+       if (should_refresh)
+         buffy_maildir_update (tmp);
+#endif
        if (buffy_maildir_hasnew (tmp) > 0)
          BuffyCount++;
        break;
 
       case MUTT_MH:
+#ifdef USE_SIDEBAR
+       if (should_refresh)
+         mh_buffy_update (tmp);
+#endif
        mh_buffy(tmp);
        if (tmp->new)
          BuffyCount++;
@@ -485,6 +644,13 @@
     else if (!tmp->notified)
       BuffyNotify++;
   }
+#ifdef USE_SIDEBAR
+  if (should_refresh)
+  {
+    SidebarNeedsRedraw = 1;
+    mutt_sb_set_update_time();
+  }
+#endif
 
   BuffyDoneTime = BuffyTime;
   return (BuffyCount);
diff -r 52f48b083cc0 -r 8e342d73159b buffy.h
--- a/buffy.h   Tue May 31 13:20:28 2016 -0700
+++ b/buffy.h   Sat Jun 04 11:32:12 2016 -0700
@@ -16,6 +16,9 @@
  *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
02110-1301, USA.
  */
 
+#ifndef _BUFFY_H
+#define _BUFFY_H
+
 /*parameter to mutt_parse_mailboxes*/
 #define MUTT_MAILBOXES   1
 #define MUTT_UNMAILBOXES 2 
@@ -23,13 +26,28 @@
 typedef struct buffy_t
 {
   char path[_POSIX_PATH_MAX];
+#ifdef USE_SIDEBAR
+  char realpath[_POSIX_PATH_MAX];
+#endif
   off_t size;
   struct buffy_t *next;
+#ifdef USE_SIDEBAR
+  struct buffy_t *prev;
+#endif
   short new;                   /* mailbox has new mail */
+#ifdef USE_SIDEBAR
+  int msg_count;               /* total number of messages */
+  int msg_unread;              /* number of unread messages */
+  int msg_flagged;             /* number of flagged messages */
+  short is_hidden;             /* is hidden from the sidebar */
+#endif
   short notified;              /* user has been notified */
   short magic;                 /* mailbox type */
   short newly_created;         /* mbox or mmdf just popped into existence */
   time_t last_visited;         /* time of last exit from this mailbox */
+#ifdef USE_SIDEBAR
+  time_t sb_last_checked;      /* time of last buffy check from sidebar */
+#endif
 }
 BUFFY;
 
@@ -49,3 +67,5 @@
 void mutt_buffy_setnotified (const char *path);
 
 void mh_buffy (BUFFY *);
+
+#endif /* _BUFFY_H */
diff -r 52f48b083cc0 -r 8e342d73159b color.c
--- a/color.c   Tue May 31 13:20:28 2016 -0700
+++ b/color.c   Sat Jun 04 11:32:12 2016 -0700
@@ -94,6 +94,14 @@
   { "underline",       MT_COLOR_UNDERLINE },
   { "index",           MT_COLOR_INDEX },
   { "prompt",          MT_COLOR_PROMPT },
+#ifdef USE_SIDEBAR
+  { "sidebar_divider", MT_COLOR_DIVIDER },
+  { "sidebar_flagged", MT_COLOR_FLAGGED },
+  { "sidebar_highlight",MT_COLOR_HIGHLIGHT },
+  { "sidebar_indicator",MT_COLOR_SB_INDICATOR },
+  { "sidebar_new",     MT_COLOR_NEW },
+  { "sidebar_spoolfile",MT_COLOR_SB_SPOOLFILE },
+#endif
   { NULL,              0 }
 };
 
@@ -146,6 +154,9 @@
   ColorDefs[MT_COLOR_INDICATOR] = A_REVERSE;
   ColorDefs[MT_COLOR_SEARCH] = A_REVERSE;
   ColorDefs[MT_COLOR_MARKERS] = A_REVERSE;
+#ifdef USE_SIDEBAR
+  ColorDefs[MT_COLOR_HIGHLIGHT] = A_UNDERLINE;
+#endif
   /* special meaning: toggle the relevant attribute */
   ColorDefs[MT_COLOR_BOLD] = 0;
   ColorDefs[MT_COLOR_UNDERLINE] = 0;
diff -r 52f48b083cc0 -r 8e342d73159b configure.ac
--- a/configure.ac      Tue May 31 13:20:28 2016 -0700
+++ b/configure.ac      Sat Jun 04 11:32:12 2016 -0700
@@ -175,6 +175,14 @@
        SMIMEAUX_TARGET="smime_keys"
 fi
 
+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.])
+               OPS="$OPS \$(srcdir)/OPS.SIDEBAR"
+                MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS sidebar.o"
+        fi
+])
+
 AC_ARG_WITH(mixmaster, AS_HELP_STRING([--with-mixmaster@<:@=PATH@:>@],[Include 
Mixmaster support]),
   [if test "$withval" != no
    then
diff -r 52f48b083cc0 -r 8e342d73159b contrib/sample.muttrc-sidebar
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/sample.muttrc-sidebar     Sat Jun 04 11:32:12 2016 -0700
@@ -0,0 +1,116 @@
+# This is a complete list of sidebar-related configuration.
+
+# --------------------------------------------------------------------------
+# VARIABLES - shown with their default values
+# --------------------------------------------------------------------------
+
+# Should the Sidebar be shown?
+set sidebar_visible = no
+
+# How wide should the Sidebar be in screen columns?
+# Note: Some characters, e.g. Chinese, take up two columns each.
+set sidebar_width = 20
+
+# Should the mailbox paths be abbreviated?
+set sidebar_short_path = no
+
+# When abbreviating mailbox path names, use any of these characters as path
+# separators.  Only the part after the last separators will be shown.
+# For file folders '/' is good.  For IMAP folders, often '.' is useful.
+set sidebar_delim_chars = '/.'
+
+# If the mailbox path is abbreviated, should it be indented?
+set sidebar_folder_indent = no
+
+# Indent mailbox paths with this string.
+set sidebar_indent_string = '  '
+
+# Make the Sidebar only display mailboxes that contain new, or flagged,
+# mail.
+set sidebar_new_mail_only = no
+
+# Any mailboxes that are whitelisted will always be visible, even if the
+# sidebar_new_mail_only option is enabled.
+sidebar_whitelist '/home/user/mailbox1'
+sidebar_whitelist '/home/user/mailbox2'
+
+# When searching for mailboxes containing new mail, should the search wrap
+# around when it reaches the end of the list?
+set sidebar_next_new_wrap = no
+
+# The character to use as the divider between the Sidebar and the other Mutt
+# panels.
+# Note: Only the first character of this string is used.
+set sidebar_divider_char = '|'
+
+# Display the Sidebar mailboxes using this format string.
+set sidebar_format = '%B%?F? [%F]?%* %?N?%N/?%S'
+
+# Sidebar will not refresh its list of mailboxes any more frequently than
+# this number of seconds.  This will help reduce disk/network traffic.
+set sidebar_refresh_time = 60
+
+# Sort the mailboxes in the Sidebar using this method:
+#       count    - total number of messages
+#       flagged  - number of flagged messages
+#       new      - number of new messages
+#       path     - mailbox path
+#       unsorted - do not sort the mailboxes
+set sidebar_sort_method = 'unsorted'
+
+# --------------------------------------------------------------------------
+# FUNCTIONS - shown with an example mapping
+# --------------------------------------------------------------------------
+
+# Move the highlight to the previous mailbox
+bind index,pager \Cp sidebar-prev
+
+# Move the highlight to the next mailbox
+bind index,pager \Cn sidebar-next
+
+# Open the highlighted mailbox
+bind index,pager \Co sidebar-open
+
+# Move the highlight to the previous page
+# This is useful if you have a LOT of mailboxes.
+bind index,pager <F3> sidebar-page-up
+
+# Move the highlight to the next page
+# This is useful if you have a LOT of mailboxes.
+bind index,pager <F4> sidebar-page-down
+
+# Move the highlight to the previous mailbox containing new, or flagged,
+# mail.
+bind index,pager <F5> sidebar-prev-new
+
+# Move the highlight to the next mailbox containing new, or flagged, mail.
+bind index,pager <F6> sidebar-next-new
+
+# Toggle the visibility of the Sidebar.
+bind index,pager B sidebar-toggle-visible
+
+# --------------------------------------------------------------------------
+# COLORS - some unpleasant examples are given
+# --------------------------------------------------------------------------
+# Note: All color operations are of the form:
+#       color OBJECT FOREGROUND BACKGROUND
+
+# Color of the current, open, mailbox
+# Note: This is a general Mutt option which colors all selected items.
+color indicator cyan black
+
+# Color of the highlighted, but not open, mailbox.
+color sidebar_highlight black color8
+
+# Color of the divider separating the Sidebar from Mutt panels
+color sidebar_divider color8 black
+
+# Color to give mailboxes containing flagged mail
+color sidebar_flagged red black
+
+# Color to give mailboxes containing new mail
+color sidebar_new green black
+
+# --------------------------------------------------------------------------
+
+# vim: syntax=muttrc
diff -r 52f48b083cc0 -r 8e342d73159b contrib/sample.vimrc-sidebar
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/sample.vimrc-sidebar      Sat Jun 04 11:32:12 2016 -0700
@@ -0,0 +1,35 @@
+" Vim syntax file for the mutt sidebar patch
+
+syntax keyword muttrcVarBool    skipwhite contained sidebar_folder_indent 
nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr
+syntax keyword muttrcVarBool    skipwhite contained sidebar_new_mail_only 
nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr
+syntax keyword muttrcVarBool    skipwhite contained sidebar_next_new_wrap 
nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr
+syntax keyword muttrcVarBool    skipwhite contained sidebar_short_path    
nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr
+syntax keyword muttrcVarBool    skipwhite contained sidebar_visible       
nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr
+
+syntax keyword muttrcVarNum     skipwhite contained sidebar_refresh_time  
nextgroup=muttrcSetNumAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr
+syntax keyword muttrcVarNum     skipwhite contained sidebar_width         
nextgroup=muttrcSetNumAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr
+
+syntax keyword muttrcVarStr     contained skipwhite sidebar_divider_char  
nextgroup=muttrcVarEqualsIdxFmt
+syntax keyword muttrcVarStr     contained skipwhite sidebar_delim_chars   
nextgroup=muttrcVarEqualsIdxFmt
+syntax keyword muttrcVarStr     contained skipwhite sidebar_format        
nextgroup=muttrcVarEqualsIdxFmt
+syntax keyword muttrcVarStr     contained skipwhite sidebar_indent_string 
nextgroup=muttrcVarEqualsIdxFmt
+syntax keyword muttrcVarStr     contained skipwhite sidebar_sort_method   
nextgroup=muttrcVarEqualsIdxFmt
+
+syntax keyword muttrcCommand    sidebar_whitelist
+
+syntax match muttrcFunction     contained "\<sidebar-next\>"
+syntax match muttrcFunction     contained "\<sidebar-next-new\>"
+syntax match muttrcFunction     contained "\<sidebar-open\>"
+syntax match muttrcFunction     contained "\<sidebar-page-down\>"
+syntax match muttrcFunction     contained "\<sidebar-page-up\>"
+syntax match muttrcFunction     contained "\<sidebar-prev\>"
+syntax match muttrcFunction     contained "\<sidebar-prev-new\>"
+syntax match muttrcFunction     contained "\<sidebar-toggle-visible\>"
+
+syntax keyword muttrcColorField contained sidebar_divider
+syntax keyword muttrcColorField contained sidebar_flagged
+syntax keyword muttrcColorField contained sidebar_highlight
+syntax keyword muttrcColorField contained sidebar_indicator
+syntax keyword muttrcColorField contained sidebar_new
+
+" vim: syntax=vim
diff -r 52f48b083cc0 -r 8e342d73159b curs_main.c
--- a/curs_main.c       Tue May 31 13:20:28 2016 -0700
+++ b/curs_main.c       Sat Jun 04 11:32:12 2016 -0700
@@ -26,8 +26,13 @@
 #include "mailbox.h"
 #include "mapping.h"
 #include "sort.h"
+#include "buffy.h"
 #include "mx.h"
 
+#ifdef USE_SIDEBAR
+#include "sidebar.h"
+#endif
+
 #ifdef USE_POP
 #include "pop.h"
 #endif
@@ -593,8 +598,12 @@
        menu->redraw |= REDRAW_STATUS;
      if (do_buffy_notify)
      {
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
-       beep ();
+       if (mutt_buffy_notify())
+       {
+         menu->redraw |= REDRAW_STATUS;
+         if (option (OPTBEEPNEW))
+           beep();
+       }
      }
      else
        do_buffy_notify = 1;
@@ -611,6 +620,13 @@
 
     if (menu->menu == MENU_MAIN)
     {
+#ifdef USE_SIDEBAR
+      if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw)
+      {
+        mutt_sb_set_buffystats (Context);
+        menu_redraw_sidebar (menu);
+      }
+#endif
       if (Context && Context->hdrs && !(menu->current >= Context->vcount))
       {
        menu_check_recenter (menu);
@@ -1149,6 +1165,9 @@
          menu->redraw = REDRAW_FULL;
        break;
 
+#ifdef USE_SIDEBAR
+      case OP_SIDEBAR_OPEN:
+#endif
       case OP_MAIN_CHANGE_FOLDER:
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
 
@@ -1176,20 +1195,29 @@
            break;
          }
        }
+#ifdef USE_SIDEBAR
+        else if (op == OP_SIDEBAR_OPEN)
+        {
+          const char *path = mutt_sb_get_highlight();
+          if (!path || !*path)
+            break;
+          strncpy (buf, path, sizeof (buf));
+        }
+#endif
        else
        {
          mutt_buffy (buf, sizeof (buf));
 
-         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);
@@ -1198,6 +1226,9 @@
        }
 
        mutt_expand_path (buf, sizeof (buf));
+#ifdef USE_SIDEBAR
+       mutt_sb_set_open_buffy (buf);
+#endif
        if (mx_get_magic (buf) <= 0)
        {
          mutt_error (_("%s is not a mailbox."), buf);
@@ -2309,6 +2340,22 @@
        mutt_what_key();
        break;
 
+#ifdef USE_SIDEBAR
+      case OP_SIDEBAR_NEXT:
+      case OP_SIDEBAR_NEXT_NEW:
+      case OP_SIDEBAR_PAGE_DOWN:
+      case OP_SIDEBAR_PAGE_UP:
+      case OP_SIDEBAR_PREV:
+      case OP_SIDEBAR_PREV_NEW:
+        mutt_sb_change_mailbox (op);
+        break;
+
+      case OP_SIDEBAR_TOGGLE_VISIBLE:
+       toggle_option (OPTSIDEBAR);
+        mutt_reflow_windows();
+       menu->redraw = REDRAW_FULL;
+       break;
+#endif
       default:
        if (menu->menu == MENU_MAIN)
          km_error_key (MENU_MAIN);
diff -r 52f48b083cc0 -r 8e342d73159b doc/manual.xml.head
--- a/doc/manual.xml.head       Tue May 31 13:20:28 2016 -0700
+++ b/doc/manual.xml.head       Sat Jun 04 11:32:12 2016 -0700
@@ -405,6 +405,15 @@
 
 </sect2>
 
+<sect2 id="intro-sidebar">
+  <title>Sidebar</title>
+  <para>
+    The Sidebar shows a list of all your mailboxes.  The list can be
+    turned on and off, it can be themed and the list style can be
+    configured.
+  </para>
+</sect2>
+
 <sect2 id="intro-help">
 <title>Help</title>
 
@@ -8092,6 +8101,293 @@
 
 </sect1>
 
+<sect1 id="sidebar">
+  <title>Sidebar</title>
+  <subtitle>Overview of mailboxes</subtitle>
+
+  <sect2 id="sidebar-intro">
+    <title>Introduction</title>
+
+    <para>
+      The Sidebar shows a list of all your mailboxes.  The list can be
+      turned on and off, it can be themed and the list style can be
+      configured.
+    </para>
+  </sect2>
+
+  <sect2 id="sidebar-variables">
+    <title>Variables</title>
+
+    <table id="table-sidebar-variables">
+      <title>Sidebar Variables</title>
+      <tgroup cols="3">
+       <thead>
+         <row>
+           <entry>Name</entry>
+           <entry>Type</entry>
+           <entry>Default</entry>
+         </row>
+       </thead>
+       <tbody>
+         <row>
+           <entry><literal>sidebar_delim_chars</literal></entry>
+           <entry>string</entry>
+           <entry><literal>/.</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_divider_char</literal></entry>
+           <entry>string</entry>
+           <entry><literal>|</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_folder_indent</literal></entry>
+           <entry>boolean</entry>
+           <entry><literal>no</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_format</literal></entry>
+           <entry>string</entry>
+           <entry><literal>%B%?F? [%F]?%* %?N?%N/?%S</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_indent_string</literal></entry>
+           <entry>string</entry>
+           <entry><literal>&nbsp;&nbsp;</literal> (two spaces)</entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_new_mail_only</literal></entry>
+           <entry>boolean</entry>
+           <entry><literal>no</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_next_new_wrap</literal></entry>
+           <entry>boolean</entry>
+           <entry><literal>no</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_refresh_time</literal></entry>
+           <entry>number</entry>
+           <entry><literal>60</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_short_path</literal></entry>
+           <entry>boolean</entry>
+           <entry><literal>no</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_sort_method</literal></entry>
+           <entry>enum</entry>
+           <entry><literal>SORT_ORDER</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_visible</literal></entry>
+           <entry>boolean</entry>
+           <entry><literal>no</literal></entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_whitelist</literal></entry>
+           <entry>list</entry>
+           <entry>(empty)</entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_width</literal></entry>
+           <entry>number</entry>
+           <entry><literal>20</literal></entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+  </sect2>
+
+  <sect2 id="sidebar-functions">
+    <title>Functions</title>
+
+    <para>
+      Sidebar adds the following functions to Mutt.
+      By default, none of them are bound to keys.
+    </para>
+
+    <table id="table-sidebar-functions">
+      <title>Sidebar Functions</title>
+      <tgroup cols="3">
+       <thead>
+         <row>
+           <entry>Menus</entry>
+           <entry>Function</entry>
+           <entry>Description</entry>
+         </row>
+       </thead>
+       <tbody>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-next&gt;</literal></entry>
+           <entry>Move the highlight to next mailbox</entry>
+         </row>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-next-new&gt;</literal></entry>
+           <entry>Move the highlight to next mailbox with new mail</entry>
+         </row>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-open&gt;</literal></entry>
+           <entry>Open highlighted mailbox</entry>
+         </row>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-page-down&gt;</literal></entry>
+           <entry>Scroll the Sidebar down 1 page</entry>
+         </row>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-page-up&gt;</literal></entry>
+           <entry>Scroll the Sidebar up 1 page</entry>
+         </row>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-prev&gt;</literal></entry>
+           <entry>Move the highlight to previous mailbox</entry>
+         </row>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-prev-new&gt;</literal></entry>
+           <entry>Move the highlight to previous mailbox with new mail</entry>
+         </row>
+         <row>
+           <entry>index,pager</entry>
+           <entry><literal>&lt;sidebar-toggle-visible&gt;</literal></entry>
+           <entry>Make the Sidebar (in)visible</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+  </sect2>
+
+  <sect2 id="sidebar-commands">
+    <title>Commands</title>
+    <cmdsynopsis>
+      <command>sidebar_whitelist<anchor id="sidebar-whitelist"/></command>
+      <arg choice="plain">
+       <replaceable class="parameter">mailbox</replaceable>
+      </arg>
+      <arg choice="opt" rep="repeat">
+       <replaceable class="parameter">mailbox</replaceable>
+      </arg>
+    </cmdsynopsis>
+  </sect2>
+
+  <sect2 id="sidebar-colors">
+    <title>Colors</title>
+
+    <table id="table-sidebar-colors">
+      <title>Sidebar Colors</title>
+      <tgroup cols="3">
+       <thead>
+         <row>
+           <entry>Name</entry>
+           <entry>Default Color</entry>
+           <entry>Description</entry>
+         </row>
+       </thead>
+       <tbody>
+         <row>
+           <entry><literal>sidebar_divider</literal></entry>
+           <entry>default</entry>
+           <entry>The dividing line between the Sidebar and the Index/Pager 
panels</entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_flagged</literal></entry>
+           <entry>default</entry>
+           <entry>Mailboxes containing flagged mail</entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_highlight</literal></entry>
+           <entry>underline</entry>
+           <entry>Cursor to select a mailbox</entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_indicator</literal></entry>
+           <entry>mutt <literal>indicator</literal></entry>
+           <entry>The mailbox open in the Index panel</entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_new</literal></entry>
+           <entry>default</entry>
+           <entry>Mailboxes containing new mail</entry>
+         </row>
+         <row>
+           <entry><literal>sidebar_spoolfile</literal></entry>
+           <entry>default</entry>
+           <entry>Mailbox that receives incoming mail</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+
+    <para>
+    If the <literal>sidebar_indicator</literal> color isn't set, then the 
default Mutt
+    indicator color will be used (the color used in the index panel).
+    </para>
+  </sect2>

Reply via email to