Ticket #33222: patch-1.5.21-6.2.debian.sidebar.diff

File patch-1.5.21-6.2.debian.sidebar.diff, 36.5 KB (added by kchr@…, 11 years ago)

Updated sidebar patch, from mutt-patched in Debian repo (revision 6.2)

  • Makefile.am

    This is the sidebar patch.
    
    When enabled, mutt will show a list of mailboxes with (new) message counts in a
    separate column on the left side of the screen.
    
    As this feature is still considered to be unstable, this patch is only applied
    in the "mutt-patched" package.
    
    * Configuration variables:
    
      sidebar_delim (string, default "|")
    
        This specifies the delimiter between the sidebar (if visible) and 
        other screens.
    
      sidebar_visible (boolean, default no)
    
        This specifies whether or not to show sidebar (left-side list of folders).
    
      sidebar_width (integer, default 0)
    -
        The width of the sidebar.
    
    * Patch source:
      - http://www.lunar-linux.org/index.php?page=mutt-sidebar
      - http://lunar-linux.org/~tchan/mutt/patch-1.5.19.sidebar.20090522.txt
    
    * Changes made:
      - 2008-08-02 myon: Refreshed patch using quilt push -f to remove hunks we do
        not need (Makefile.in).
    
    a b  
    3232        rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \
    3333        score.c send.c sendlib.c signal.c sort.c \
    3434        status.c system.c thread.c charset.c history.c lib.c \
     35        sidebar.c \
    3536        muttlib.c editmsg.c mbyte.c \
    3637        url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
    3738
  • OPS

    a b  
    180180OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
    181181OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
    182182OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
     183OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
     184OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
     185OP_SIDEBAR_NEXT "go down to next mailbox"
     186OP_SIDEBAR_PREV "go to previous mailbox"
     187OP_SIDEBAR_OPEN "open hilighted mailbox"
  • buffy.c

    a b  
    340340  return rc;
    341341}
    342342
     343/* update message counts for the sidebar */
     344void buffy_maildir_update (BUFFY* mailbox)
     345{
     346  char path[_POSIX_PATH_MAX];
     347  DIR *dirp;
     348  struct dirent *de;
     349  char *p;
     350
     351  mailbox->msgcount = 0;
     352  mailbox->msg_unread = 0;
     353  mailbox->msg_flagged = 0;
     354
     355  snprintf (path, sizeof (path), "%s/new", mailbox->path);
     356       
     357  if ((dirp = opendir (path)) == NULL)
     358  {   
     359    mailbox->magic = 0;
     360    return;
     361  }
     362     
     363  while ((de = readdir (dirp)) != NULL)
     364  {
     365    if (*de->d_name == '.')
     366      continue;
     367
     368    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
     369      mailbox->new = 1;
     370      mailbox->msgcount++;
     371      mailbox->msg_unread++;
     372    }
     373  }
     374
     375  closedir (dirp);
     376  snprintf (path, sizeof (path), "%s/cur", mailbox->path);
     377       
     378  if ((dirp = opendir (path)) == NULL)
     379  {   
     380    mailbox->magic = 0;
     381    return;
     382  }
     383     
     384  while ((de = readdir (dirp)) != NULL)
     385  {
     386    if (*de->d_name == '.')
     387      continue;
     388
     389    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
     390      mailbox->msgcount++;
     391      if ((p = strstr (de->d_name, ":2,"))) {
     392        if (!strchr (p + 3, 'T')) {
     393          if (!strchr (p + 3, 'S'))
     394            mailbox->msg_unread++;
     395          if (strchr(p + 3, 'F'))
     396            mailbox->msg_flagged++;
     397        }
     398      }
     399    }
     400  }
     401
     402  closedir (dirp);
     403}
     404
    343405/* returns 1 if mailbox has new mail */
    344406static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
    345407{
     
    371433  return rc;
    372434}
    373435
     436/* update message counts for the sidebar */
     437void buffy_mbox_update (BUFFY* mailbox)
     438{
     439  CONTEXT *ctx = NULL;
     440
     441  ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
     442  if(ctx)
     443  {
     444    mailbox->msgcount = ctx->msgcount;
     445    mailbox->msg_unread = ctx->unread;
     446    mx_close_mailbox(ctx, 0);
     447  }
     448}
     449
    374450int mutt_buffy_check (int force)
    375451{
    376452  BUFFY *tmp;
     
    444520      {
    445521      case M_MBOX:
    446522      case M_MMDF:
     523        buffy_mbox_update (tmp);
    447524        if (buffy_mbox_hasnew (tmp, &sb) > 0)
    448525          BuffyCount++;
    449526        break;
    450527
    451528      case M_MAILDIR:
     529        buffy_maildir_update (tmp);
    452530        if (buffy_maildir_hasnew (tmp) > 0)
    453531          BuffyCount++;
    454532        break;
    455533
    456534      case M_MH:
     535        mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged);
    457536        if ((tmp->new = mh_buffy (tmp->path)) > 0)
    458537          BuffyCount++;
    459538        break;
  • buffy.h

    a b  
    2525  char path[_POSIX_PATH_MAX];
    2626  off_t size;
    2727  struct buffy_t *next;
     28  struct buffy_t *prev;
    2829  short new;                    /* mailbox has new mail */
     30  int msgcount;                 /* total number of messages */
     31  int msg_unread;               /* number of unread messages */
     32  int msg_flagged;              /* number of flagged messages */
    2933  short notified;               /* user has been notified */
    3034  short magic;                  /* mailbox type */
    3135  short newly_created;          /* mbox or mmdf just popped into existence */
  • color.c

    a b  
    9393  { "bold",             MT_COLOR_BOLD },
    9494  { "underline",        MT_COLOR_UNDERLINE },
    9595  { "index",            MT_COLOR_INDEX },
     96  { "sidebar_new",      MT_COLOR_NEW },
     97  { "sidebar_flagged",  MT_COLOR_FLAGGED },
    9698  { NULL,               0 }
    9799};
    98100
  • compose.c

    a b  
    7272
    7373#define HDR_XOFFSET 10
    7474#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
    75 #define W (COLS - HDR_XOFFSET)
     75#define W (COLS - HDR_XOFFSET - SidebarWidth)
    7676
    7777static char *Prompts[] =
    7878{
     
    112112{
    113113  int off = 0;
    114114
    115   mvaddstr (HDR_CRYPT, 0, "Security: ");
     115  mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
    116116
    117117  if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
    118118  {
     
    144144  }
    145145
    146146  clrtoeol ();
    147   move (HDR_CRYPTINFO, 0);
     147  move (HDR_CRYPTINFO, SidebarWidth);
    148148  clrtoeol ();
    149149
    150150  if ((WithCrypto & APPLICATION_PGP)
     
    161161      && (msg->security & ENCRYPT)
    162162      && SmimeCryptAlg
    163163      && *SmimeCryptAlg) {
    164       mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
     164      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
    165165                NONULL(SmimeCryptAlg));
    166166      off = 20;
    167167  }
     
    175175  int c;
    176176  char *t;
    177177
    178   mvaddstr (HDR_MIX, 0,     "     Mix: ");
     178  mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
    179179
    180180  if (!chain)
    181181  {
     
    190190    if (t && t[0] == '0' && t[1] == '\0')
    191191      t = "<random>";
    192192   
    193     if (c + mutt_strlen (t) + 2 >= COLS)
     193    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
    194194      break;
    195195
    196196    addstr (NONULL(t));
     
    242242
    243243  buf[0] = 0;
    244244  rfc822_write_address (buf, sizeof (buf), addr, 1);
    245   mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
     245  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
    246246  mutt_paddstr (W, buf);
    247247}
    248248
     
    252252  draw_envelope_addr (HDR_TO, msg->env->to);
    253253  draw_envelope_addr (HDR_CC, msg->env->cc);
    254254  draw_envelope_addr (HDR_BCC, msg->env->bcc);
    255   mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
     255  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
    256256  mutt_paddstr (W, NONULL (msg->env->subject));
    257257  draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
    258   mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
     258  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
    259259  mutt_paddstr (W, fcc);
    260260
    261261  if (WithCrypto)
     
    266266#endif
    267267
    268268  SETCOLOR (MT_COLOR_STATUS);
    269   mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
     269  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
    270270  BKGDSET (MT_COLOR_STATUS);
    271271  clrtoeol ();
    272272
     
    304304  /* redraw the expanded list so the user can see the result */
    305305  buf[0] = 0;
    306306  rfc822_write_address (buf, sizeof (buf), *addr, 1);
    307   move (line, HDR_XOFFSET);
     307  move (line, HDR_XOFFSET+SidebarWidth);
    308308  mutt_paddstr (W, buf);
    309309 
    310310  return 0;
     
    549549        if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
    550550        {
    551551          mutt_str_replace (&msg->env->subject, buf);
    552           move (HDR_SUBJECT, HDR_XOFFSET);
     552          move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
    553553          clrtoeol ();
    554554          if (msg->env->subject)
    555555            mutt_paddstr (W, msg->env->subject);
     
    566566        {
    567567          strfcpy (fcc, buf, fcclen);
    568568          mutt_pretty_mailbox (fcc, fcclen);
    569           move (HDR_FCC, HDR_XOFFSET);
     569          move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
    570570          mutt_paddstr (W, fcc);
    571571          fccSet = 1;
    572572        }
  • curs_main.c

    a b  
    2626#include "mailbox.h"
    2727#include "mapping.h"
    2828#include "sort.h"
     29#include "buffy.h"
    2930#include "mx.h"
     31#include "sidebar.h"
    3032
    3133#ifdef USE_POP
    3234#include "pop.h"
     
    532534       menu->redraw |= REDRAW_STATUS;
    533535     if (do_buffy_notify)
    534536     {
    535        if (mutt_buffy_notify () && option (OPTBEEPNEW))
    536         beep ();
     537       if (mutt_buffy_notify ())
     538       {
     539         menu->redraw |= REDRAW_FULL;
     540         if (option (OPTBEEPNEW))
     541           beep ();
     542       }
    537543     }
    538544     else
    539545       do_buffy_notify = 1;
     
    545551    if (menu->redraw & REDRAW_FULL)
    546552    {
    547553      menu_redraw_full (menu);
     554      draw_sidebar(menu->menu);
    548555      mutt_show_error ();
    549556    }
    550557
     
    567574
    568575      if (menu->redraw & REDRAW_STATUS)
    569576      {
     577        DrawFullLine = 1;
    570578        menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
     579        DrawFullLine = 0;
    571580        CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
    572581        SETCOLOR (MT_COLOR_STATUS);
    573582        BKGDSET (MT_COLOR_STATUS);
     583        set_buffystats(Context);
    574584        mutt_paddstr (COLS, buf);
    575585        SETCOLOR (MT_COLOR_NORMAL);
    576586        BKGDSET (MT_COLOR_NORMAL);
     
    591601        menu->oldcurrent = -1;
    592602
    593603      if (option (OPTARROWCURSOR))
    594         move (menu->current - menu->top + menu->offset, 2);
     604        move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
    595605      else if (option (OPTBRAILLEFRIENDLY))
    596606        move (menu->current - menu->top + menu->offset, 0);
    597607      else
     
    10891099          menu->redraw = REDRAW_FULL;
    10901100        break;
    10911101
     1102      case OP_SIDEBAR_OPEN:
    10921103      case OP_MAIN_CHANGE_FOLDER:
    10931104      case OP_MAIN_NEXT_UNREAD_MAILBOX:
    10941105
     
    11201131        {
    11211132          mutt_buffy (buf, sizeof (buf));
    11221133
    1123           if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
     1134          if ( op == OP_SIDEBAR_OPEN ) {
     1135              if(!CurBuffy)
     1136                break;
     1137            strncpy( buf, CurBuffy->path, sizeof(buf) ); 
     1138            } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
    11241139          {
    11251140            if (menu->menu == MENU_PAGER)
    11261141            {
     
    11381153        }
    11391154
    11401155        mutt_expand_path (buf, sizeof (buf));
     1156        set_curbuffy(buf);
    11411157        if (mx_get_magic (buf) <= 0)
    11421158        {
    11431159          mutt_error (_("%s is not a mailbox."), buf);
     
    22412257        mutt_what_key();
    22422258        break;
    22432259
     2260      case OP_SIDEBAR_SCROLL_UP:
     2261      case OP_SIDEBAR_SCROLL_DOWN:
     2262      case OP_SIDEBAR_NEXT:
     2263      case OP_SIDEBAR_PREV:
     2264        scroll_sidebar(op, menu->menu);
     2265        break;
    22442266      default:
    22452267        if (menu->menu == MENU_MAIN)
    22462268          km_error_key (MENU_MAIN);
  • flags.c

    a b  
    2222
    2323#include "mutt.h"
    2424#include "mutt_curses.h"
     25#include "mutt_menu.h"
    2526#include "sort.h"
    2627#include "mx.h"
     28#include "sidebar.h"
    2729
    2830void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
    2931{
     
    290292   */
    291293  if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
    292294    h->searched = 0;
     295        draw_sidebar(0);
    293296}
    294297
    295298void mutt_tag_set_flag (int flag, int bf)
  • functions.h

    a b  
    170170  { "decrypt-save",             OP_DECRYPT_SAVE,                NULL },
    171171
    172172
     173 { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
     174 { "sidebar-scroll-down",       OP_SIDEBAR_SCROLL_DOWN, NULL },
     175 { "sidebar-next",              OP_SIDEBAR_NEXT, NULL },
     176 { "sidebar-prev",              OP_SIDEBAR_PREV, NULL },
     177 { "sidebar-open",              OP_SIDEBAR_OPEN, NULL },
    173178  { NULL,                       0,                              NULL }
    174179};
    175180
     
    274279
    275280  { "what-key",         OP_WHAT_KEY,            NULL },
    276281
     282  { "sidebar-scroll-up",        OP_SIDEBAR_SCROLL_UP, NULL },
     283  { "sidebar-scroll-down",      OP_SIDEBAR_SCROLL_DOWN, NULL },
     284  { "sidebar-next",     OP_SIDEBAR_NEXT, NULL },
     285  { "sidebar-prev",     OP_SIDEBAR_PREV, NULL },
     286  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
    277287  { NULL,               0,                              NULL }
    278288};
    279289
  • globals.h

    a b  
    117117WHERE char *SendCharset;
    118118WHERE char *Sendmail;
    119119WHERE char *Shell;
     120WHERE char *SidebarDelim;
    120121WHERE char *Signature;
    121122WHERE char *SimpleSearch;
    122123#if USE_SMTP
     
    210211WHERE short ScoreThresholdRead;
    211212WHERE short ScoreThresholdFlag;
    212213
     214WHERE struct buffy_t *CurBuffy INITVAL(0);
     215WHERE short DrawFullLine INITVAL(0);
     216WHERE short SidebarWidth;
    213217#ifdef USE_IMAP
    214218WHERE short ImapKeepalive;
    215219WHERE short ImapPipelineDepth;
  • imap/command.c

    a b  
    10111011             opened */
    10121012          status->uidnext = oldun;
    10131013
     1014        /* Added to make the sidebar show the correct numbers */
     1015        if (status->messages)
     1016        {
     1017          inc->msgcount = status->messages;
     1018          inc->msg_unread = status->unseen;
     1019        }
     1020
    10141021        FREE (&value);
    10151022        return;
    10161023      }
  • imap/imap.c

    a b  
    15271527
    15281528    imap_munge_mbox_name (munged, sizeof (munged), name);
    15291529    snprintf (command, sizeof (command),
    1530               "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
     1530              "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
    15311531
    15321532    if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
    15331533    {
  • init.h

    a b  
    19651965  ** not used.
    19661966  ** (PGP only)
    19671967  */
     1968  {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
     1969  /*
     1970  ** .pp
     1971  ** This specifies the delimiter between the sidebar (if visible) and
     1972  ** other screens.
     1973  */
     1974  { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
     1975  /*
     1976  ** .pp
     1977  ** This specifies whether or not to show sidebar (left-side list of folders).
     1978  */
     1979  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
     1980  /*
     1981  ** .pp
     1982  ** The width of the sidebar.
     1983  */
    19681984  { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
    19691985  /*
    19701986  ** .pp
  • mailbox.h

    a b  
    2727#define M_NEWFOLDER     (1<<4) /* create a new folder - same as M_APPEND, but uses
    2828                                * safe_fopen() for mbox-style folders.
    2929                                */
     30#define M_PEEK          (1<<5) /* revert atime back after taking a look (if applicable) */
    3031
    3132/* mx_open_new_message() */
    3233#define M_ADD_FROM      1       /* add a From_ line */
  • mbox.c

    a b  
    104104    mutt_perror (ctx->path);
    105105    return (-1);
    106106  }
     107  ctx->atime = sb.st_atime;
    107108  ctx->mtime = sb.st_mtime;
    108109  ctx->size = sb.st_size;
    109110
     
    255256
    256257  ctx->size = sb.st_size;
    257258  ctx->mtime = sb.st_mtime;
     259  ctx->atime = sb.st_atime;
    258260
    259261#ifdef NFS_ATTRIBUTE_HACK
    260262  if (sb.st_mtime > sb.st_atime)
  • menu.c

    a b  
    2424#include "mutt_curses.h"
    2525#include "mutt_menu.h"
    2626#include "mbyte.h"
     27#include "sidebar.h"
    2728
    2829#include <string.h>
    2930#include <stdlib.h>
     
    156157{
    157158  char *scratch = safe_strdup (s);
    158159  int shift = option (OPTARROWCURSOR) ? 3 : 0;
    159   int cols = COLS - shift;
     160  int cols = COLS - shift - SidebarWidth;
    160161
    161162  mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
    162163  s[n - 1] = 0;
     
    207208  char buf[LONG_STRING];
    208209  int i;
    209210
     211  draw_sidebar(1);
    210212  for (i = menu->top; i < menu->top + menu->pagelen; i++)
    211213  {
    212214    if (i < menu->max)
     
    217219      if (option (OPTARROWCURSOR))
    218220      {
    219221        attrset (menu->color (i));
    220         CLEARLINE (i - menu->top + menu->offset);
     222        CLEARLINE_WIN (i - menu->top + menu->offset);
    221223
    222224        if (i == menu->current)
    223225        {
     
    246248          BKGDSET (MT_COLOR_INDICATOR);
    247249        }
    248250
    249         CLEARLINE (i - menu->top + menu->offset);
     251        CLEARLINE_WIN (i - menu->top + menu->offset);
    250252        print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
    251253        SETCOLOR (MT_COLOR_NORMAL);
    252254        BKGDSET (MT_COLOR_NORMAL);
    253255      }
    254256    }
    255257    else
    256       CLEARLINE (i - menu->top + menu->offset);
     258      CLEARLINE_WIN (i - menu->top + menu->offset);
    257259  }
    258260  menu->redraw = 0;
    259261}
     
    268270    return;
    269271  }
    270272 
    271   move (menu->oldcurrent + menu->offset - menu->top, 0);
     273  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
    272274  SETCOLOR (MT_COLOR_NORMAL);
    273275  BKGDSET (MT_COLOR_NORMAL);
    274276
     
    283285      clrtoeol ();
    284286      menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
    285287      menu_pad_string (buf, sizeof (buf));
    286       move (menu->oldcurrent + menu->offset - menu->top, 3);
     288      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
    287289      print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
    288290      SETCOLOR (MT_COLOR_NORMAL);
    289291    }
    290292
    291293    /* now draw it in the new location */
    292     move (menu->current + menu->offset - menu->top, 0);
     294    move (menu->current + menu->offset - menu->top, SidebarWidth);
    293295    attrset (menu->color (menu->current));
    294296    ADDCOLOR (MT_COLOR_INDICATOR);
    295297    addstr ("->");
     
    310312    attrset (menu->color (menu->current));
    311313    ADDCOLOR (MT_COLOR_INDICATOR);
    312314    BKGDSET (MT_COLOR_INDICATOR);
    313     CLEARLINE (menu->current - menu->top + menu->offset);
     315    CLEARLINE_WIN (menu->current - menu->top + menu->offset);
    314316    print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
    315317    SETCOLOR (MT_COLOR_NORMAL);
    316318    BKGDSET (MT_COLOR_NORMAL);
     
    322324{
    323325  char buf[LONG_STRING];
    324326 
    325   move (menu->current + menu->offset - menu->top, 0);
     327  move (menu->current + menu->offset - menu->top, SidebarWidth);
    326328  menu_make_entry (buf, sizeof (buf), menu, menu->current);
    327329  menu_pad_string (buf, sizeof (buf));
    328330
     
    884886   
    885887   
    886888    if (option (OPTARROWCURSOR))
    887       move (menu->current - menu->top + menu->offset, 2);
     889      move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
    888890    else if (option (OPTBRAILLEFRIENDLY))
    889891      move (menu->current - menu->top + menu->offset, 0);
    890892    else
  • mh.c

    a b  
    235235
    236236  if (mh_read_sequences (&mhs, path) < 0)
    237237    return 0;
     238
    238239  for (i = 0; !r && i <= mhs.max; i++)
    239     if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN)
     240    if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
    240241      r = 1;
     242    }
    241243  mhs_free_sequences (&mhs);
    242244  return r;
    243245}
    244246
     247void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged)
     248{
     249  int i;
     250  struct mh_sequences mhs;
     251  memset (&mhs, 0, sizeof (mhs));
     252
     253  if (mh_read_sequences (&mhs, path) < 0)
     254    return;
     255
     256  msgcount = 0;
     257  msg_unread = 0;
     258  msg_flagged = 0;
     259  for (i = 0; i <= mhs.max; i++)
     260    msgcount++;
     261    if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
     262      msg_unread++;
     263    }
     264    if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
     265      msg_flagged++;
     266  mhs_free_sequences (&mhs);
     267}
     268
    245269static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
    246270{
    247271  int fd;
  • mutt.h

    a b  
    431431  OPTSAVEEMPTY,
    432432  OPTSAVENAME,
    433433  OPTSCORE,
     434  OPTSIDEBAR,
    434435  OPTSIGDASHES,
    435436  OPTSIGONTOP,
    436437  OPTSORTRE,
     
    874875{
    875876  char *path;
    876877  FILE *fp;
     878  time_t atime;
    877879  time_t mtime;
    878880  off_t size;
    879881  off_t vsize;
     
    914916  unsigned int quiet : 1;       /* inhibit status messages? */
    915917  unsigned int collapsed : 1;   /* are all threads collapsed? */
    916918  unsigned int closing : 1;     /* mailbox is being closed */
     919  unsigned int peekonly : 1;    /* just taking a glance, revert atime */
    917920
    918921  /* driver hooks */
    919922  void *data;                   /* driver specific data */
  • mutt_curses.h

    a b  
    6464#undef lines
    6565#endif /* lines */
    6666
     67#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
    6768#define CLEARLINE(x) move(x,0), clrtoeol()
    6869#define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
    6970#define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
     
    126127  MT_COLOR_BOLD,
    127128  MT_COLOR_UNDERLINE,
    128129  MT_COLOR_INDEX,
     130  MT_COLOR_NEW,
     131  MT_COLOR_FLAGGED,
    129132  MT_COLOR_MAX
    130133};
    131134
  • muttlib.c

    a b  
    12861286          pl = pw = 1;
    12871287
    12881288        /* see if there's room to add content, else ignore */
     1289        if ( DrawFullLine )
     1290        {
    12891291        if ((col < COLS && wlen < destlen) || soft)
    12901292        {
    12911293          int pad;
     
    13291331          col += wid;
    13301332          src += pl;
    13311333        }
     1334        }
     1335        else
     1336        {
     1337        if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
     1338        {
     1339          int pad;
     1340
     1341          /* get contents after padding */
     1342          mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
     1343          len = mutt_strlen (buf);
     1344          wid = mutt_strwidth (buf);
     1345
     1346          /* try to consume as many columns as we can, if we don't have
     1347           * memory for that, use as much memory as possible */
     1348          pad = (COLS - SidebarWidth - col - wid) / pw;
     1349          if (pad > 0 && wlen + (pad * pl) + len > destlen)
     1350            pad = ((signed)(destlen - wlen - len)) / pl;
     1351          if (pad > 0)
     1352          {
     1353            while (pad--)
     1354            {
     1355              memcpy (wptr, src, pl);
     1356              wptr += pl;
     1357              wlen += pl;
     1358              col += pw;
     1359            }
     1360          }
     1361          else if (soft && pad < 0)
     1362          {
     1363            /* \0-terminate dest for length computation in mutt_wstr_trunc() */
     1364            *wptr = 0;
     1365            /* make sure right part is at most as wide as display */
     1366            len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
     1367            /* truncate left so that right part fits completely in */
     1368            wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
     1369            wptr = dest + wlen;
     1370          }
     1371          if (len + wlen > destlen)
     1372            len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
     1373          memcpy (wptr, buf, len);
     1374          wptr += len;
     1375          wlen += len;
     1376          col += wid;
     1377          src += pl;
     1378        }
     1379        }
    13321380        break; /* skip rest of input */
    13331381      }
    13341382      else if (ch == '|')
  • mx.c

    a b  
    595595 *              M_APPEND        open mailbox for appending
    596596 *              M_READONLY      open mailbox in read-only mode
    597597 *              M_QUIET         only print error messages
     598 *              M_PEEK          revert atime where applicable
    598599 *      ctx     if non-null, context struct to use
    599600 */
    600601CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
     
    617618    ctx->quiet = 1;
    618619  if (flags & M_READONLY)
    619620    ctx->readonly = 1;
     621  if (flags & M_PEEK)
     622    ctx->peekonly = 1;
    620623
    621624  if (flags & (M_APPEND|M_NEWFOLDER))
    622625  {
     
    721724void mx_fastclose_mailbox (CONTEXT *ctx)
    722725{
    723726  int i;
     727#ifndef BUFFY_SIZE
     728  struct utimbuf ut;
     729#endif
    724730
    725731  if(!ctx)
    726732    return;
     733#ifndef BUFFY_SIZE
     734  /* fix up the times so buffy won't get confused */
     735  if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
     736  {
     737    ut.actime = ctx->atime;
     738    ut.modtime = ctx->mtime;
     739    utime (ctx->path, &ut);
     740  }
     741#endif
    727742
    728743  /* never announce that a mailbox we've just left has new mail. #3290
    729744   * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
  • mx.h

    a b  
    6161int mh_sync_mailbox (CONTEXT *, int *);
    6262int mh_check_mailbox (CONTEXT *, int *);
    6363int mh_buffy (const char *);
     64void mh_buffy_update (const char *, int *, int *, int *);
    6465int mh_check_empty (const char *);
    6566
    6667int maildir_read_dir (CONTEXT *);
  • pager.c

    a b  
    2929#include "pager.h"
    3030#include "attach.h"
    3131#include "mbyte.h"
     32#include "sidebar.h"
    3233
    3334#include "mutt_crypt.h"
    3435
     
    10951096  wchar_t wc;
    10961097  mbstate_t mbstate;
    10971098  int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
     1099  wrap_cols -= SidebarWidth;
    10981100
    10991101  if (check_attachment_marker ((char *)buf) == 0)
    11001102    wrap_cols = COLS;
     
    17451747    if ((redraw & REDRAW_BODY) || topline != oldtopline)
    17461748    {
    17471749      do {
    1748         move (bodyoffset, 0);
     1750        move (bodyoffset, SidebarWidth);
    17491751        curline = oldtopline = topline;
    17501752        lines = 0;
    17511753        force_redraw = 0;
     
    17581760                            &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
    17591761            lines++;
    17601762          curline++;
     1763          move(lines + bodyoffset, SidebarWidth);
    17611764        }
    17621765        last_offset = lineInfo[curline].offset;
    17631766      } while (force_redraw);
     
    17711774          addch ('~');
    17721775        addch ('\n');
    17731776        lines++;
     1777        move(lines + bodyoffset, SidebarWidth);
    17741778      }
    17751779      /* We are going to update the pager status bar, so it isn't
    17761780       * necessary to reset to normal color now. */
     
    17941798      /* print out the pager status bar */
    17951799      SETCOLOR (MT_COLOR_STATUS);
    17961800      BKGDSET (MT_COLOR_STATUS);
    1797       CLEARLINE (statusoffset);
     1801      CLEARLINE_WIN (statusoffset);
    17981802
    17991803      if (IsHeader (extra) || IsMsgAttach (extra))
    18001804      {
    1801         size_t l1 = COLS * MB_LEN_MAX;
     1805        size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
    18021806        size_t l2 = sizeof (buffer);
    18031807        hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
    18041808        mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
    1805         mutt_paddstr (COLS, buffer);
     1809        mutt_paddstr (COLS-SidebarWidth, buffer);
    18061810      }
    18071811      else
    18081812      {
    18091813        char bn[STRING];
    18101814        snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
    1811         mutt_paddstr (COLS, bn);
     1815        mutt_paddstr (COLS-SidebarWidth, bn);
    18121816      }
    18131817      BKGDSET (MT_COLOR_NORMAL);
    18141818      SETCOLOR (MT_COLOR_NORMAL);
     
    18261830      /* redraw the pager_index indicator, because the
    18271831       * flags for this message might have changed. */
    18281832      menu_redraw_current (index);
     1833      draw_sidebar(MENU_PAGER);
    18291834
    18301835      /* print out the index status bar */
    18311836      menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
    18321837 
    1833       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
     1838      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
    18341839      SETCOLOR (MT_COLOR_STATUS);
    18351840      BKGDSET (MT_COLOR_STATUS);
    1836       mutt_paddstr (COLS, buffer);
     1841      mutt_paddstr (COLS-SidebarWidth, buffer);
    18371842      SETCOLOR (MT_COLOR_NORMAL);
    18381843      BKGDSET (MT_COLOR_NORMAL);
    18391844    }
    18401845
     1846    /* if we're not using the index, update every time */
     1847    if ( index == 0 )
     1848      draw_sidebar(MENU_PAGER);
     1849
    18411850    redraw = 0;
    18421851
    18431852    if (option(OPTBRAILLEFRIENDLY)) {
     
    27692778        mutt_what_key ();
    27702779        break;
    27712780
     2781      case OP_SIDEBAR_SCROLL_UP:
     2782      case OP_SIDEBAR_SCROLL_DOWN:
     2783      case OP_SIDEBAR_NEXT:
     2784      case OP_SIDEBAR_PREV:
     2785        scroll_sidebar(ch, MENU_PAGER);
     2786        break;
     2787
    27722788      default:
    27732789        ch = -1;
    27742790        break;
  • new file sidebar.c

    - +  
     1/*
     2 * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
     3 * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
     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
     21#if HAVE_CONFIG_H
     22# include "config.h"
     23#endif
     24
     25#include "mutt.h"
     26#include "mutt_menu.h"
     27#include "mutt_curses.h"
     28#include "sidebar.h"
     29#include "buffy.h"
     30#include <libgen.h>
     31#include "keymap.h"
     32#include <stdbool.h>
     33
     34/*BUFFY *CurBuffy = 0;*/
     35static BUFFY *TopBuffy = 0;
     36static BUFFY *BottomBuffy = 0;
     37static int known_lines = 0;
     38
     39static int quick_log10(int n)
     40{
     41        char string[32];
     42        sprintf(string, "%d", n);
     43        return strlen(string);
     44}
     45
     46void calc_boundaries (int menu)
     47{
     48        BUFFY *tmp = Incoming;
     49
     50        if ( known_lines != LINES ) {
     51                TopBuffy = BottomBuffy = 0;
     52                known_lines = LINES;
     53        }
     54        for ( ; tmp->next != 0; tmp = tmp->next )
     55                tmp->next->prev = tmp;
     56
     57        if ( TopBuffy == 0 && BottomBuffy == 0 )
     58                TopBuffy = Incoming;
     59        if ( BottomBuffy == 0 ) {
     60                int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
     61                BottomBuffy = TopBuffy;
     62                while ( --count && BottomBuffy->next )
     63                        BottomBuffy = BottomBuffy->next;
     64        }
     65        else if ( TopBuffy == CurBuffy->next ) {
     66                int count = LINES - 2 - (menu != MENU_PAGER);
     67                BottomBuffy = CurBuffy;
     68                tmp = BottomBuffy;
     69                while ( --count && tmp->prev)
     70                        tmp = tmp->prev;
     71                TopBuffy = tmp;
     72        }
     73        else if ( BottomBuffy == CurBuffy->prev ) {
     74                int count = LINES - 2 - (menu != MENU_PAGER);
     75                TopBuffy = CurBuffy;
     76                tmp = TopBuffy;
     77                while ( --count && tmp->next )
     78                        tmp = tmp->next;
     79                BottomBuffy = tmp;
     80        }
     81}
     82
     83char *make_sidebar_entry(char *box, int size, int new, int flagged)
     84{
     85        static char *entry = 0;
     86        char *c;
     87        int i = 0;
     88        int delim_len = strlen(SidebarDelim);
     89
     90        c = realloc(entry, SidebarWidth - delim_len + 2);
     91        if ( c ) entry = c;
     92        entry[SidebarWidth - delim_len + 1] = 0;
     93        for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
     94        i = strlen(box);
     95        strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
     96
     97        if (size == -1)
     98                sprintf(entry + SidebarWidth - delim_len - 3, "?");
     99        else if ( new ) {
     100          if (flagged > 0) {
     101              sprintf(
     102                        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
     103                        "% d(%d)[%d]", size, new, flagged);
     104          } else {
     105              sprintf(
     106                      entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
     107                      "% d(%d)", size, new);
     108          }
     109        } else if (flagged > 0) {
     110              sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
     111        } else {
     112              sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
     113        }
     114        return entry;
     115}
     116
     117void set_curbuffy(char buf[LONG_STRING])
     118{
     119  BUFFY* tmp = CurBuffy = Incoming;
     120
     121  if (!Incoming)
     122    return;
     123
     124  while(1) {
     125    if(!strcmp(tmp->path, buf)) {
     126      CurBuffy = tmp;
     127      break;
     128    }
     129
     130    if(tmp->next)
     131      tmp = tmp->next;
     132    else
     133      break;
     134  }
     135}
     136
     137int draw_sidebar(int menu) {
     138
     139        int lines = option(OPTHELP) ? 1 : 0;
     140    lines += option(OPTSTATUSONTOP) ? 1 : 0;
     141
     142        BUFFY *tmp;
     143#ifndef USE_SLANG_CURSES
     144        attr_t attrs;
     145#endif
     146        short delim_len = strlen(SidebarDelim);
     147        short color_pair;
     148
     149        static bool initialized = false;
     150        static int prev_show_value;
     151        static short saveSidebarWidth;
     152
     153        /* initialize first time */
     154        if(!initialized) {
     155                prev_show_value = option(OPTSIDEBAR);
     156                saveSidebarWidth = SidebarWidth;
     157                if(!option(OPTSIDEBAR)) SidebarWidth = 0;
     158                initialized = true;
     159        }
     160
     161        /* save or restore the value SidebarWidth */
     162        if(prev_show_value != option(OPTSIDEBAR)) {
     163                if(prev_show_value && !option(OPTSIDEBAR)) {
     164                        saveSidebarWidth = SidebarWidth;
     165                        SidebarWidth = 0;
     166                } else if(!prev_show_value && option(OPTSIDEBAR)) {
     167                        SidebarWidth = saveSidebarWidth;
     168                }
     169                prev_show_value = option(OPTSIDEBAR);
     170        }
     171
     172
     173//      if ( SidebarWidth == 0 ) return 0;
     174       if (SidebarWidth > 0 && option (OPTSIDEBAR)
     175           && delim_len >= SidebarWidth) {
     176         unset_option (OPTSIDEBAR);
     177         /* saveSidebarWidth = SidebarWidth; */
     178         if (saveSidebarWidth > delim_len) {
     179           SidebarWidth = saveSidebarWidth;
     180           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
     181           sleep (2);
     182         } else {
     183           SidebarWidth = 0;
     184           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
     185           sleep (4); /* the advise to set a sane value should be seen long enough */
     186         }
     187         saveSidebarWidth = 0;
     188         return (0);
     189       }
     190
     191    if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
     192      if (SidebarWidth > 0) {
     193        saveSidebarWidth = SidebarWidth;
     194        SidebarWidth = 0;
     195      }
     196      unset_option(OPTSIDEBAR);
     197      return 0;
     198    }
     199
     200        /* get attributes for divider */
     201        SETCOLOR(MT_COLOR_STATUS);
     202#ifndef USE_SLANG_CURSES
     203        attr_get(&attrs, &color_pair, 0);
     204#else
     205        color_pair = attr_get();
     206#endif
     207        SETCOLOR(MT_COLOR_NORMAL);
     208
     209        /* draw the divider */
     210
     211        for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
     212                move(lines, SidebarWidth - delim_len);
     213                addstr(NONULL(SidebarDelim));
     214#ifndef USE_SLANG_CURSES
     215                mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
     216#endif
     217        }
     218
     219        if ( Incoming == 0 ) return 0;
     220        lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
     221    lines += option(OPTSTATUSONTOP) ? 1 : 0;
     222
     223        if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 )
     224                calc_boundaries(menu);
     225        if ( CurBuffy == 0 ) CurBuffy = Incoming;
     226
     227        tmp = TopBuffy;
     228
     229        SETCOLOR(MT_COLOR_NORMAL);
     230
     231        for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
     232                if ( tmp == CurBuffy )
     233                        SETCOLOR(MT_COLOR_INDICATOR);
     234                else if ( tmp->msg_unread > 0 )
     235                        SETCOLOR(MT_COLOR_NEW);
     236                else if ( tmp->msg_flagged > 0 )
     237                        SETCOLOR(MT_COLOR_FLAGGED);
     238                else
     239                        SETCOLOR(MT_COLOR_NORMAL);
     240
     241                move( lines, 0 );
     242                if ( Context && !strcmp( tmp->path, Context->path ) ) {
     243                        tmp->msg_unread = Context->unread;
     244                        tmp->msgcount = Context->msgcount;
     245                        tmp->msg_flagged = Context->flagged;
     246                }
     247                // check whether Maildir is a prefix of the current folder's path
     248                short maildir_is_prefix = 0;
     249                if ( (strlen(tmp->path) > strlen(Maildir)) &&
     250                        (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
     251                        maildir_is_prefix = 1;
     252                // calculate depth of current folder and generate its display name with indented spaces
     253                int sidebar_folder_depth = 0;
     254                char *sidebar_folder_name;
     255                sidebar_folder_name = basename(tmp->path);
     256                if ( maildir_is_prefix ) {
     257                        char *tmp_folder_name;
     258                        int i;
     259                        tmp_folder_name = tmp->path + strlen(Maildir);
     260                        for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
     261                                if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
     262                        }   
     263                        if (sidebar_folder_depth > 0) {
     264                                sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
     265                                for (i=0; i < sidebar_folder_depth; i++)
     266                                        sidebar_folder_name[i]=' ';
     267                                sidebar_folder_name[i]=0;
     268                                strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
     269                        }
     270                }
     271                printw( "%.*s", SidebarWidth - delim_len + 1,
     272                        make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
     273                        tmp->msg_unread, tmp->msg_flagged));
     274                if (sidebar_folder_depth > 0)
     275                        free(sidebar_folder_name);
     276                lines++;
     277        }
     278        SETCOLOR(MT_COLOR_NORMAL);
     279        for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
     280                int i = 0;
     281                move( lines, 0 );
     282                for ( ; i < SidebarWidth - delim_len; i++ )
     283                        addch(' ');
     284        }
     285        return 0;
     286}
     287
     288
     289void set_buffystats(CONTEXT* Context)
     290{
     291        BUFFY *tmp = Incoming;
     292        while(tmp) {
     293                if(Context && !strcmp(tmp->path, Context->path)) {
     294                        tmp->msg_unread = Context->unread;
     295                        tmp->msgcount = Context->msgcount;
     296                        break;
     297                }
     298                tmp = tmp->next;
     299        }
     300}
     301
     302void scroll_sidebar(int op, int menu)
     303{
     304        if(!SidebarWidth) return;
     305        if(!CurBuffy) return;
     306
     307        switch (op) {
     308                case OP_SIDEBAR_NEXT:
     309                        if ( CurBuffy->next == NULL ) return;
     310                        CurBuffy = CurBuffy->next;
     311                        break;
     312                case OP_SIDEBAR_PREV:
     313                        if ( CurBuffy->prev == NULL ) return;
     314                        CurBuffy = CurBuffy->prev;
     315                        break;
     316                case OP_SIDEBAR_SCROLL_UP:
     317                        CurBuffy = TopBuffy;
     318                        if ( CurBuffy != Incoming ) {
     319                                calc_boundaries(menu);
     320                                CurBuffy = CurBuffy->prev;
     321                        }
     322                        break;
     323                case OP_SIDEBAR_SCROLL_DOWN:
     324                        CurBuffy = BottomBuffy;
     325                        if ( CurBuffy->next ) {
     326                                calc_boundaries(menu);
     327                                CurBuffy = CurBuffy->next;
     328                        }
     329                        break;
     330                default:
     331                        return;
     332        }
     333        calc_boundaries(menu);
     334        draw_sidebar(menu);
     335}
     336
  • new file sidebar.h

    - +  
     1/*
     2 * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
     3 * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
     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
     23struct MBOX_LIST {
     24        char *path;
     25        int msgcount;
     26        int new;
     27} MBLIST;
     28
     29/* parameter is whether or not to go to the status line */
     30/* used for omitting the last | that covers up the status bar in the index */
     31int draw_sidebar(int);
     32void scroll_sidebar(int, int);
     33void set_curbuffy(char*);
     34void set_buffystats(CONTEXT*);
     35
     36#endif /* SIDEBAR_H */