michael@478: The Mutt "sidebar" patch as taken over by Debian for Mutt 1.5.21 michael@478: but with the patches for Makefile.in applied again. michael@478: michael@478: Index: Makefile.am michael@478: --- Makefile.am.orig 2010-08-24 18:34:21.000000000 +0200 michael@478: +++ Makefile.am 2011-01-17 19:33:57.000000000 +0100 michael@478: @@ -33,7 +33,7 @@ michael@478: score.c send.c sendlib.c signal.c sort.c \ michael@478: status.c system.c thread.c charset.c history.c lib.c \ michael@478: muttlib.c editmsg.c mbyte.c \ michael@478: - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c michael@478: + url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c michael@478: michael@478: nodist_mutt_SOURCES = $(BUILT_SOURCES) michael@478: michael@478: Index: Makefile.in michael@478: --- Makefile.in.orig 2010-08-25 18:31:48.000000000 +0200 michael@478: +++ Makefile.in 2011-01-17 19:33:57.000000000 +0100 michael@478: @@ -85,7 +85,7 @@ michael@478: system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \ michael@478: history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \ michael@478: editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \ michael@478: - ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) michael@478: + ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT) michael@478: am__objects_1 = michael@478: am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1) michael@478: nodist_mutt_OBJECTS = $(am__objects_2) michael@478: @@ -359,7 +359,7 @@ michael@478: score.c send.c sendlib.c signal.c sort.c \ michael@478: status.c system.c thread.c charset.c history.c lib.c \ michael@478: muttlib.c editmsg.c mbyte.c \ michael@478: - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c michael@478: + url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c michael@478: michael@478: nodist_mutt_SOURCES = $(BUILT_SOURCES) michael@478: mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \ michael@478: @@ -391,7 +391,7 @@ michael@478: README.SSL smime.h group.h \ michael@478: muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \ michael@478: ChangeLog mkchangelog.sh mutt_idna.h \ michael@478: - snprintf.c regex.c crypt-gpgme.h hcachever.sh.in michael@478: + snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in michael@478: michael@478: EXTRA_SCRIPTS = smime_keys michael@478: mutt_dotlock_SOURCES = mutt_dotlock.c michael@478: Index: OPS michael@478: --- OPS.orig 2010-03-01 18:56:19.000000000 +0100 michael@478: +++ OPS 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -179,3 +179,8 @@ michael@478: OP_MAIN_SHOW_LIMIT "show currently active limit pattern" michael@478: OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" michael@478: OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" michael@478: +OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" michael@478: +OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" michael@478: +OP_SIDEBAR_NEXT "go down to next mailbox" michael@478: +OP_SIDEBAR_PREV "go to previous mailbox" michael@478: +OP_SIDEBAR_OPEN "open hilighted mailbox" michael@478: Index: buffy.c michael@478: --- buffy.c.orig 2010-09-13 19:19:55.000000000 +0200 michael@478: +++ buffy.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -312,6 +312,10 @@ michael@478: return 0; michael@478: } michael@478: michael@478: + mailbox->msgcount = 0; michael@478: + mailbox->msg_unread = 0; michael@478: + mailbox->msg_flagged = 0; michael@478: + michael@478: while ((de = readdir (dirp)) != NULL) michael@478: { michael@478: if (*de->d_name == '.') michael@478: @@ -329,7 +333,9 @@ michael@478: continue; michael@478: } michael@478: /* one new and undeleted message is enough */ michael@478: - mailbox->new = 1; michael@478: + mailbox->has_new = mailbox->new = 1; michael@478: + mailbox->msgcount++; michael@478: + mailbox->msg_unread++; michael@478: rc = 1; michael@478: break; michael@478: } michael@478: @@ -337,6 +343,32 @@ michael@478: michael@478: closedir (dirp); michael@478: michael@478: + /* michael@478: + * count read messages (for folderlist (sidebar) we also need to count michael@478: + * messages in cur so that we the total number of messages michael@478: + */ michael@478: + snprintf (path, sizeof (path), "%s/cur", mailbox->path); michael@478: + if ((dirp = opendir (path)) == NULL) michael@478: + { michael@478: + mailbox->magic = 0; michael@478: + } michael@478: + while ((de = readdir (dirp)) != NULL) michael@478: + { michael@478: + char *p; michael@478: + if (*de->d_name != '.') { michael@478: + if ((p = strstr (de->d_name, ":2,"))) { michael@478: + if (!strchr (p + 3, 'T')) { michael@478: + mailbox->msgcount++; michael@478: + if ( !strchr (p + 3, 'S')) michael@478: + mailbox->msg_unread++; michael@478: + if (strchr(p + 3, 'F')) michael@478: + mailbox->msg_flagged++; michael@478: + } michael@478: + } else michael@478: + mailbox->msgcount++; michael@478: + } michael@478: + } michael@478: + michael@478: return rc; michael@478: } michael@478: michael@478: @@ -345,14 +377,33 @@ michael@478: { michael@478: int rc = 0; michael@478: int statcheck; michael@478: + CONTEXT *ctx; michael@478: michael@478: if (option (OPTCHECKMBOXSIZE)) michael@478: statcheck = sb->st_size > mailbox->size; michael@478: else michael@478: statcheck = sb->st_mtime > sb->st_atime michael@478: || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime); michael@478: - if (statcheck) michael@478: + if (statcheck || mailbox->msgcount == 0) michael@478: { michael@478: + BUFFY b = *mailbox; michael@478: + int msgcount = 0; michael@478: + int msg_unread = 0; michael@478: + /* parse the mailbox, to see how much mail there is */ michael@478: + ctx = mx_open_mailbox( mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); michael@478: + if(ctx) michael@478: + { michael@478: + msgcount = ctx->msgcount; michael@478: + msg_unread = ctx->unread; michael@478: + mx_close_mailbox(ctx, 0); michael@478: + } michael@478: + *mailbox = b; michael@478: + mailbox->msgcount = msgcount; michael@478: + mailbox->msg_unread = msg_unread; michael@478: + if(statcheck) michael@478: + { michael@478: + mailbox->has_new = mailbox->new = 1; michael@478: + } michael@478: if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited) michael@478: { michael@478: rc = 1; michael@478: @@ -374,9 +425,11 @@ michael@478: int mutt_buffy_check (int force) michael@478: { michael@478: BUFFY *tmp; michael@478: + struct dirent *de, *dp; michael@478: struct stat sb; michael@478: struct stat contex_sb; michael@478: time_t t; michael@478: + CONTEXT *ctx; michael@478: michael@478: sb.st_size=0; michael@478: contex_sb.st_dev=0; michael@478: @@ -456,6 +509,20 @@ michael@478: case M_MH: michael@478: if ((tmp->new = mh_buffy (tmp->path)) > 0) michael@478: BuffyCount++; michael@478: + michael@478: + if ((dp = opendir (tmp->path)) == NULL) michael@478: + break; michael@478: + tmp->msgcount = 0; michael@478: + while ((de = readdir (dp))) michael@478: + { michael@478: + if (mh_valid_message (de->d_name)) michael@478: + { michael@478: + tmp->msgcount++; michael@478: + tmp->has_new = tmp->new = 1; michael@478: + } michael@478: + } michael@478: + closedir (dp); michael@478: + michael@478: break; michael@478: } michael@478: } michael@478: Index: buffy.h michael@478: --- buffy.h.orig 2010-09-13 19:19:55.000000000 +0200 michael@478: +++ buffy.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -25,7 +25,12 @@ michael@478: char path[_POSIX_PATH_MAX]; michael@478: off_t size; michael@478: struct buffy_t *next; michael@478: + struct buffy_t *prev; michael@478: short new; /* mailbox has new mail */ michael@478: + short has_new; /* set it new if new and not read */ michael@478: + int msgcount; /* total number of messages */ michael@478: + int msg_unread; /* number of unread messages */ michael@478: + int msg_flagged; /* number of flagged messages */ michael@478: short notified; /* user has been notified */ michael@478: short magic; /* mailbox type */ michael@478: short newly_created; /* mbox or mmdf just popped into existence */ michael@478: Index: color.c michael@478: --- color.c.orig 2009-05-15 19:18:23.000000000 +0200 michael@478: +++ color.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -93,6 +93,8 @@ michael@478: { "bold", MT_COLOR_BOLD }, michael@478: { "underline", MT_COLOR_UNDERLINE }, michael@478: { "index", MT_COLOR_INDEX }, michael@478: + { "sidebar_new", MT_COLOR_NEW }, michael@478: + { "sidebar_flagged", MT_COLOR_FLAGGED }, michael@478: { NULL, 0 } michael@478: }; michael@478: michael@478: Index: compose.c michael@478: --- compose.c.orig 2010-04-14 20:50:19.000000000 +0200 michael@478: +++ compose.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -72,7 +72,7 @@ michael@478: michael@478: #define HDR_XOFFSET 10 michael@478: #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ michael@478: -#define W (COLS - HDR_XOFFSET) michael@478: +#define W (COLS - HDR_XOFFSET - SidebarWidth) michael@478: michael@478: static char *Prompts[] = michael@478: { michael@478: @@ -112,7 +112,7 @@ michael@478: { michael@478: int off = 0; michael@478: michael@478: - mvaddstr (HDR_CRYPT, 0, "Security: "); michael@478: + mvaddstr (HDR_CRYPT, SidebarWidth, "Security: "); michael@478: michael@478: if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) michael@478: { michael@478: @@ -144,7 +144,7 @@ michael@478: } michael@478: michael@478: clrtoeol (); michael@478: - move (HDR_CRYPTINFO, 0); michael@478: + move (HDR_CRYPTINFO, SidebarWidth); michael@478: clrtoeol (); michael@478: michael@478: if ((WithCrypto & APPLICATION_PGP) michael@478: @@ -161,7 +161,7 @@ michael@478: && (msg->security & ENCRYPT) michael@478: && SmimeCryptAlg michael@478: && *SmimeCryptAlg) { michael@478: - mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), michael@478: + mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "), michael@478: NONULL(SmimeCryptAlg)); michael@478: off = 20; michael@478: } michael@478: @@ -175,7 +175,7 @@ michael@478: int c; michael@478: char *t; michael@478: michael@478: - mvaddstr (HDR_MIX, 0, " Mix: "); michael@478: + mvaddstr (HDR_MIX, SidebarWidth, " Mix: "); michael@478: michael@478: if (!chain) michael@478: { michael@478: @@ -190,7 +190,7 @@ michael@478: if (t && t[0] == '0' && t[1] == '\0') michael@478: t = ""; michael@478: michael@478: - if (c + mutt_strlen (t) + 2 >= COLS) michael@478: + if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth) michael@478: break; michael@478: michael@478: addstr (NONULL(t)); michael@478: @@ -242,7 +242,7 @@ michael@478: michael@478: buf[0] = 0; michael@478: rfc822_write_address (buf, sizeof (buf), addr, 1); michael@478: - mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); michael@478: + mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]); michael@478: mutt_paddstr (W, buf); michael@478: } michael@478: michael@478: @@ -252,10 +252,10 @@ michael@478: draw_envelope_addr (HDR_TO, msg->env->to); michael@478: draw_envelope_addr (HDR_CC, msg->env->cc); michael@478: draw_envelope_addr (HDR_BCC, msg->env->bcc); michael@478: - mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); michael@478: + mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); michael@478: mutt_paddstr (W, NONULL (msg->env->subject)); michael@478: draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); michael@478: - mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]); michael@478: + mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]); michael@478: mutt_paddstr (W, fcc); michael@478: michael@478: if (WithCrypto) michael@478: @@ -266,7 +266,7 @@ michael@478: #endif michael@478: michael@478: SETCOLOR (MT_COLOR_STATUS); michael@478: - mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); michael@478: + mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments")); michael@478: BKGDSET (MT_COLOR_STATUS); michael@478: clrtoeol (); michael@478: michael@478: @@ -304,7 +304,7 @@ michael@478: /* redraw the expanded list so the user can see the result */ michael@478: buf[0] = 0; michael@478: rfc822_write_address (buf, sizeof (buf), *addr, 1); michael@478: - move (line, HDR_XOFFSET); michael@478: + move (line, HDR_XOFFSET+SidebarWidth); michael@478: mutt_paddstr (W, buf); michael@478: michael@478: return 0; michael@478: @@ -549,7 +549,7 @@ michael@478: if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) michael@478: { michael@478: mutt_str_replace (&msg->env->subject, buf); michael@478: - move (HDR_SUBJECT, HDR_XOFFSET); michael@478: + move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth); michael@478: clrtoeol (); michael@478: if (msg->env->subject) michael@478: mutt_paddstr (W, msg->env->subject); michael@478: @@ -566,7 +566,7 @@ michael@478: { michael@478: strfcpy (fcc, buf, fcclen); michael@478: mutt_pretty_mailbox (fcc, fcclen); michael@478: - move (HDR_FCC, HDR_XOFFSET); michael@478: + move (HDR_FCC, HDR_XOFFSET + SidebarWidth); michael@478: mutt_paddstr (W, fcc); michael@478: fccSet = 1; michael@478: } michael@478: Index: curs_main.c michael@478: --- curs_main.c.orig 2010-09-13 19:19:55.000000000 +0200 michael@478: +++ curs_main.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -26,7 +26,9 @@ michael@478: #include "mailbox.h" michael@478: #include "mapping.h" michael@478: #include "sort.h" michael@478: +#include "buffy.h" michael@478: #include "mx.h" michael@478: +#include "sidebar.h" michael@478: michael@478: #ifdef USE_POP michael@478: #include "pop.h" michael@478: @@ -519,8 +521,12 @@ michael@478: menu->redraw |= REDRAW_STATUS; michael@478: if (do_buffy_notify) michael@478: { michael@478: - if (mutt_buffy_notify () && option (OPTBEEPNEW)) michael@478: - beep (); michael@478: + if (mutt_buffy_notify ()) michael@478: + { michael@478: + menu->redraw |= REDRAW_FULL; michael@478: + if (option (OPTBEEPNEW)) michael@478: + beep (); michael@478: + } michael@478: } michael@478: else michael@478: do_buffy_notify = 1; michael@478: @@ -532,6 +538,7 @@ michael@478: if (menu->redraw & REDRAW_FULL) michael@478: { michael@478: menu_redraw_full (menu); michael@478: + draw_sidebar(menu->menu); michael@478: mutt_show_error (); michael@478: } michael@478: michael@478: @@ -554,10 +561,13 @@ michael@478: michael@478: if (menu->redraw & REDRAW_STATUS) michael@478: { michael@478: + DrawFullLine = 1; michael@478: menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); michael@478: + DrawFullLine = 0; michael@478: CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2); michael@478: SETCOLOR (MT_COLOR_STATUS); michael@478: BKGDSET (MT_COLOR_STATUS); michael@478: + set_buffystats(Context); michael@478: mutt_paddstr (COLS, buf); michael@478: SETCOLOR (MT_COLOR_NORMAL); michael@478: BKGDSET (MT_COLOR_NORMAL); michael@478: @@ -571,7 +581,7 @@ michael@478: menu->oldcurrent = -1; michael@478: michael@478: if (option (OPTARROWCURSOR)) michael@478: - move (menu->current - menu->top + menu->offset, 2); michael@478: + move (menu->current - menu->top + menu->offset, SidebarWidth + 2); michael@478: else if (option (OPTBRAILLEFRIENDLY)) michael@478: move (menu->current - menu->top + menu->offset, 0); michael@478: else michael@478: @@ -1069,6 +1079,7 @@ michael@478: menu->redraw = REDRAW_FULL; michael@478: break; michael@478: michael@478: + case OP_SIDEBAR_OPEN: michael@478: case OP_MAIN_CHANGE_FOLDER: michael@478: case OP_MAIN_NEXT_UNREAD_MAILBOX: michael@478: michael@478: @@ -1100,7 +1111,11 @@ michael@478: { michael@478: mutt_buffy (buf, sizeof (buf)); michael@478: michael@478: - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) michael@478: + if ( op == OP_SIDEBAR_OPEN ) { michael@478: + if(!CurBuffy) michael@478: + break; michael@478: + strncpy( buf, CurBuffy->path, sizeof(buf) ); michael@478: + } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) michael@478: { michael@478: if (menu->menu == MENU_PAGER) michael@478: { michael@478: @@ -1118,6 +1133,7 @@ michael@478: } michael@478: michael@478: mutt_expand_path (buf, sizeof (buf)); michael@478: + set_curbuffy(buf); michael@478: if (mx_get_magic (buf) <= 0) michael@478: { michael@478: mutt_error (_("%s is not a mailbox."), buf); michael@478: @@ -2208,6 +2224,12 @@ michael@478: mutt_what_key(); michael@478: break; michael@478: michael@478: + case OP_SIDEBAR_SCROLL_UP: michael@478: + case OP_SIDEBAR_SCROLL_DOWN: michael@478: + case OP_SIDEBAR_NEXT: michael@478: + case OP_SIDEBAR_PREV: michael@478: + scroll_sidebar(op, menu->menu); michael@478: + break; michael@478: default: michael@478: if (menu->menu == MENU_MAIN) michael@478: km_error_key (MENU_MAIN); michael@478: Index: doc/Muttrc michael@478: --- doc/Muttrc.orig 2010-09-15 19:07:19.000000000 +0200 michael@478: +++ doc/Muttrc 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -657,6 +657,26 @@ michael@478: # $crypt_autosign, $crypt_replysign and $smime_is_default. michael@478: # michael@478: # michael@478: +# set sidebar_visible=no michael@478: +# michael@478: +# Name: sidebar_visible michael@478: +# Type: boolean michael@478: +# Default: no michael@478: +# michael@478: +# michael@478: +# This specifies whether or not to show sidebar (left-side list of folders). michael@478: +# michael@478: +# michael@478: +# set sidebar_width=0 michael@478: +# michael@478: +# Name: sidebar_width michael@478: +# Type: number michael@478: +# Default: 0 michael@478: +# michael@478: +# michael@478: +# The width of the sidebar. michael@478: +# michael@478: +# michael@478: # set crypt_autosign=no michael@478: # michael@478: # Name: crypt_autosign michael@478: Index: flags.c michael@478: --- flags.c.orig 2009-01-04 00:27:10.000000000 +0100 michael@478: +++ flags.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -22,8 +22,10 @@ michael@478: michael@478: #include "mutt.h" michael@478: #include "mutt_curses.h" michael@478: +#include "mutt_menu.h" michael@478: #include "sort.h" michael@478: #include "mx.h" michael@478: +#include "sidebar.h" michael@478: michael@478: void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) michael@478: { michael@478: @@ -263,6 +265,7 @@ michael@478: */ michael@478: if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) michael@478: h->searched = 0; michael@478: + draw_sidebar(0); michael@478: } michael@478: michael@478: void mutt_tag_set_flag (int flag, int bf) michael@478: Index: functions.h michael@478: --- functions.h.orig 2010-08-24 18:34:21.000000000 +0200 michael@478: +++ functions.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -169,6 +169,11 @@ michael@478: { "decrypt-save", OP_DECRYPT_SAVE, NULL }, michael@478: michael@478: michael@478: + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, michael@478: + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, michael@478: + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, michael@478: + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, michael@478: + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, michael@478: { NULL, 0, NULL } michael@478: }; michael@478: michael@478: @@ -272,6 +277,11 @@ michael@478: michael@478: { "what-key", OP_WHAT_KEY, NULL }, michael@478: michael@478: + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, michael@478: + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, michael@478: + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, michael@478: + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, michael@478: + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, michael@478: { NULL, 0, NULL } michael@478: }; michael@478: michael@478: Index: globals.h michael@478: --- globals.h.orig 2009-08-25 21:08:52.000000000 +0200 michael@478: +++ globals.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -117,6 +117,7 @@ michael@478: WHERE char *SendCharset; michael@478: WHERE char *Sendmail; michael@478: WHERE char *Shell; michael@478: +WHERE char *SidebarDelim; michael@478: WHERE char *Signature; michael@478: WHERE char *SimpleSearch; michael@478: #if USE_SMTP michael@478: @@ -207,6 +208,9 @@ michael@478: WHERE short ScoreThresholdRead; michael@478: WHERE short ScoreThresholdFlag; michael@478: michael@478: +WHERE struct buffy_t *CurBuffy INITVAL(0); michael@478: +WHERE short DrawFullLine INITVAL(0); michael@478: +WHERE short SidebarWidth; michael@478: #ifdef USE_IMAP michael@478: WHERE short ImapKeepalive; michael@478: WHERE short ImapPipelineDepth; michael@478: Index: imap/command.c michael@478: --- imap/command.c.orig 2010-09-15 17:39:31.000000000 +0200 michael@478: +++ imap/command.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -1011,6 +1011,13 @@ michael@478: opened */ michael@478: status->uidnext = oldun; michael@478: michael@478: + /* Added to make the sidebar show the correct numbers */ michael@478: + if (status->messages) michael@478: + { michael@478: + inc->msgcount = status->messages; michael@478: + inc->msg_unread = status->unseen; michael@478: + } michael@478: + michael@478: FREE (&value); michael@478: return; michael@478: } michael@478: Index: imap/imap.c michael@478: --- imap/imap.c.orig 2009-08-25 21:08:52.000000000 +0200 michael@478: +++ imap/imap.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -1521,7 +1521,7 @@ michael@478: michael@478: imap_munge_mbox_name (munged, sizeof (munged), name); michael@478: snprintf (command, sizeof (command), michael@478: - "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); michael@478: + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); michael@478: michael@478: if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) michael@478: { michael@478: Index: init.h michael@478: --- init.h.orig 2010-09-15 17:39:31.000000000 +0200 michael@478: +++ init.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -1953,6 +1953,22 @@ michael@478: ** not used. michael@478: ** (PGP only) michael@478: */ michael@478: + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, michael@478: + /* michael@478: + ** .pp michael@478: + ** This specifies the delimiter between the sidebar (if visible) and michael@478: + ** other screens. michael@478: + */ michael@478: + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, michael@478: + /* michael@478: + ** .pp michael@478: + ** This specifies whether or not to show sidebar (left-side list of folders). michael@478: + */ michael@478: + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, michael@478: + /* michael@478: + ** .pp michael@478: + ** The width of the sidebar. michael@478: + */ michael@478: { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, michael@478: /* michael@478: ** .pp michael@478: Index: mailbox.h michael@478: --- mailbox.h.orig 2009-04-30 19:33:48.000000000 +0200 michael@478: +++ mailbox.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -27,6 +27,7 @@ michael@478: #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses michael@478: * safe_fopen() for mbox-style folders. michael@478: */ michael@478: +#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ michael@478: michael@478: /* mx_open_new_message() */ michael@478: #define M_ADD_FROM 1 /* add a From_ line */ michael@478: Index: mbox.c michael@478: --- mbox.c.orig 2010-09-13 19:19:55.000000000 +0200 michael@478: +++ mbox.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -100,6 +100,7 @@ michael@478: mutt_perror (ctx->path); michael@478: return (-1); michael@478: } michael@478: + ctx->atime = sb.st_atime; michael@478: ctx->mtime = sb.st_mtime; michael@478: ctx->size = sb.st_size; michael@478: michael@478: @@ -251,6 +252,7 @@ michael@478: michael@478: ctx->size = sb.st_size; michael@478: ctx->mtime = sb.st_mtime; michael@478: + ctx->atime = sb.st_atime; michael@478: michael@478: #ifdef NFS_ATTRIBUTE_HACK michael@478: if (sb.st_mtime > sb.st_atime) michael@478: Index: menu.c michael@478: --- menu.c.orig 2010-08-25 18:31:40.000000000 +0200 michael@478: +++ menu.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -24,6 +24,7 @@ michael@478: #include "mutt_curses.h" michael@478: #include "mutt_menu.h" michael@478: #include "mbyte.h" michael@478: +#include "sidebar.h" michael@478: michael@478: #include michael@478: #include michael@478: @@ -156,7 +157,7 @@ michael@478: { michael@478: char *scratch = safe_strdup (s); michael@478: int shift = option (OPTARROWCURSOR) ? 3 : 0; michael@478: - int cols = COLS - shift; michael@478: + int cols = COLS - shift - SidebarWidth; michael@478: michael@478: mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); michael@478: s[n - 1] = 0; michael@478: @@ -207,6 +208,7 @@ michael@478: char buf[LONG_STRING]; michael@478: int i; michael@478: michael@478: + draw_sidebar(1); michael@478: for (i = menu->top; i < menu->top + menu->pagelen; i++) michael@478: { michael@478: if (i < menu->max) michael@478: @@ -217,7 +219,7 @@ michael@478: if (option (OPTARROWCURSOR)) michael@478: { michael@478: attrset (menu->color (i)); michael@478: - CLEARLINE (i - menu->top + menu->offset); michael@478: + CLEARLINE_WIN (i - menu->top + menu->offset); michael@478: michael@478: if (i == menu->current) michael@478: { michael@478: @@ -246,14 +248,14 @@ michael@478: BKGDSET (MT_COLOR_INDICATOR); michael@478: } michael@478: michael@478: - CLEARLINE (i - menu->top + menu->offset); michael@478: + CLEARLINE_WIN (i - menu->top + menu->offset); michael@478: print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); michael@478: SETCOLOR (MT_COLOR_NORMAL); michael@478: BKGDSET (MT_COLOR_NORMAL); michael@478: } michael@478: } michael@478: else michael@478: - CLEARLINE (i - menu->top + menu->offset); michael@478: + CLEARLINE_WIN (i - menu->top + menu->offset); michael@478: } michael@478: menu->redraw = 0; michael@478: } michael@478: @@ -268,7 +270,7 @@ michael@478: return; michael@478: } michael@478: michael@478: - move (menu->oldcurrent + menu->offset - menu->top, 0); michael@478: + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); michael@478: SETCOLOR (MT_COLOR_NORMAL); michael@478: BKGDSET (MT_COLOR_NORMAL); michael@478: michael@478: @@ -283,13 +285,13 @@ michael@478: clrtoeol (); michael@478: menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); michael@478: menu_pad_string (buf, sizeof (buf)); michael@478: - move (menu->oldcurrent + menu->offset - menu->top, 3); michael@478: + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); michael@478: print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); michael@478: SETCOLOR (MT_COLOR_NORMAL); michael@478: } michael@478: michael@478: /* now draw it in the new location */ michael@478: - move (menu->current + menu->offset - menu->top, 0); michael@478: + move (menu->current + menu->offset - menu->top, SidebarWidth); michael@478: attrset (menu->color (menu->current)); michael@478: ADDCOLOR (MT_COLOR_INDICATOR); michael@478: addstr ("->"); michael@478: @@ -310,7 +312,7 @@ michael@478: attrset (menu->color (menu->current)); michael@478: ADDCOLOR (MT_COLOR_INDICATOR); michael@478: BKGDSET (MT_COLOR_INDICATOR); michael@478: - CLEARLINE (menu->current - menu->top + menu->offset); michael@478: + CLEARLINE_WIN (menu->current - menu->top + menu->offset); michael@478: print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); michael@478: SETCOLOR (MT_COLOR_NORMAL); michael@478: BKGDSET (MT_COLOR_NORMAL); michael@478: @@ -322,7 +324,7 @@ michael@478: { michael@478: char buf[LONG_STRING]; michael@478: michael@478: - move (menu->current + menu->offset - menu->top, 0); michael@478: + move (menu->current + menu->offset - menu->top, SidebarWidth); michael@478: menu_make_entry (buf, sizeof (buf), menu, menu->current); michael@478: menu_pad_string (buf, sizeof (buf)); michael@478: michael@478: @@ -875,7 +877,7 @@ michael@478: michael@478: michael@478: if (option (OPTARROWCURSOR)) michael@478: - move (menu->current - menu->top + menu->offset, 2); michael@478: + move (menu->current - menu->top + menu->offset, SidebarWidth + 2); michael@478: else if (option (OPTBRAILLEFRIENDLY)) michael@478: move (menu->current - menu->top + menu->offset, 0); michael@478: else michael@478: Index: mutt.h michael@478: --- mutt.h.orig 2010-09-13 19:19:55.000000000 +0200 michael@478: +++ mutt.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -419,6 +419,7 @@ michael@478: OPTSAVEEMPTY, michael@478: OPTSAVENAME, michael@478: OPTSCORE, michael@478: + OPTSIDEBAR, michael@478: OPTSIGDASHES, michael@478: OPTSIGONTOP, michael@478: OPTSORTRE, michael@478: @@ -859,6 +860,7 @@ michael@478: { michael@478: char *path; michael@478: FILE *fp; michael@478: + time_t atime; michael@478: time_t mtime; michael@478: off_t size; michael@478: off_t vsize; michael@478: @@ -893,6 +895,7 @@ michael@478: unsigned int quiet : 1; /* inhibit status messages? */ michael@478: unsigned int collapsed : 1; /* are all threads collapsed? */ michael@478: unsigned int closing : 1; /* mailbox is being closed */ michael@478: + unsigned int peekonly : 1; /* just taking a glance, revert atime */ michael@478: michael@478: /* driver hooks */ michael@478: void *data; /* driver specific data */ michael@478: Index: mutt_curses.h michael@478: --- mutt_curses.h.orig 2008-03-19 21:07:57.000000000 +0100 michael@478: +++ mutt_curses.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -64,6 +64,7 @@ michael@478: #undef lines michael@478: #endif /* lines */ michael@478: michael@478: +#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() michael@478: #define CLEARLINE(x) move(x,0), clrtoeol() michael@478: #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) michael@478: #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) michael@478: @@ -126,6 +127,8 @@ michael@478: MT_COLOR_BOLD, michael@478: MT_COLOR_UNDERLINE, michael@478: MT_COLOR_INDEX, michael@478: + MT_COLOR_NEW, michael@478: + MT_COLOR_FLAGGED, michael@478: MT_COLOR_MAX michael@478: }; michael@478: michael@478: Index: muttlib.c michael@478: --- muttlib.c.orig 2010-08-25 18:31:40.000000000 +0200 michael@478: +++ muttlib.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -1286,6 +1286,8 @@ michael@478: pl = pw = 1; michael@478: michael@478: /* see if there's room to add content, else ignore */ michael@478: + if ( DrawFullLine ) michael@478: + { michael@478: if ((col < COLS && wlen < destlen) || soft) michael@478: { michael@478: int pad; michael@478: @@ -1329,6 +1331,52 @@ michael@478: col += wid; michael@478: src += pl; michael@478: } michael@478: + } michael@478: + else michael@478: + { michael@478: + if ((col < COLS-SidebarWidth && wlen < destlen) || soft) michael@478: + { michael@478: + int pad; michael@478: + michael@478: + /* get contents after padding */ michael@478: + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); michael@478: + len = mutt_strlen (buf); michael@478: + wid = mutt_strwidth (buf); michael@478: + michael@478: + /* try to consume as many columns as we can, if we don't have michael@478: + * memory for that, use as much memory as possible */ michael@478: + pad = (COLS - SidebarWidth - col - wid) / pw; michael@478: + if (pad > 0 && wlen + (pad * pl) + len > destlen) michael@478: + pad = ((signed)(destlen - wlen - len)) / pl; michael@478: + if (pad > 0) michael@478: + { michael@478: + while (pad--) michael@478: + { michael@478: + memcpy (wptr, src, pl); michael@478: + wptr += pl; michael@478: + wlen += pl; michael@478: + col += pw; michael@478: + } michael@478: + } michael@478: + else if (soft && pad < 0) michael@478: + { michael@478: + /* \0-terminate dest for length computation in mutt_wstr_trunc() */ michael@478: + *wptr = 0; michael@478: + /* make sure right part is at most as wide as display */ michael@478: + len = mutt_wstr_trunc (buf, destlen, COLS, &wid); michael@478: + /* truncate left so that right part fits completely in */ michael@478: + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); michael@478: + wptr = dest + wlen; michael@478: + } michael@478: + if (len + wlen > destlen) michael@478: + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); michael@478: + memcpy (wptr, buf, len); michael@478: + wptr += len; michael@478: + wlen += len; michael@478: + col += wid; michael@478: + src += pl; michael@478: + } michael@478: + } michael@478: break; /* skip rest of input */ michael@478: } michael@478: else if (ch == '|') michael@478: Index: mx.c michael@478: --- mx.c.orig 2010-09-13 19:19:55.000000000 +0200 michael@478: +++ mx.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -580,6 +580,7 @@ michael@478: * M_APPEND open mailbox for appending michael@478: * M_READONLY open mailbox in read-only mode michael@478: * M_QUIET only print error messages michael@478: + * M_PEEK revert atime where applicable michael@478: * ctx if non-null, context struct to use michael@478: */ michael@478: CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) michael@478: @@ -602,6 +603,8 @@ michael@478: ctx->quiet = 1; michael@478: if (flags & M_READONLY) michael@478: ctx->readonly = 1; michael@478: + if (flags & M_PEEK) michael@478: + ctx->peekonly = 1; michael@478: michael@478: if (flags & (M_APPEND|M_NEWFOLDER)) michael@478: { michael@478: @@ -701,9 +704,21 @@ michael@478: void mx_fastclose_mailbox (CONTEXT *ctx) michael@478: { michael@478: int i; michael@478: +#ifndef BUFFY_SIZE michael@478: + struct utimbuf ut; michael@478: +#endif michael@478: michael@478: if(!ctx) michael@478: return; michael@478: +#ifndef BUFFY_SIZE michael@478: + /* fix up the times so buffy won't get confused */ michael@478: + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) michael@478: + { michael@478: + ut.actime = ctx->atime; michael@478: + ut.modtime = ctx->mtime; michael@478: + utime (ctx->path, &ut); michael@478: + } michael@478: +#endif michael@478: michael@478: /* never announce that a mailbox we've just left has new mail. #3290 michael@478: * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ michael@478: Index: pager.c michael@478: --- pager.c.orig 2010-08-25 18:31:40.000000000 +0200 michael@478: +++ pager.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -29,6 +29,7 @@ michael@478: #include "pager.h" michael@478: #include "attach.h" michael@478: #include "mbyte.h" michael@478: +#include "sidebar.h" michael@478: michael@478: #include "mutt_crypt.h" michael@478: michael@478: @@ -1099,6 +1100,7 @@ michael@478: if (check_attachment_marker ((char *)buf) == 0) michael@478: wrap_cols = COLS; michael@478: michael@478: + wrap_cols -= SidebarWidth; michael@478: /* FIXME: this should come from lineInfo */ michael@478: memset(&mbstate, 0, sizeof(mbstate)); michael@478: michael@478: @@ -1745,7 +1747,7 @@ michael@478: if ((redraw & REDRAW_BODY) || topline != oldtopline) michael@478: { michael@478: do { michael@478: - move (bodyoffset, 0); michael@478: + move (bodyoffset, SidebarWidth); michael@478: curline = oldtopline = topline; michael@478: lines = 0; michael@478: force_redraw = 0; michael@478: @@ -1758,6 +1760,7 @@ michael@478: &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) michael@478: lines++; michael@478: curline++; michael@478: + move(lines + bodyoffset, SidebarWidth); michael@478: } michael@478: last_offset = lineInfo[curline].offset; michael@478: } while (force_redraw); michael@478: @@ -1771,6 +1774,7 @@ michael@478: addch ('~'); michael@478: addch ('\n'); michael@478: lines++; michael@478: + move(lines + bodyoffset, SidebarWidth); michael@478: } michael@478: /* We are going to update the pager status bar, so it isn't michael@478: * necessary to reset to normal color now. */ michael@478: @@ -1794,11 +1798,11 @@ michael@478: /* print out the pager status bar */ michael@478: SETCOLOR (MT_COLOR_STATUS); michael@478: BKGDSET (MT_COLOR_STATUS); michael@478: - CLEARLINE (statusoffset); michael@478: + CLEARLINE_WIN (statusoffset); michael@478: michael@478: if (IsHeader (extra) || IsMsgAttach (extra)) michael@478: { michael@478: - size_t l1 = COLS * MB_LEN_MAX; michael@478: + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; michael@478: size_t l2 = sizeof (buffer); michael@478: hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; michael@478: mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); michael@478: @@ -1808,7 +1812,7 @@ michael@478: { michael@478: char bn[STRING]; michael@478: snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); michael@478: - mutt_paddstr (COLS, bn); michael@478: + mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner); michael@478: } michael@478: BKGDSET (MT_COLOR_NORMAL); michael@478: SETCOLOR (MT_COLOR_NORMAL); michael@478: @@ -1819,18 +1823,23 @@ michael@478: /* redraw the pager_index indicator, because the michael@478: * flags for this message might have changed. */ michael@478: menu_redraw_current (index); michael@478: + draw_sidebar(MENU_PAGER); michael@478: michael@478: /* print out the index status bar */ michael@478: menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); michael@478: michael@478: - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); michael@478: + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); michael@478: SETCOLOR (MT_COLOR_STATUS); michael@478: BKGDSET (MT_COLOR_STATUS); michael@478: - mutt_paddstr (COLS, buffer); michael@478: + mutt_paddstr (COLS-SidebarWidth, buffer); michael@478: SETCOLOR (MT_COLOR_NORMAL); michael@478: BKGDSET (MT_COLOR_NORMAL); michael@478: } michael@478: michael@478: + /* if we're not using the index, update every time */ michael@478: + if ( index == 0 ) michael@478: + draw_sidebar(MENU_PAGER); michael@478: + michael@478: redraw = 0; michael@478: michael@478: if (option(OPTBRAILLEFRIENDLY)) { michael@478: @@ -2756,6 +2765,13 @@ michael@478: mutt_what_key (); michael@478: break; michael@478: michael@478: + case OP_SIDEBAR_SCROLL_UP: michael@478: + case OP_SIDEBAR_SCROLL_DOWN: michael@478: + case OP_SIDEBAR_NEXT: michael@478: + case OP_SIDEBAR_PREV: michael@478: + scroll_sidebar(ch, MENU_PAGER); michael@478: + break; michael@478: + michael@478: default: michael@478: ch = -1; michael@478: break; michael@478: Index: sidebar.c michael@478: --- sidebar.c.orig 2011-01-17 19:33:15.000000000 +0100 michael@478: +++ sidebar.c 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -0,0 +1,333 @@ michael@478: +/* michael@478: + * Copyright (C) ????-2004 Justin Hibbits michael@478: + * Copyright (C) 2004 Thomer M. Gil michael@478: + * michael@478: + * This program is free software; you can redistribute it and/or modify michael@478: + * it under the terms of the GNU General Public License as published by michael@478: + * the Free Software Foundation; either version 2 of the License, or michael@478: + * (at your option) any later version. michael@478: + * michael@478: + * This program is distributed in the hope that it will be useful, michael@478: + * but WITHOUT ANY WARRANTY; without even the implied warranty of michael@478: + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the michael@478: + * GNU General Public License for more details. michael@478: + * michael@478: + * You should have received a copy of the GNU General Public License michael@478: + * along with this program; if not, write to the Free Software michael@478: + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. michael@478: + */ michael@478: + michael@478: + michael@478: +#if HAVE_CONFIG_H michael@478: +# include "config.h" michael@478: +#endif michael@478: + michael@478: +#include "mutt.h" michael@478: +#include "mutt_menu.h" michael@478: +#include "mutt_curses.h" michael@478: +#include "sidebar.h" michael@478: +#include "buffy.h" michael@478: +#include michael@478: +#include "keymap.h" michael@478: +#include michael@478: + michael@478: +/*BUFFY *CurBuffy = 0;*/ michael@478: +static BUFFY *TopBuffy = 0; michael@478: +static BUFFY *BottomBuffy = 0; michael@478: +static int known_lines = 0; michael@478: + michael@478: +static int quick_log10(int n) michael@478: +{ michael@478: + char string[32]; michael@478: + sprintf(string, "%d", n); michael@478: + return strlen(string); michael@478: +} michael@478: + michael@478: +void calc_boundaries (int menu) michael@478: +{ michael@478: + BUFFY *tmp = Incoming; michael@478: + michael@478: + if ( known_lines != LINES ) { michael@478: + TopBuffy = BottomBuffy = 0; michael@478: + known_lines = LINES; michael@478: + } michael@478: + for ( ; tmp->next != 0; tmp = tmp->next ) michael@478: + tmp->next->prev = tmp; michael@478: + michael@478: + if ( TopBuffy == 0 && BottomBuffy == 0 ) michael@478: + TopBuffy = Incoming; michael@478: + if ( BottomBuffy == 0 ) { michael@478: + int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); michael@478: + BottomBuffy = TopBuffy; michael@478: + while ( --count && BottomBuffy->next ) michael@478: + BottomBuffy = BottomBuffy->next; michael@478: + } michael@478: + else if ( TopBuffy == CurBuffy->next ) { michael@478: + int count = LINES - 2 - (menu != MENU_PAGER); michael@478: + BottomBuffy = CurBuffy; michael@478: + tmp = BottomBuffy; michael@478: + while ( --count && tmp->prev) michael@478: + tmp = tmp->prev; michael@478: + TopBuffy = tmp; michael@478: + } michael@478: + else if ( BottomBuffy == CurBuffy->prev ) { michael@478: + int count = LINES - 2 - (menu != MENU_PAGER); michael@478: + TopBuffy = CurBuffy; michael@478: + tmp = TopBuffy; michael@478: + while ( --count && tmp->next ) michael@478: + tmp = tmp->next; michael@478: + BottomBuffy = tmp; michael@478: + } michael@478: +} michael@478: + michael@478: +char *make_sidebar_entry(char *box, int size, int new, int flagged) michael@478: +{ michael@478: + static char *entry = 0; michael@478: + char *c; michael@478: + int i = 0; michael@478: + int delim_len = strlen(SidebarDelim); michael@478: + michael@478: + c = realloc(entry, SidebarWidth - delim_len + 2); michael@478: + if ( c ) entry = c; michael@478: + entry[SidebarWidth - delim_len + 1] = 0; michael@478: + for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); michael@478: + i = strlen(box); michael@478: + strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); michael@478: + michael@478: + if (size == -1) michael@478: + sprintf(entry + SidebarWidth - delim_len - 3, "?"); michael@478: + else if ( new ) { michael@478: + if (flagged > 0) { michael@478: + sprintf( michael@478: + entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), michael@478: + "% d(%d)[%d]", size, new, flagged); michael@478: + } else { michael@478: + sprintf( michael@478: + entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), michael@478: + "% d(%d)", size, new); michael@478: + } michael@478: + } else if (flagged > 0) { michael@478: + sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); michael@478: + } else { michael@478: + sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); michael@478: + } michael@478: + return entry; michael@478: +} michael@478: + michael@478: +void set_curbuffy(char buf[LONG_STRING]) michael@478: +{ michael@478: + BUFFY* tmp = CurBuffy = Incoming; michael@478: + michael@478: + if (!Incoming) michael@478: + return; michael@478: + michael@478: + while(1) { michael@478: + if(!strcmp(tmp->path, buf)) { michael@478: + CurBuffy = tmp; michael@478: + break; michael@478: + } michael@478: + michael@478: + if(tmp->next) michael@478: + tmp = tmp->next; michael@478: + else michael@478: + break; michael@478: + } michael@478: +} michael@478: + michael@478: +int draw_sidebar(int menu) { michael@478: + michael@478: + int lines = option(OPTHELP) ? 1 : 0; michael@478: + BUFFY *tmp; michael@478: +#ifndef USE_SLANG_CURSES michael@478: + attr_t attrs; michael@478: +#endif michael@478: + short delim_len = strlen(SidebarDelim); michael@478: + short color_pair; michael@478: + michael@478: + static bool initialized = false; michael@478: + static int prev_show_value; michael@478: + static short saveSidebarWidth; michael@478: + michael@478: + /* initialize first time */ michael@478: + if(!initialized) { michael@478: + prev_show_value = option(OPTSIDEBAR); michael@478: + saveSidebarWidth = SidebarWidth; michael@478: + if(!option(OPTSIDEBAR)) SidebarWidth = 0; michael@478: + initialized = true; michael@478: + } michael@478: + michael@478: + /* save or restore the value SidebarWidth */ michael@478: + if(prev_show_value != option(OPTSIDEBAR)) { michael@478: + if(prev_show_value && !option(OPTSIDEBAR)) { michael@478: + saveSidebarWidth = SidebarWidth; michael@478: + SidebarWidth = 0; michael@478: + } else if(!prev_show_value && option(OPTSIDEBAR)) { michael@478: + SidebarWidth = saveSidebarWidth; michael@478: + } michael@478: + prev_show_value = option(OPTSIDEBAR); michael@478: + } michael@478: + michael@478: + michael@478: +// if ( SidebarWidth == 0 ) return 0; michael@478: + if (SidebarWidth > 0 && option (OPTSIDEBAR) michael@478: + && delim_len >= SidebarWidth) { michael@478: + unset_option (OPTSIDEBAR); michael@478: + /* saveSidebarWidth = SidebarWidth; */ michael@478: + if (saveSidebarWidth > delim_len) { michael@478: + SidebarWidth = saveSidebarWidth; michael@478: + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); michael@478: + sleep (2); michael@478: + } else { michael@478: + SidebarWidth = 0; michael@478: + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); michael@478: + sleep (4); /* the advise to set a sane value should be seen long enough */ michael@478: + } michael@478: + saveSidebarWidth = 0; michael@478: + return (0); michael@478: + } michael@478: + michael@478: + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { michael@478: + if (SidebarWidth > 0) { michael@478: + saveSidebarWidth = SidebarWidth; michael@478: + SidebarWidth = 0; michael@478: + } michael@478: + unset_option(OPTSIDEBAR); michael@478: + return 0; michael@478: + } michael@478: + michael@478: + /* get attributes for divider */ michael@478: + SETCOLOR(MT_COLOR_STATUS); michael@478: +#ifndef USE_SLANG_CURSES michael@478: + attr_get(&attrs, &color_pair, 0); michael@478: +#else michael@478: + color_pair = attr_get(); michael@478: +#endif michael@478: + SETCOLOR(MT_COLOR_NORMAL); michael@478: + michael@478: + /* draw the divider */ michael@478: + michael@478: + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { michael@478: + move(lines, SidebarWidth - delim_len); michael@478: + addstr(NONULL(SidebarDelim)); michael@478: +#ifndef USE_SLANG_CURSES michael@478: + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); michael@478: +#endif michael@478: + } michael@478: + michael@478: + if ( Incoming == 0 ) return 0; michael@478: + lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ michael@478: + michael@478: + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) michael@478: + calc_boundaries(menu); michael@478: + if ( CurBuffy == 0 ) CurBuffy = Incoming; michael@478: + michael@478: + tmp = TopBuffy; michael@478: + michael@478: + SETCOLOR(MT_COLOR_NORMAL); michael@478: + michael@478: + for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { michael@478: + if ( tmp == CurBuffy ) michael@478: + SETCOLOR(MT_COLOR_INDICATOR); michael@478: + else if ( tmp->msg_unread > 0 ) michael@478: + SETCOLOR(MT_COLOR_NEW); michael@478: + else if ( tmp->msg_flagged > 0 ) michael@478: + SETCOLOR(MT_COLOR_FLAGGED); michael@478: + else michael@478: + SETCOLOR(MT_COLOR_NORMAL); michael@478: + michael@478: + move( lines, 0 ); michael@478: + if ( Context && !strcmp( tmp->path, Context->path ) ) { michael@478: + tmp->msg_unread = Context->unread; michael@478: + tmp->msgcount = Context->msgcount; michael@478: + tmp->msg_flagged = Context->flagged; michael@478: + } michael@478: + // check whether Maildir is a prefix of the current folder's path michael@478: + short maildir_is_prefix = 0; michael@478: + if ( (strlen(tmp->path) > strlen(Maildir)) && michael@478: + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) michael@478: + maildir_is_prefix = 1; michael@478: + // calculate depth of current folder and generate its display name with indented spaces michael@478: + int sidebar_folder_depth = 0; michael@478: + char *sidebar_folder_name; michael@478: + sidebar_folder_name = basename(tmp->path); michael@478: + if ( maildir_is_prefix ) { michael@478: + char *tmp_folder_name; michael@478: + int i; michael@478: + tmp_folder_name = tmp->path + strlen(Maildir); michael@478: + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { michael@478: + if (tmp_folder_name[i] == '/') sidebar_folder_depth++; michael@478: + } michael@478: + if (sidebar_folder_depth > 0) { michael@478: + sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); michael@478: + for (i=0; i < sidebar_folder_depth; i++) michael@478: + sidebar_folder_name[i]=' '; michael@478: + sidebar_folder_name[i]=0; michael@478: + strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); michael@478: + } michael@478: + } michael@478: + printw( "%.*s", SidebarWidth - delim_len + 1, michael@478: + make_sidebar_entry(sidebar_folder_name, tmp->msgcount, michael@478: + tmp->msg_unread, tmp->msg_flagged)); michael@478: + if (sidebar_folder_depth > 0) michael@478: + free(sidebar_folder_name); michael@478: + lines++; michael@478: + } michael@478: + SETCOLOR(MT_COLOR_NORMAL); michael@478: + for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { michael@478: + int i = 0; michael@478: + move( lines, 0 ); michael@478: + for ( ; i < SidebarWidth - delim_len; i++ ) michael@478: + addch(' '); michael@478: + } michael@478: + return 0; michael@478: +} michael@478: + michael@478: + michael@478: +void set_buffystats(CONTEXT* Context) michael@478: +{ michael@478: + BUFFY *tmp = Incoming; michael@478: + while(tmp) { michael@478: + if(Context && !strcmp(tmp->path, Context->path)) { michael@478: + tmp->msg_unread = Context->unread; michael@478: + tmp->msgcount = Context->msgcount; michael@478: + break; michael@478: + } michael@478: + tmp = tmp->next; michael@478: + } michael@478: +} michael@478: + michael@478: +void scroll_sidebar(int op, int menu) michael@478: +{ michael@478: + if(!SidebarWidth) return; michael@478: + if(!CurBuffy) return; michael@478: + michael@478: + switch (op) { michael@478: + case OP_SIDEBAR_NEXT: michael@478: + if ( CurBuffy->next == NULL ) return; michael@478: + CurBuffy = CurBuffy->next; michael@478: + break; michael@478: + case OP_SIDEBAR_PREV: michael@478: + if ( CurBuffy->prev == NULL ) return; michael@478: + CurBuffy = CurBuffy->prev; michael@478: + break; michael@478: + case OP_SIDEBAR_SCROLL_UP: michael@478: + CurBuffy = TopBuffy; michael@478: + if ( CurBuffy != Incoming ) { michael@478: + calc_boundaries(menu); michael@478: + CurBuffy = CurBuffy->prev; michael@478: + } michael@478: + break; michael@478: + case OP_SIDEBAR_SCROLL_DOWN: michael@478: + CurBuffy = BottomBuffy; michael@478: + if ( CurBuffy->next ) { michael@478: + calc_boundaries(menu); michael@478: + CurBuffy = CurBuffy->next; michael@478: + } michael@478: + break; michael@478: + default: michael@478: + return; michael@478: + } michael@478: + calc_boundaries(menu); michael@478: + draw_sidebar(menu); michael@478: +} michael@478: + michael@478: Index: sidebar.h michael@478: --- sidebar.h.orig 2011-01-17 19:33:15.000000000 +0100 michael@478: +++ sidebar.h 2011-01-17 19:33:15.000000000 +0100 michael@478: @@ -0,0 +1,36 @@ michael@478: +/* michael@478: + * Copyright (C) ????-2004 Justin Hibbits michael@478: + * Copyright (C) 2004 Thomer M. Gil michael@478: + * michael@478: + * This program is free software; you can redistribute it and/or modify michael@478: + * it under the terms of the GNU General Public License as published by michael@478: + * the Free Software Foundation; either version 2 of the License, or michael@478: + * (at your option) any later version. michael@478: + * michael@478: + * This program is distributed in the hope that it will be useful, michael@478: + * but WITHOUT ANY WARRANTY; without even the implied warranty of michael@478: + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the michael@478: + * GNU General Public License for more details. michael@478: + * michael@478: + * You should have received a copy of the GNU General Public License michael@478: + * along with this program; if not, write to the Free Software michael@478: + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. michael@478: + */ michael@478: + michael@478: +#ifndef SIDEBAR_H michael@478: +#define SIDEBAR_H michael@478: + michael@478: +struct MBOX_LIST { michael@478: + char *path; michael@478: + int msgcount; michael@478: + int new; michael@478: +} MBLIST; michael@478: + michael@478: +/* parameter is whether or not to go to the status line */ michael@478: +/* used for omitting the last | that covers up the status bar in the index */ michael@478: +int draw_sidebar(int); michael@478: +void scroll_sidebar(int, int); michael@478: +void set_curbuffy(char*); michael@478: +void set_buffystats(CONTEXT*); michael@478: + michael@478: +#endif /* SIDEBAR_H */ michael@478: michael@478: ============================================================================== michael@478: michael@478: Fix drawing of sidebar delimiter with the intended michael@478: attributes of the "status" bar --rse 20070906 michael@478: michael@478: Index: sidebar.c michael@478: --- sidebar.c.orig 2007-11-04 15:05:17 +0100 michael@478: +++ sidebar.c 2007-11-04 15:05:17 +0100 michael@478: @@ -186,23 +186,14 @@ michael@478: return 0; michael@478: } michael@478: michael@478: - /* get attributes for divider */ michael@478: - SETCOLOR(MT_COLOR_STATUS); michael@478: -#ifndef USE_SLANG_CURSES michael@478: - attr_get(&attrs, &color_pair, 0); michael@478: -#else michael@478: - color_pair = attr_get(); michael@478: -#endif michael@478: - SETCOLOR(MT_COLOR_NORMAL); michael@478: michael@478: /* draw the divider */ michael@478: michael@478: for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { michael@478: + SETCOLOR(MT_COLOR_STATUS); michael@478: move(lines, SidebarWidth - delim_len); michael@478: addstr(NONULL(SidebarDelim)); michael@478: -#ifndef USE_SLANG_CURSES michael@478: - mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); michael@478: -#endif michael@478: + SETCOLOR(MT_COLOR_NORMAL); michael@478: } michael@478: michael@478: if ( Incoming == 0 ) return 0;