1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mutt/mutt.patch.sidebar Sun Aug 05 21:46:09 2012 +0200 1.3 @@ -0,0 +1,1391 @@ 1.4 +The Mutt "sidebar" patch as taken over by Debian for Mutt 1.5.21 1.5 +but with the patches for Makefile.in applied again. 1.6 + 1.7 +Index: Makefile.am 1.8 +--- Makefile.am.orig 2010-08-24 18:34:21.000000000 +0200 1.9 ++++ Makefile.am 2011-01-17 19:33:57.000000000 +0100 1.10 +@@ -33,7 +33,7 @@ 1.11 + score.c send.c sendlib.c signal.c sort.c \ 1.12 + status.c system.c thread.c charset.c history.c lib.c \ 1.13 + muttlib.c editmsg.c mbyte.c \ 1.14 +- url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c 1.15 ++ url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c 1.16 + 1.17 + nodist_mutt_SOURCES = $(BUILT_SOURCES) 1.18 + 1.19 +Index: Makefile.in 1.20 +--- Makefile.in.orig 2010-08-25 18:31:48.000000000 +0200 1.21 ++++ Makefile.in 2011-01-17 19:33:57.000000000 +0100 1.22 +@@ -85,7 +85,7 @@ 1.23 + system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \ 1.24 + history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \ 1.25 + editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \ 1.26 +- ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) 1.27 ++ ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT) 1.28 + am__objects_1 = 1.29 + am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1) 1.30 + nodist_mutt_OBJECTS = $(am__objects_2) 1.31 +@@ -359,7 +359,7 @@ 1.32 + score.c send.c sendlib.c signal.c sort.c \ 1.33 + status.c system.c thread.c charset.c history.c lib.c \ 1.34 + muttlib.c editmsg.c mbyte.c \ 1.35 +- url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c 1.36 ++ url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c 1.37 + 1.38 + nodist_mutt_SOURCES = $(BUILT_SOURCES) 1.39 + mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \ 1.40 +@@ -391,7 +391,7 @@ 1.41 + README.SSL smime.h group.h \ 1.42 + muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \ 1.43 + ChangeLog mkchangelog.sh mutt_idna.h \ 1.44 +- snprintf.c regex.c crypt-gpgme.h hcachever.sh.in 1.45 ++ snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in 1.46 + 1.47 + EXTRA_SCRIPTS = smime_keys 1.48 + mutt_dotlock_SOURCES = mutt_dotlock.c 1.49 +Index: OPS 1.50 +--- OPS.orig 2010-03-01 18:56:19.000000000 +0100 1.51 ++++ OPS 2011-01-17 19:33:15.000000000 +0100 1.52 +@@ -179,3 +179,8 @@ 1.53 + OP_MAIN_SHOW_LIMIT "show currently active limit pattern" 1.54 + OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" 1.55 + OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" 1.56 ++OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" 1.57 ++OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" 1.58 ++OP_SIDEBAR_NEXT "go down to next mailbox" 1.59 ++OP_SIDEBAR_PREV "go to previous mailbox" 1.60 ++OP_SIDEBAR_OPEN "open hilighted mailbox" 1.61 +Index: buffy.c 1.62 +--- buffy.c.orig 2010-09-13 19:19:55.000000000 +0200 1.63 ++++ buffy.c 2011-01-17 19:33:15.000000000 +0100 1.64 +@@ -312,6 +312,10 @@ 1.65 + return 0; 1.66 + } 1.67 + 1.68 ++ mailbox->msgcount = 0; 1.69 ++ mailbox->msg_unread = 0; 1.70 ++ mailbox->msg_flagged = 0; 1.71 ++ 1.72 + while ((de = readdir (dirp)) != NULL) 1.73 + { 1.74 + if (*de->d_name == '.') 1.75 +@@ -329,7 +333,9 @@ 1.76 + continue; 1.77 + } 1.78 + /* one new and undeleted message is enough */ 1.79 +- mailbox->new = 1; 1.80 ++ mailbox->has_new = mailbox->new = 1; 1.81 ++ mailbox->msgcount++; 1.82 ++ mailbox->msg_unread++; 1.83 + rc = 1; 1.84 + break; 1.85 + } 1.86 +@@ -337,6 +343,32 @@ 1.87 + 1.88 + closedir (dirp); 1.89 + 1.90 ++ /* 1.91 ++ * count read messages (for folderlist (sidebar) we also need to count 1.92 ++ * messages in cur so that we the total number of messages 1.93 ++ */ 1.94 ++ snprintf (path, sizeof (path), "%s/cur", mailbox->path); 1.95 ++ if ((dirp = opendir (path)) == NULL) 1.96 ++ { 1.97 ++ mailbox->magic = 0; 1.98 ++ } 1.99 ++ while ((de = readdir (dirp)) != NULL) 1.100 ++ { 1.101 ++ char *p; 1.102 ++ if (*de->d_name != '.') { 1.103 ++ if ((p = strstr (de->d_name, ":2,"))) { 1.104 ++ if (!strchr (p + 3, 'T')) { 1.105 ++ mailbox->msgcount++; 1.106 ++ if ( !strchr (p + 3, 'S')) 1.107 ++ mailbox->msg_unread++; 1.108 ++ if (strchr(p + 3, 'F')) 1.109 ++ mailbox->msg_flagged++; 1.110 ++ } 1.111 ++ } else 1.112 ++ mailbox->msgcount++; 1.113 ++ } 1.114 ++ } 1.115 ++ 1.116 + return rc; 1.117 + } 1.118 + 1.119 +@@ -345,14 +377,33 @@ 1.120 + { 1.121 + int rc = 0; 1.122 + int statcheck; 1.123 ++ CONTEXT *ctx; 1.124 + 1.125 + if (option (OPTCHECKMBOXSIZE)) 1.126 + statcheck = sb->st_size > mailbox->size; 1.127 + else 1.128 + statcheck = sb->st_mtime > sb->st_atime 1.129 + || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime); 1.130 +- if (statcheck) 1.131 ++ if (statcheck || mailbox->msgcount == 0) 1.132 + { 1.133 ++ BUFFY b = *mailbox; 1.134 ++ int msgcount = 0; 1.135 ++ int msg_unread = 0; 1.136 ++ /* parse the mailbox, to see how much mail there is */ 1.137 ++ ctx = mx_open_mailbox( mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); 1.138 ++ if(ctx) 1.139 ++ { 1.140 ++ msgcount = ctx->msgcount; 1.141 ++ msg_unread = ctx->unread; 1.142 ++ mx_close_mailbox(ctx, 0); 1.143 ++ } 1.144 ++ *mailbox = b; 1.145 ++ mailbox->msgcount = msgcount; 1.146 ++ mailbox->msg_unread = msg_unread; 1.147 ++ if(statcheck) 1.148 ++ { 1.149 ++ mailbox->has_new = mailbox->new = 1; 1.150 ++ } 1.151 + if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited) 1.152 + { 1.153 + rc = 1; 1.154 +@@ -374,9 +425,11 @@ 1.155 + int mutt_buffy_check (int force) 1.156 + { 1.157 + BUFFY *tmp; 1.158 ++ struct dirent *de, *dp; 1.159 + struct stat sb; 1.160 + struct stat contex_sb; 1.161 + time_t t; 1.162 ++ CONTEXT *ctx; 1.163 + 1.164 + sb.st_size=0; 1.165 + contex_sb.st_dev=0; 1.166 +@@ -456,6 +509,20 @@ 1.167 + case M_MH: 1.168 + if ((tmp->new = mh_buffy (tmp->path)) > 0) 1.169 + BuffyCount++; 1.170 ++ 1.171 ++ if ((dp = opendir (tmp->path)) == NULL) 1.172 ++ break; 1.173 ++ tmp->msgcount = 0; 1.174 ++ while ((de = readdir (dp))) 1.175 ++ { 1.176 ++ if (mh_valid_message (de->d_name)) 1.177 ++ { 1.178 ++ tmp->msgcount++; 1.179 ++ tmp->has_new = tmp->new = 1; 1.180 ++ } 1.181 ++ } 1.182 ++ closedir (dp); 1.183 ++ 1.184 + break; 1.185 + } 1.186 + } 1.187 +Index: buffy.h 1.188 +--- buffy.h.orig 2010-09-13 19:19:55.000000000 +0200 1.189 ++++ buffy.h 2011-01-17 19:33:15.000000000 +0100 1.190 +@@ -25,7 +25,12 @@ 1.191 + char path[_POSIX_PATH_MAX]; 1.192 + off_t size; 1.193 + struct buffy_t *next; 1.194 ++ struct buffy_t *prev; 1.195 + short new; /* mailbox has new mail */ 1.196 ++ short has_new; /* set it new if new and not read */ 1.197 ++ int msgcount; /* total number of messages */ 1.198 ++ int msg_unread; /* number of unread messages */ 1.199 ++ int msg_flagged; /* number of flagged messages */ 1.200 + short notified; /* user has been notified */ 1.201 + short magic; /* mailbox type */ 1.202 + short newly_created; /* mbox or mmdf just popped into existence */ 1.203 +Index: color.c 1.204 +--- color.c.orig 2009-05-15 19:18:23.000000000 +0200 1.205 ++++ color.c 2011-01-17 19:33:15.000000000 +0100 1.206 +@@ -93,6 +93,8 @@ 1.207 + { "bold", MT_COLOR_BOLD }, 1.208 + { "underline", MT_COLOR_UNDERLINE }, 1.209 + { "index", MT_COLOR_INDEX }, 1.210 ++ { "sidebar_new", MT_COLOR_NEW }, 1.211 ++ { "sidebar_flagged", MT_COLOR_FLAGGED }, 1.212 + { NULL, 0 } 1.213 + }; 1.214 + 1.215 +Index: compose.c 1.216 +--- compose.c.orig 2010-04-14 20:50:19.000000000 +0200 1.217 ++++ compose.c 2011-01-17 19:33:15.000000000 +0100 1.218 +@@ -72,7 +72,7 @@ 1.219 + 1.220 + #define HDR_XOFFSET 10 1.221 + #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ 1.222 +-#define W (COLS - HDR_XOFFSET) 1.223 ++#define W (COLS - HDR_XOFFSET - SidebarWidth) 1.224 + 1.225 + static char *Prompts[] = 1.226 + { 1.227 +@@ -112,7 +112,7 @@ 1.228 + { 1.229 + int off = 0; 1.230 + 1.231 +- mvaddstr (HDR_CRYPT, 0, "Security: "); 1.232 ++ mvaddstr (HDR_CRYPT, SidebarWidth, "Security: "); 1.233 + 1.234 + if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) 1.235 + { 1.236 +@@ -144,7 +144,7 @@ 1.237 + } 1.238 + 1.239 + clrtoeol (); 1.240 +- move (HDR_CRYPTINFO, 0); 1.241 ++ move (HDR_CRYPTINFO, SidebarWidth); 1.242 + clrtoeol (); 1.243 + 1.244 + if ((WithCrypto & APPLICATION_PGP) 1.245 +@@ -161,7 +161,7 @@ 1.246 + && (msg->security & ENCRYPT) 1.247 + && SmimeCryptAlg 1.248 + && *SmimeCryptAlg) { 1.249 +- mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), 1.250 ++ mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "), 1.251 + NONULL(SmimeCryptAlg)); 1.252 + off = 20; 1.253 + } 1.254 +@@ -175,7 +175,7 @@ 1.255 + int c; 1.256 + char *t; 1.257 + 1.258 +- mvaddstr (HDR_MIX, 0, " Mix: "); 1.259 ++ mvaddstr (HDR_MIX, SidebarWidth, " Mix: "); 1.260 + 1.261 + if (!chain) 1.262 + { 1.263 +@@ -190,7 +190,7 @@ 1.264 + if (t && t[0] == '0' && t[1] == '\0') 1.265 + t = "<random>"; 1.266 + 1.267 +- if (c + mutt_strlen (t) + 2 >= COLS) 1.268 ++ if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth) 1.269 + break; 1.270 + 1.271 + addstr (NONULL(t)); 1.272 +@@ -242,7 +242,7 @@ 1.273 + 1.274 + buf[0] = 0; 1.275 + rfc822_write_address (buf, sizeof (buf), addr, 1); 1.276 +- mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); 1.277 ++ mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]); 1.278 + mutt_paddstr (W, buf); 1.279 + } 1.280 + 1.281 +@@ -252,10 +252,10 @@ 1.282 + draw_envelope_addr (HDR_TO, msg->env->to); 1.283 + draw_envelope_addr (HDR_CC, msg->env->cc); 1.284 + draw_envelope_addr (HDR_BCC, msg->env->bcc); 1.285 +- mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); 1.286 ++ mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); 1.287 + mutt_paddstr (W, NONULL (msg->env->subject)); 1.288 + draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); 1.289 +- mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]); 1.290 ++ mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]); 1.291 + mutt_paddstr (W, fcc); 1.292 + 1.293 + if (WithCrypto) 1.294 +@@ -266,7 +266,7 @@ 1.295 + #endif 1.296 + 1.297 + SETCOLOR (MT_COLOR_STATUS); 1.298 +- mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); 1.299 ++ mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments")); 1.300 + BKGDSET (MT_COLOR_STATUS); 1.301 + clrtoeol (); 1.302 + 1.303 +@@ -304,7 +304,7 @@ 1.304 + /* redraw the expanded list so the user can see the result */ 1.305 + buf[0] = 0; 1.306 + rfc822_write_address (buf, sizeof (buf), *addr, 1); 1.307 +- move (line, HDR_XOFFSET); 1.308 ++ move (line, HDR_XOFFSET+SidebarWidth); 1.309 + mutt_paddstr (W, buf); 1.310 + 1.311 + return 0; 1.312 +@@ -549,7 +549,7 @@ 1.313 + if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) 1.314 + { 1.315 + mutt_str_replace (&msg->env->subject, buf); 1.316 +- move (HDR_SUBJECT, HDR_XOFFSET); 1.317 ++ move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth); 1.318 + clrtoeol (); 1.319 + if (msg->env->subject) 1.320 + mutt_paddstr (W, msg->env->subject); 1.321 +@@ -566,7 +566,7 @@ 1.322 + { 1.323 + strfcpy (fcc, buf, fcclen); 1.324 + mutt_pretty_mailbox (fcc, fcclen); 1.325 +- move (HDR_FCC, HDR_XOFFSET); 1.326 ++ move (HDR_FCC, HDR_XOFFSET + SidebarWidth); 1.327 + mutt_paddstr (W, fcc); 1.328 + fccSet = 1; 1.329 + } 1.330 +Index: curs_main.c 1.331 +--- curs_main.c.orig 2010-09-13 19:19:55.000000000 +0200 1.332 ++++ curs_main.c 2011-01-17 19:33:15.000000000 +0100 1.333 +@@ -26,7 +26,9 @@ 1.334 + #include "mailbox.h" 1.335 + #include "mapping.h" 1.336 + #include "sort.h" 1.337 ++#include "buffy.h" 1.338 + #include "mx.h" 1.339 ++#include "sidebar.h" 1.340 + 1.341 + #ifdef USE_POP 1.342 + #include "pop.h" 1.343 +@@ -519,8 +521,12 @@ 1.344 + menu->redraw |= REDRAW_STATUS; 1.345 + if (do_buffy_notify) 1.346 + { 1.347 +- if (mutt_buffy_notify () && option (OPTBEEPNEW)) 1.348 +- beep (); 1.349 ++ if (mutt_buffy_notify ()) 1.350 ++ { 1.351 ++ menu->redraw |= REDRAW_FULL; 1.352 ++ if (option (OPTBEEPNEW)) 1.353 ++ beep (); 1.354 ++ } 1.355 + } 1.356 + else 1.357 + do_buffy_notify = 1; 1.358 +@@ -532,6 +538,7 @@ 1.359 + if (menu->redraw & REDRAW_FULL) 1.360 + { 1.361 + menu_redraw_full (menu); 1.362 ++ draw_sidebar(menu->menu); 1.363 + mutt_show_error (); 1.364 + } 1.365 + 1.366 +@@ -554,10 +561,13 @@ 1.367 + 1.368 + if (menu->redraw & REDRAW_STATUS) 1.369 + { 1.370 ++ DrawFullLine = 1; 1.371 + menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); 1.372 ++ DrawFullLine = 0; 1.373 + CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2); 1.374 + SETCOLOR (MT_COLOR_STATUS); 1.375 + BKGDSET (MT_COLOR_STATUS); 1.376 ++ set_buffystats(Context); 1.377 + mutt_paddstr (COLS, buf); 1.378 + SETCOLOR (MT_COLOR_NORMAL); 1.379 + BKGDSET (MT_COLOR_NORMAL); 1.380 +@@ -571,7 +581,7 @@ 1.381 + menu->oldcurrent = -1; 1.382 + 1.383 + if (option (OPTARROWCURSOR)) 1.384 +- move (menu->current - menu->top + menu->offset, 2); 1.385 ++ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); 1.386 + else if (option (OPTBRAILLEFRIENDLY)) 1.387 + move (menu->current - menu->top + menu->offset, 0); 1.388 + else 1.389 +@@ -1069,6 +1079,7 @@ 1.390 + menu->redraw = REDRAW_FULL; 1.391 + break; 1.392 + 1.393 ++ case OP_SIDEBAR_OPEN: 1.394 + case OP_MAIN_CHANGE_FOLDER: 1.395 + case OP_MAIN_NEXT_UNREAD_MAILBOX: 1.396 + 1.397 +@@ -1100,7 +1111,11 @@ 1.398 + { 1.399 + mutt_buffy (buf, sizeof (buf)); 1.400 + 1.401 +- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 1.402 ++ if ( op == OP_SIDEBAR_OPEN ) { 1.403 ++ if(!CurBuffy) 1.404 ++ break; 1.405 ++ strncpy( buf, CurBuffy->path, sizeof(buf) ); 1.406 ++ } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 1.407 + { 1.408 + if (menu->menu == MENU_PAGER) 1.409 + { 1.410 +@@ -1118,6 +1133,7 @@ 1.411 + } 1.412 + 1.413 + mutt_expand_path (buf, sizeof (buf)); 1.414 ++ set_curbuffy(buf); 1.415 + if (mx_get_magic (buf) <= 0) 1.416 + { 1.417 + mutt_error (_("%s is not a mailbox."), buf); 1.418 +@@ -2208,6 +2224,12 @@ 1.419 + mutt_what_key(); 1.420 + break; 1.421 + 1.422 ++ case OP_SIDEBAR_SCROLL_UP: 1.423 ++ case OP_SIDEBAR_SCROLL_DOWN: 1.424 ++ case OP_SIDEBAR_NEXT: 1.425 ++ case OP_SIDEBAR_PREV: 1.426 ++ scroll_sidebar(op, menu->menu); 1.427 ++ break; 1.428 + default: 1.429 + if (menu->menu == MENU_MAIN) 1.430 + km_error_key (MENU_MAIN); 1.431 +Index: doc/Muttrc 1.432 +--- doc/Muttrc.orig 2010-09-15 19:07:19.000000000 +0200 1.433 ++++ doc/Muttrc 2011-01-17 19:33:15.000000000 +0100 1.434 +@@ -657,6 +657,26 @@ 1.435 + # $crypt_autosign, $crypt_replysign and $smime_is_default. 1.436 + # 1.437 + # 1.438 ++# set sidebar_visible=no 1.439 ++# 1.440 ++# Name: sidebar_visible 1.441 ++# Type: boolean 1.442 ++# Default: no 1.443 ++# 1.444 ++# 1.445 ++# This specifies whether or not to show sidebar (left-side list of folders). 1.446 ++# 1.447 ++# 1.448 ++# set sidebar_width=0 1.449 ++# 1.450 ++# Name: sidebar_width 1.451 ++# Type: number 1.452 ++# Default: 0 1.453 ++# 1.454 ++# 1.455 ++# The width of the sidebar. 1.456 ++# 1.457 ++# 1.458 + # set crypt_autosign=no 1.459 + # 1.460 + # Name: crypt_autosign 1.461 +Index: flags.c 1.462 +--- flags.c.orig 2009-01-04 00:27:10.000000000 +0100 1.463 ++++ flags.c 2011-01-17 19:33:15.000000000 +0100 1.464 +@@ -22,8 +22,10 @@ 1.465 + 1.466 + #include "mutt.h" 1.467 + #include "mutt_curses.h" 1.468 ++#include "mutt_menu.h" 1.469 + #include "sort.h" 1.470 + #include "mx.h" 1.471 ++#include "sidebar.h" 1.472 + 1.473 + void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) 1.474 + { 1.475 +@@ -263,6 +265,7 @@ 1.476 + */ 1.477 + if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) 1.478 + h->searched = 0; 1.479 ++ draw_sidebar(0); 1.480 + } 1.481 + 1.482 + void mutt_tag_set_flag (int flag, int bf) 1.483 +Index: functions.h 1.484 +--- functions.h.orig 2010-08-24 18:34:21.000000000 +0200 1.485 ++++ functions.h 2011-01-17 19:33:15.000000000 +0100 1.486 +@@ -169,6 +169,11 @@ 1.487 + { "decrypt-save", OP_DECRYPT_SAVE, NULL }, 1.488 + 1.489 + 1.490 ++ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, 1.491 ++ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, 1.492 ++ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 1.493 ++ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 1.494 ++ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 1.495 + { NULL, 0, NULL } 1.496 + }; 1.497 + 1.498 +@@ -272,6 +277,11 @@ 1.499 + 1.500 + { "what-key", OP_WHAT_KEY, NULL }, 1.501 + 1.502 ++ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, 1.503 ++ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, 1.504 ++ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 1.505 ++ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 1.506 ++ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 1.507 + { NULL, 0, NULL } 1.508 + }; 1.509 + 1.510 +Index: globals.h 1.511 +--- globals.h.orig 2009-08-25 21:08:52.000000000 +0200 1.512 ++++ globals.h 2011-01-17 19:33:15.000000000 +0100 1.513 +@@ -117,6 +117,7 @@ 1.514 + WHERE char *SendCharset; 1.515 + WHERE char *Sendmail; 1.516 + WHERE char *Shell; 1.517 ++WHERE char *SidebarDelim; 1.518 + WHERE char *Signature; 1.519 + WHERE char *SimpleSearch; 1.520 + #if USE_SMTP 1.521 +@@ -207,6 +208,9 @@ 1.522 + WHERE short ScoreThresholdRead; 1.523 + WHERE short ScoreThresholdFlag; 1.524 + 1.525 ++WHERE struct buffy_t *CurBuffy INITVAL(0); 1.526 ++WHERE short DrawFullLine INITVAL(0); 1.527 ++WHERE short SidebarWidth; 1.528 + #ifdef USE_IMAP 1.529 + WHERE short ImapKeepalive; 1.530 + WHERE short ImapPipelineDepth; 1.531 +Index: imap/command.c 1.532 +--- imap/command.c.orig 2010-09-15 17:39:31.000000000 +0200 1.533 ++++ imap/command.c 2011-01-17 19:33:15.000000000 +0100 1.534 +@@ -1011,6 +1011,13 @@ 1.535 + opened */ 1.536 + status->uidnext = oldun; 1.537 + 1.538 ++ /* Added to make the sidebar show the correct numbers */ 1.539 ++ if (status->messages) 1.540 ++ { 1.541 ++ inc->msgcount = status->messages; 1.542 ++ inc->msg_unread = status->unseen; 1.543 ++ } 1.544 ++ 1.545 + FREE (&value); 1.546 + return; 1.547 + } 1.548 +Index: imap/imap.c 1.549 +--- imap/imap.c.orig 2009-08-25 21:08:52.000000000 +0200 1.550 ++++ imap/imap.c 2011-01-17 19:33:15.000000000 +0100 1.551 +@@ -1521,7 +1521,7 @@ 1.552 + 1.553 + imap_munge_mbox_name (munged, sizeof (munged), name); 1.554 + snprintf (command, sizeof (command), 1.555 +- "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); 1.556 ++ "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); 1.557 + 1.558 + if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) 1.559 + { 1.560 +Index: init.h 1.561 +--- init.h.orig 2010-09-15 17:39:31.000000000 +0200 1.562 ++++ init.h 2011-01-17 19:33:15.000000000 +0100 1.563 +@@ -1953,6 +1953,22 @@ 1.564 + ** not used. 1.565 + ** (PGP only) 1.566 + */ 1.567 ++ {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, 1.568 ++ /* 1.569 ++ ** .pp 1.570 ++ ** This specifies the delimiter between the sidebar (if visible) and 1.571 ++ ** other screens. 1.572 ++ */ 1.573 ++ { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, 1.574 ++ /* 1.575 ++ ** .pp 1.576 ++ ** This specifies whether or not to show sidebar (left-side list of folders). 1.577 ++ */ 1.578 ++ { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, 1.579 ++ /* 1.580 ++ ** .pp 1.581 ++ ** The width of the sidebar. 1.582 ++ */ 1.583 + { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, 1.584 + /* 1.585 + ** .pp 1.586 +Index: mailbox.h 1.587 +--- mailbox.h.orig 2009-04-30 19:33:48.000000000 +0200 1.588 ++++ mailbox.h 2011-01-17 19:33:15.000000000 +0100 1.589 +@@ -27,6 +27,7 @@ 1.590 + #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses 1.591 + * safe_fopen() for mbox-style folders. 1.592 + */ 1.593 ++#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ 1.594 + 1.595 + /* mx_open_new_message() */ 1.596 + #define M_ADD_FROM 1 /* add a From_ line */ 1.597 +Index: mbox.c 1.598 +--- mbox.c.orig 2010-09-13 19:19:55.000000000 +0200 1.599 ++++ mbox.c 2011-01-17 19:33:15.000000000 +0100 1.600 +@@ -100,6 +100,7 @@ 1.601 + mutt_perror (ctx->path); 1.602 + return (-1); 1.603 + } 1.604 ++ ctx->atime = sb.st_atime; 1.605 + ctx->mtime = sb.st_mtime; 1.606 + ctx->size = sb.st_size; 1.607 + 1.608 +@@ -251,6 +252,7 @@ 1.609 + 1.610 + ctx->size = sb.st_size; 1.611 + ctx->mtime = sb.st_mtime; 1.612 ++ ctx->atime = sb.st_atime; 1.613 + 1.614 + #ifdef NFS_ATTRIBUTE_HACK 1.615 + if (sb.st_mtime > sb.st_atime) 1.616 +Index: menu.c 1.617 +--- menu.c.orig 2010-08-25 18:31:40.000000000 +0200 1.618 ++++ menu.c 2011-01-17 19:33:15.000000000 +0100 1.619 +@@ -24,6 +24,7 @@ 1.620 + #include "mutt_curses.h" 1.621 + #include "mutt_menu.h" 1.622 + #include "mbyte.h" 1.623 ++#include "sidebar.h" 1.624 + 1.625 + #include <string.h> 1.626 + #include <stdlib.h> 1.627 +@@ -156,7 +157,7 @@ 1.628 + { 1.629 + char *scratch = safe_strdup (s); 1.630 + int shift = option (OPTARROWCURSOR) ? 3 : 0; 1.631 +- int cols = COLS - shift; 1.632 ++ int cols = COLS - shift - SidebarWidth; 1.633 + 1.634 + mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); 1.635 + s[n - 1] = 0; 1.636 +@@ -207,6 +208,7 @@ 1.637 + char buf[LONG_STRING]; 1.638 + int i; 1.639 + 1.640 ++ draw_sidebar(1); 1.641 + for (i = menu->top; i < menu->top + menu->pagelen; i++) 1.642 + { 1.643 + if (i < menu->max) 1.644 +@@ -217,7 +219,7 @@ 1.645 + if (option (OPTARROWCURSOR)) 1.646 + { 1.647 + attrset (menu->color (i)); 1.648 +- CLEARLINE (i - menu->top + menu->offset); 1.649 ++ CLEARLINE_WIN (i - menu->top + menu->offset); 1.650 + 1.651 + if (i == menu->current) 1.652 + { 1.653 +@@ -246,14 +248,14 @@ 1.654 + BKGDSET (MT_COLOR_INDICATOR); 1.655 + } 1.656 + 1.657 +- CLEARLINE (i - menu->top + menu->offset); 1.658 ++ CLEARLINE_WIN (i - menu->top + menu->offset); 1.659 + print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); 1.660 + SETCOLOR (MT_COLOR_NORMAL); 1.661 + BKGDSET (MT_COLOR_NORMAL); 1.662 + } 1.663 + } 1.664 + else 1.665 +- CLEARLINE (i - menu->top + menu->offset); 1.666 ++ CLEARLINE_WIN (i - menu->top + menu->offset); 1.667 + } 1.668 + menu->redraw = 0; 1.669 + } 1.670 +@@ -268,7 +270,7 @@ 1.671 + return; 1.672 + } 1.673 + 1.674 +- move (menu->oldcurrent + menu->offset - menu->top, 0); 1.675 ++ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); 1.676 + SETCOLOR (MT_COLOR_NORMAL); 1.677 + BKGDSET (MT_COLOR_NORMAL); 1.678 + 1.679 +@@ -283,13 +285,13 @@ 1.680 + clrtoeol (); 1.681 + menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); 1.682 + menu_pad_string (buf, sizeof (buf)); 1.683 +- move (menu->oldcurrent + menu->offset - menu->top, 3); 1.684 ++ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); 1.685 + print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); 1.686 + SETCOLOR (MT_COLOR_NORMAL); 1.687 + } 1.688 + 1.689 + /* now draw it in the new location */ 1.690 +- move (menu->current + menu->offset - menu->top, 0); 1.691 ++ move (menu->current + menu->offset - menu->top, SidebarWidth); 1.692 + attrset (menu->color (menu->current)); 1.693 + ADDCOLOR (MT_COLOR_INDICATOR); 1.694 + addstr ("->"); 1.695 +@@ -310,7 +312,7 @@ 1.696 + attrset (menu->color (menu->current)); 1.697 + ADDCOLOR (MT_COLOR_INDICATOR); 1.698 + BKGDSET (MT_COLOR_INDICATOR); 1.699 +- CLEARLINE (menu->current - menu->top + menu->offset); 1.700 ++ CLEARLINE_WIN (menu->current - menu->top + menu->offset); 1.701 + print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); 1.702 + SETCOLOR (MT_COLOR_NORMAL); 1.703 + BKGDSET (MT_COLOR_NORMAL); 1.704 +@@ -322,7 +324,7 @@ 1.705 + { 1.706 + char buf[LONG_STRING]; 1.707 + 1.708 +- move (menu->current + menu->offset - menu->top, 0); 1.709 ++ move (menu->current + menu->offset - menu->top, SidebarWidth); 1.710 + menu_make_entry (buf, sizeof (buf), menu, menu->current); 1.711 + menu_pad_string (buf, sizeof (buf)); 1.712 + 1.713 +@@ -875,7 +877,7 @@ 1.714 + 1.715 + 1.716 + if (option (OPTARROWCURSOR)) 1.717 +- move (menu->current - menu->top + menu->offset, 2); 1.718 ++ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); 1.719 + else if (option (OPTBRAILLEFRIENDLY)) 1.720 + move (menu->current - menu->top + menu->offset, 0); 1.721 + else 1.722 +Index: mutt.h 1.723 +--- mutt.h.orig 2010-09-13 19:19:55.000000000 +0200 1.724 ++++ mutt.h 2011-01-17 19:33:15.000000000 +0100 1.725 +@@ -419,6 +419,7 @@ 1.726 + OPTSAVEEMPTY, 1.727 + OPTSAVENAME, 1.728 + OPTSCORE, 1.729 ++ OPTSIDEBAR, 1.730 + OPTSIGDASHES, 1.731 + OPTSIGONTOP, 1.732 + OPTSORTRE, 1.733 +@@ -859,6 +860,7 @@ 1.734 + { 1.735 + char *path; 1.736 + FILE *fp; 1.737 ++ time_t atime; 1.738 + time_t mtime; 1.739 + off_t size; 1.740 + off_t vsize; 1.741 +@@ -893,6 +895,7 @@ 1.742 + unsigned int quiet : 1; /* inhibit status messages? */ 1.743 + unsigned int collapsed : 1; /* are all threads collapsed? */ 1.744 + unsigned int closing : 1; /* mailbox is being closed */ 1.745 ++ unsigned int peekonly : 1; /* just taking a glance, revert atime */ 1.746 + 1.747 + /* driver hooks */ 1.748 + void *data; /* driver specific data */ 1.749 +Index: mutt_curses.h 1.750 +--- mutt_curses.h.orig 2008-03-19 21:07:57.000000000 +0100 1.751 ++++ mutt_curses.h 2011-01-17 19:33:15.000000000 +0100 1.752 +@@ -64,6 +64,7 @@ 1.753 + #undef lines 1.754 + #endif /* lines */ 1.755 + 1.756 ++#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() 1.757 + #define CLEARLINE(x) move(x,0), clrtoeol() 1.758 + #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) 1.759 + #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) 1.760 +@@ -126,6 +127,8 @@ 1.761 + MT_COLOR_BOLD, 1.762 + MT_COLOR_UNDERLINE, 1.763 + MT_COLOR_INDEX, 1.764 ++ MT_COLOR_NEW, 1.765 ++ MT_COLOR_FLAGGED, 1.766 + MT_COLOR_MAX 1.767 + }; 1.768 + 1.769 +Index: muttlib.c 1.770 +--- muttlib.c.orig 2010-08-25 18:31:40.000000000 +0200 1.771 ++++ muttlib.c 2011-01-17 19:33:15.000000000 +0100 1.772 +@@ -1286,6 +1286,8 @@ 1.773 + pl = pw = 1; 1.774 + 1.775 + /* see if there's room to add content, else ignore */ 1.776 ++ if ( DrawFullLine ) 1.777 ++ { 1.778 + if ((col < COLS && wlen < destlen) || soft) 1.779 + { 1.780 + int pad; 1.781 +@@ -1329,6 +1331,52 @@ 1.782 + col += wid; 1.783 + src += pl; 1.784 + } 1.785 ++ } 1.786 ++ else 1.787 ++ { 1.788 ++ if ((col < COLS-SidebarWidth && wlen < destlen) || soft) 1.789 ++ { 1.790 ++ int pad; 1.791 ++ 1.792 ++ /* get contents after padding */ 1.793 ++ mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); 1.794 ++ len = mutt_strlen (buf); 1.795 ++ wid = mutt_strwidth (buf); 1.796 ++ 1.797 ++ /* try to consume as many columns as we can, if we don't have 1.798 ++ * memory for that, use as much memory as possible */ 1.799 ++ pad = (COLS - SidebarWidth - col - wid) / pw; 1.800 ++ if (pad > 0 && wlen + (pad * pl) + len > destlen) 1.801 ++ pad = ((signed)(destlen - wlen - len)) / pl; 1.802 ++ if (pad > 0) 1.803 ++ { 1.804 ++ while (pad--) 1.805 ++ { 1.806 ++ memcpy (wptr, src, pl); 1.807 ++ wptr += pl; 1.808 ++ wlen += pl; 1.809 ++ col += pw; 1.810 ++ } 1.811 ++ } 1.812 ++ else if (soft && pad < 0) 1.813 ++ { 1.814 ++ /* \0-terminate dest for length computation in mutt_wstr_trunc() */ 1.815 ++ *wptr = 0; 1.816 ++ /* make sure right part is at most as wide as display */ 1.817 ++ len = mutt_wstr_trunc (buf, destlen, COLS, &wid); 1.818 ++ /* truncate left so that right part fits completely in */ 1.819 ++ wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); 1.820 ++ wptr = dest + wlen; 1.821 ++ } 1.822 ++ if (len + wlen > destlen) 1.823 ++ len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); 1.824 ++ memcpy (wptr, buf, len); 1.825 ++ wptr += len; 1.826 ++ wlen += len; 1.827 ++ col += wid; 1.828 ++ src += pl; 1.829 ++ } 1.830 ++ } 1.831 + break; /* skip rest of input */ 1.832 + } 1.833 + else if (ch == '|') 1.834 +Index: mx.c 1.835 +--- mx.c.orig 2010-09-13 19:19:55.000000000 +0200 1.836 ++++ mx.c 2011-01-17 19:33:15.000000000 +0100 1.837 +@@ -580,6 +580,7 @@ 1.838 + * M_APPEND open mailbox for appending 1.839 + * M_READONLY open mailbox in read-only mode 1.840 + * M_QUIET only print error messages 1.841 ++ * M_PEEK revert atime where applicable 1.842 + * ctx if non-null, context struct to use 1.843 + */ 1.844 + CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) 1.845 +@@ -602,6 +603,8 @@ 1.846 + ctx->quiet = 1; 1.847 + if (flags & M_READONLY) 1.848 + ctx->readonly = 1; 1.849 ++ if (flags & M_PEEK) 1.850 ++ ctx->peekonly = 1; 1.851 + 1.852 + if (flags & (M_APPEND|M_NEWFOLDER)) 1.853 + { 1.854 +@@ -701,9 +704,21 @@ 1.855 + void mx_fastclose_mailbox (CONTEXT *ctx) 1.856 + { 1.857 + int i; 1.858 ++#ifndef BUFFY_SIZE 1.859 ++ struct utimbuf ut; 1.860 ++#endif 1.861 + 1.862 + if(!ctx) 1.863 + return; 1.864 ++#ifndef BUFFY_SIZE 1.865 ++ /* fix up the times so buffy won't get confused */ 1.866 ++ if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) 1.867 ++ { 1.868 ++ ut.actime = ctx->atime; 1.869 ++ ut.modtime = ctx->mtime; 1.870 ++ utime (ctx->path, &ut); 1.871 ++ } 1.872 ++#endif 1.873 + 1.874 + /* never announce that a mailbox we've just left has new mail. #3290 1.875 + * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ 1.876 +Index: pager.c 1.877 +--- pager.c.orig 2010-08-25 18:31:40.000000000 +0200 1.878 ++++ pager.c 2011-01-17 19:33:15.000000000 +0100 1.879 +@@ -29,6 +29,7 @@ 1.880 + #include "pager.h" 1.881 + #include "attach.h" 1.882 + #include "mbyte.h" 1.883 ++#include "sidebar.h" 1.884 + 1.885 + #include "mutt_crypt.h" 1.886 + 1.887 +@@ -1099,6 +1100,7 @@ 1.888 + if (check_attachment_marker ((char *)buf) == 0) 1.889 + wrap_cols = COLS; 1.890 + 1.891 ++ wrap_cols -= SidebarWidth; 1.892 + /* FIXME: this should come from lineInfo */ 1.893 + memset(&mbstate, 0, sizeof(mbstate)); 1.894 + 1.895 +@@ -1745,7 +1747,7 @@ 1.896 + if ((redraw & REDRAW_BODY) || topline != oldtopline) 1.897 + { 1.898 + do { 1.899 +- move (bodyoffset, 0); 1.900 ++ move (bodyoffset, SidebarWidth); 1.901 + curline = oldtopline = topline; 1.902 + lines = 0; 1.903 + force_redraw = 0; 1.904 +@@ -1758,6 +1760,7 @@ 1.905 + &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) 1.906 + lines++; 1.907 + curline++; 1.908 ++ move(lines + bodyoffset, SidebarWidth); 1.909 + } 1.910 + last_offset = lineInfo[curline].offset; 1.911 + } while (force_redraw); 1.912 +@@ -1771,6 +1774,7 @@ 1.913 + addch ('~'); 1.914 + addch ('\n'); 1.915 + lines++; 1.916 ++ move(lines + bodyoffset, SidebarWidth); 1.917 + } 1.918 + /* We are going to update the pager status bar, so it isn't 1.919 + * necessary to reset to normal color now. */ 1.920 +@@ -1794,11 +1798,11 @@ 1.921 + /* print out the pager status bar */ 1.922 + SETCOLOR (MT_COLOR_STATUS); 1.923 + BKGDSET (MT_COLOR_STATUS); 1.924 +- CLEARLINE (statusoffset); 1.925 ++ CLEARLINE_WIN (statusoffset); 1.926 + 1.927 + if (IsHeader (extra) || IsMsgAttach (extra)) 1.928 + { 1.929 +- size_t l1 = COLS * MB_LEN_MAX; 1.930 ++ size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; 1.931 + size_t l2 = sizeof (buffer); 1.932 + hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; 1.933 + mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); 1.934 +@@ -1808,7 +1812,7 @@ 1.935 + { 1.936 + char bn[STRING]; 1.937 + snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); 1.938 +- mutt_paddstr (COLS, bn); 1.939 ++ mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner); 1.940 + } 1.941 + BKGDSET (MT_COLOR_NORMAL); 1.942 + SETCOLOR (MT_COLOR_NORMAL); 1.943 +@@ -1819,18 +1823,23 @@ 1.944 + /* redraw the pager_index indicator, because the 1.945 + * flags for this message might have changed. */ 1.946 + menu_redraw_current (index); 1.947 ++ draw_sidebar(MENU_PAGER); 1.948 + 1.949 + /* print out the index status bar */ 1.950 + menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); 1.951 + 1.952 +- move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); 1.953 ++ move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); 1.954 + SETCOLOR (MT_COLOR_STATUS); 1.955 + BKGDSET (MT_COLOR_STATUS); 1.956 +- mutt_paddstr (COLS, buffer); 1.957 ++ mutt_paddstr (COLS-SidebarWidth, buffer); 1.958 + SETCOLOR (MT_COLOR_NORMAL); 1.959 + BKGDSET (MT_COLOR_NORMAL); 1.960 + } 1.961 + 1.962 ++ /* if we're not using the index, update every time */ 1.963 ++ if ( index == 0 ) 1.964 ++ draw_sidebar(MENU_PAGER); 1.965 ++ 1.966 + redraw = 0; 1.967 + 1.968 + if (option(OPTBRAILLEFRIENDLY)) { 1.969 +@@ -2756,6 +2765,13 @@ 1.970 + mutt_what_key (); 1.971 + break; 1.972 + 1.973 ++ case OP_SIDEBAR_SCROLL_UP: 1.974 ++ case OP_SIDEBAR_SCROLL_DOWN: 1.975 ++ case OP_SIDEBAR_NEXT: 1.976 ++ case OP_SIDEBAR_PREV: 1.977 ++ scroll_sidebar(ch, MENU_PAGER); 1.978 ++ break; 1.979 ++ 1.980 + default: 1.981 + ch = -1; 1.982 + break; 1.983 +Index: sidebar.c 1.984 +--- sidebar.c.orig 2011-01-17 19:33:15.000000000 +0100 1.985 ++++ sidebar.c 2011-01-17 19:33:15.000000000 +0100 1.986 +@@ -0,0 +1,333 @@ 1.987 ++/* 1.988 ++ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> 1.989 ++ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> 1.990 ++ * 1.991 ++ * This program is free software; you can redistribute it and/or modify 1.992 ++ * it under the terms of the GNU General Public License as published by 1.993 ++ * the Free Software Foundation; either version 2 of the License, or 1.994 ++ * (at your option) any later version. 1.995 ++ * 1.996 ++ * This program is distributed in the hope that it will be useful, 1.997 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of 1.998 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.999 ++ * GNU General Public License for more details. 1.1000 ++ * 1.1001 ++ * You should have received a copy of the GNU General Public License 1.1002 ++ * along with this program; if not, write to the Free Software 1.1003 ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 1.1004 ++ */ 1.1005 ++ 1.1006 ++ 1.1007 ++#if HAVE_CONFIG_H 1.1008 ++# include "config.h" 1.1009 ++#endif 1.1010 ++ 1.1011 ++#include "mutt.h" 1.1012 ++#include "mutt_menu.h" 1.1013 ++#include "mutt_curses.h" 1.1014 ++#include "sidebar.h" 1.1015 ++#include "buffy.h" 1.1016 ++#include <libgen.h> 1.1017 ++#include "keymap.h" 1.1018 ++#include <stdbool.h> 1.1019 ++ 1.1020 ++/*BUFFY *CurBuffy = 0;*/ 1.1021 ++static BUFFY *TopBuffy = 0; 1.1022 ++static BUFFY *BottomBuffy = 0; 1.1023 ++static int known_lines = 0; 1.1024 ++ 1.1025 ++static int quick_log10(int n) 1.1026 ++{ 1.1027 ++ char string[32]; 1.1028 ++ sprintf(string, "%d", n); 1.1029 ++ return strlen(string); 1.1030 ++} 1.1031 ++ 1.1032 ++void calc_boundaries (int menu) 1.1033 ++{ 1.1034 ++ BUFFY *tmp = Incoming; 1.1035 ++ 1.1036 ++ if ( known_lines != LINES ) { 1.1037 ++ TopBuffy = BottomBuffy = 0; 1.1038 ++ known_lines = LINES; 1.1039 ++ } 1.1040 ++ for ( ; tmp->next != 0; tmp = tmp->next ) 1.1041 ++ tmp->next->prev = tmp; 1.1042 ++ 1.1043 ++ if ( TopBuffy == 0 && BottomBuffy == 0 ) 1.1044 ++ TopBuffy = Incoming; 1.1045 ++ if ( BottomBuffy == 0 ) { 1.1046 ++ int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); 1.1047 ++ BottomBuffy = TopBuffy; 1.1048 ++ while ( --count && BottomBuffy->next ) 1.1049 ++ BottomBuffy = BottomBuffy->next; 1.1050 ++ } 1.1051 ++ else if ( TopBuffy == CurBuffy->next ) { 1.1052 ++ int count = LINES - 2 - (menu != MENU_PAGER); 1.1053 ++ BottomBuffy = CurBuffy; 1.1054 ++ tmp = BottomBuffy; 1.1055 ++ while ( --count && tmp->prev) 1.1056 ++ tmp = tmp->prev; 1.1057 ++ TopBuffy = tmp; 1.1058 ++ } 1.1059 ++ else if ( BottomBuffy == CurBuffy->prev ) { 1.1060 ++ int count = LINES - 2 - (menu != MENU_PAGER); 1.1061 ++ TopBuffy = CurBuffy; 1.1062 ++ tmp = TopBuffy; 1.1063 ++ while ( --count && tmp->next ) 1.1064 ++ tmp = tmp->next; 1.1065 ++ BottomBuffy = tmp; 1.1066 ++ } 1.1067 ++} 1.1068 ++ 1.1069 ++char *make_sidebar_entry(char *box, int size, int new, int flagged) 1.1070 ++{ 1.1071 ++ static char *entry = 0; 1.1072 ++ char *c; 1.1073 ++ int i = 0; 1.1074 ++ int delim_len = strlen(SidebarDelim); 1.1075 ++ 1.1076 ++ c = realloc(entry, SidebarWidth - delim_len + 2); 1.1077 ++ if ( c ) entry = c; 1.1078 ++ entry[SidebarWidth - delim_len + 1] = 0; 1.1079 ++ for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); 1.1080 ++ i = strlen(box); 1.1081 ++ strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); 1.1082 ++ 1.1083 ++ if (size == -1) 1.1084 ++ sprintf(entry + SidebarWidth - delim_len - 3, "?"); 1.1085 ++ else if ( new ) { 1.1086 ++ if (flagged > 0) { 1.1087 ++ sprintf( 1.1088 ++ entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), 1.1089 ++ "% d(%d)[%d]", size, new, flagged); 1.1090 ++ } else { 1.1091 ++ sprintf( 1.1092 ++ entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), 1.1093 ++ "% d(%d)", size, new); 1.1094 ++ } 1.1095 ++ } else if (flagged > 0) { 1.1096 ++ sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); 1.1097 ++ } else { 1.1098 ++ sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); 1.1099 ++ } 1.1100 ++ return entry; 1.1101 ++} 1.1102 ++ 1.1103 ++void set_curbuffy(char buf[LONG_STRING]) 1.1104 ++{ 1.1105 ++ BUFFY* tmp = CurBuffy = Incoming; 1.1106 ++ 1.1107 ++ if (!Incoming) 1.1108 ++ return; 1.1109 ++ 1.1110 ++ while(1) { 1.1111 ++ if(!strcmp(tmp->path, buf)) { 1.1112 ++ CurBuffy = tmp; 1.1113 ++ break; 1.1114 ++ } 1.1115 ++ 1.1116 ++ if(tmp->next) 1.1117 ++ tmp = tmp->next; 1.1118 ++ else 1.1119 ++ break; 1.1120 ++ } 1.1121 ++} 1.1122 ++ 1.1123 ++int draw_sidebar(int menu) { 1.1124 ++ 1.1125 ++ int lines = option(OPTHELP) ? 1 : 0; 1.1126 ++ BUFFY *tmp; 1.1127 ++#ifndef USE_SLANG_CURSES 1.1128 ++ attr_t attrs; 1.1129 ++#endif 1.1130 ++ short delim_len = strlen(SidebarDelim); 1.1131 ++ short color_pair; 1.1132 ++ 1.1133 ++ static bool initialized = false; 1.1134 ++ static int prev_show_value; 1.1135 ++ static short saveSidebarWidth; 1.1136 ++ 1.1137 ++ /* initialize first time */ 1.1138 ++ if(!initialized) { 1.1139 ++ prev_show_value = option(OPTSIDEBAR); 1.1140 ++ saveSidebarWidth = SidebarWidth; 1.1141 ++ if(!option(OPTSIDEBAR)) SidebarWidth = 0; 1.1142 ++ initialized = true; 1.1143 ++ } 1.1144 ++ 1.1145 ++ /* save or restore the value SidebarWidth */ 1.1146 ++ if(prev_show_value != option(OPTSIDEBAR)) { 1.1147 ++ if(prev_show_value && !option(OPTSIDEBAR)) { 1.1148 ++ saveSidebarWidth = SidebarWidth; 1.1149 ++ SidebarWidth = 0; 1.1150 ++ } else if(!prev_show_value && option(OPTSIDEBAR)) { 1.1151 ++ SidebarWidth = saveSidebarWidth; 1.1152 ++ } 1.1153 ++ prev_show_value = option(OPTSIDEBAR); 1.1154 ++ } 1.1155 ++ 1.1156 ++ 1.1157 ++// if ( SidebarWidth == 0 ) return 0; 1.1158 ++ if (SidebarWidth > 0 && option (OPTSIDEBAR) 1.1159 ++ && delim_len >= SidebarWidth) { 1.1160 ++ unset_option (OPTSIDEBAR); 1.1161 ++ /* saveSidebarWidth = SidebarWidth; */ 1.1162 ++ if (saveSidebarWidth > delim_len) { 1.1163 ++ SidebarWidth = saveSidebarWidth; 1.1164 ++ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); 1.1165 ++ sleep (2); 1.1166 ++ } else { 1.1167 ++ SidebarWidth = 0; 1.1168 ++ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); 1.1169 ++ sleep (4); /* the advise to set a sane value should be seen long enough */ 1.1170 ++ } 1.1171 ++ saveSidebarWidth = 0; 1.1172 ++ return (0); 1.1173 ++ } 1.1174 ++ 1.1175 ++ if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { 1.1176 ++ if (SidebarWidth > 0) { 1.1177 ++ saveSidebarWidth = SidebarWidth; 1.1178 ++ SidebarWidth = 0; 1.1179 ++ } 1.1180 ++ unset_option(OPTSIDEBAR); 1.1181 ++ return 0; 1.1182 ++ } 1.1183 ++ 1.1184 ++ /* get attributes for divider */ 1.1185 ++ SETCOLOR(MT_COLOR_STATUS); 1.1186 ++#ifndef USE_SLANG_CURSES 1.1187 ++ attr_get(&attrs, &color_pair, 0); 1.1188 ++#else 1.1189 ++ color_pair = attr_get(); 1.1190 ++#endif 1.1191 ++ SETCOLOR(MT_COLOR_NORMAL); 1.1192 ++ 1.1193 ++ /* draw the divider */ 1.1194 ++ 1.1195 ++ for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { 1.1196 ++ move(lines, SidebarWidth - delim_len); 1.1197 ++ addstr(NONULL(SidebarDelim)); 1.1198 ++#ifndef USE_SLANG_CURSES 1.1199 ++ mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); 1.1200 ++#endif 1.1201 ++ } 1.1202 ++ 1.1203 ++ if ( Incoming == 0 ) return 0; 1.1204 ++ lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ 1.1205 ++ 1.1206 ++ if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 1.1207 ++ calc_boundaries(menu); 1.1208 ++ if ( CurBuffy == 0 ) CurBuffy = Incoming; 1.1209 ++ 1.1210 ++ tmp = TopBuffy; 1.1211 ++ 1.1212 ++ SETCOLOR(MT_COLOR_NORMAL); 1.1213 ++ 1.1214 ++ for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { 1.1215 ++ if ( tmp == CurBuffy ) 1.1216 ++ SETCOLOR(MT_COLOR_INDICATOR); 1.1217 ++ else if ( tmp->msg_unread > 0 ) 1.1218 ++ SETCOLOR(MT_COLOR_NEW); 1.1219 ++ else if ( tmp->msg_flagged > 0 ) 1.1220 ++ SETCOLOR(MT_COLOR_FLAGGED); 1.1221 ++ else 1.1222 ++ SETCOLOR(MT_COLOR_NORMAL); 1.1223 ++ 1.1224 ++ move( lines, 0 ); 1.1225 ++ if ( Context && !strcmp( tmp->path, Context->path ) ) { 1.1226 ++ tmp->msg_unread = Context->unread; 1.1227 ++ tmp->msgcount = Context->msgcount; 1.1228 ++ tmp->msg_flagged = Context->flagged; 1.1229 ++ } 1.1230 ++ // check whether Maildir is a prefix of the current folder's path 1.1231 ++ short maildir_is_prefix = 0; 1.1232 ++ if ( (strlen(tmp->path) > strlen(Maildir)) && 1.1233 ++ (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) 1.1234 ++ maildir_is_prefix = 1; 1.1235 ++ // calculate depth of current folder and generate its display name with indented spaces 1.1236 ++ int sidebar_folder_depth = 0; 1.1237 ++ char *sidebar_folder_name; 1.1238 ++ sidebar_folder_name = basename(tmp->path); 1.1239 ++ if ( maildir_is_prefix ) { 1.1240 ++ char *tmp_folder_name; 1.1241 ++ int i; 1.1242 ++ tmp_folder_name = tmp->path + strlen(Maildir); 1.1243 ++ for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { 1.1244 ++ if (tmp_folder_name[i] == '/') sidebar_folder_depth++; 1.1245 ++ } 1.1246 ++ if (sidebar_folder_depth > 0) { 1.1247 ++ sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); 1.1248 ++ for (i=0; i < sidebar_folder_depth; i++) 1.1249 ++ sidebar_folder_name[i]=' '; 1.1250 ++ sidebar_folder_name[i]=0; 1.1251 ++ strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); 1.1252 ++ } 1.1253 ++ } 1.1254 ++ printw( "%.*s", SidebarWidth - delim_len + 1, 1.1255 ++ make_sidebar_entry(sidebar_folder_name, tmp->msgcount, 1.1256 ++ tmp->msg_unread, tmp->msg_flagged)); 1.1257 ++ if (sidebar_folder_depth > 0) 1.1258 ++ free(sidebar_folder_name); 1.1259 ++ lines++; 1.1260 ++ } 1.1261 ++ SETCOLOR(MT_COLOR_NORMAL); 1.1262 ++ for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { 1.1263 ++ int i = 0; 1.1264 ++ move( lines, 0 ); 1.1265 ++ for ( ; i < SidebarWidth - delim_len; i++ ) 1.1266 ++ addch(' '); 1.1267 ++ } 1.1268 ++ return 0; 1.1269 ++} 1.1270 ++ 1.1271 ++ 1.1272 ++void set_buffystats(CONTEXT* Context) 1.1273 ++{ 1.1274 ++ BUFFY *tmp = Incoming; 1.1275 ++ while(tmp) { 1.1276 ++ if(Context && !strcmp(tmp->path, Context->path)) { 1.1277 ++ tmp->msg_unread = Context->unread; 1.1278 ++ tmp->msgcount = Context->msgcount; 1.1279 ++ break; 1.1280 ++ } 1.1281 ++ tmp = tmp->next; 1.1282 ++ } 1.1283 ++} 1.1284 ++ 1.1285 ++void scroll_sidebar(int op, int menu) 1.1286 ++{ 1.1287 ++ if(!SidebarWidth) return; 1.1288 ++ if(!CurBuffy) return; 1.1289 ++ 1.1290 ++ switch (op) { 1.1291 ++ case OP_SIDEBAR_NEXT: 1.1292 ++ if ( CurBuffy->next == NULL ) return; 1.1293 ++ CurBuffy = CurBuffy->next; 1.1294 ++ break; 1.1295 ++ case OP_SIDEBAR_PREV: 1.1296 ++ if ( CurBuffy->prev == NULL ) return; 1.1297 ++ CurBuffy = CurBuffy->prev; 1.1298 ++ break; 1.1299 ++ case OP_SIDEBAR_SCROLL_UP: 1.1300 ++ CurBuffy = TopBuffy; 1.1301 ++ if ( CurBuffy != Incoming ) { 1.1302 ++ calc_boundaries(menu); 1.1303 ++ CurBuffy = CurBuffy->prev; 1.1304 ++ } 1.1305 ++ break; 1.1306 ++ case OP_SIDEBAR_SCROLL_DOWN: 1.1307 ++ CurBuffy = BottomBuffy; 1.1308 ++ if ( CurBuffy->next ) { 1.1309 ++ calc_boundaries(menu); 1.1310 ++ CurBuffy = CurBuffy->next; 1.1311 ++ } 1.1312 ++ break; 1.1313 ++ default: 1.1314 ++ return; 1.1315 ++ } 1.1316 ++ calc_boundaries(menu); 1.1317 ++ draw_sidebar(menu); 1.1318 ++} 1.1319 ++ 1.1320 +Index: sidebar.h 1.1321 +--- sidebar.h.orig 2011-01-17 19:33:15.000000000 +0100 1.1322 ++++ sidebar.h 2011-01-17 19:33:15.000000000 +0100 1.1323 +@@ -0,0 +1,36 @@ 1.1324 ++/* 1.1325 ++ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> 1.1326 ++ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> 1.1327 ++ * 1.1328 ++ * This program is free software; you can redistribute it and/or modify 1.1329 ++ * it under the terms of the GNU General Public License as published by 1.1330 ++ * the Free Software Foundation; either version 2 of the License, or 1.1331 ++ * (at your option) any later version. 1.1332 ++ * 1.1333 ++ * This program is distributed in the hope that it will be useful, 1.1334 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of 1.1335 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.1336 ++ * GNU General Public License for more details. 1.1337 ++ * 1.1338 ++ * You should have received a copy of the GNU General Public License 1.1339 ++ * along with this program; if not, write to the Free Software 1.1340 ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 1.1341 ++ */ 1.1342 ++ 1.1343 ++#ifndef SIDEBAR_H 1.1344 ++#define SIDEBAR_H 1.1345 ++ 1.1346 ++struct MBOX_LIST { 1.1347 ++ char *path; 1.1348 ++ int msgcount; 1.1349 ++ int new; 1.1350 ++} MBLIST; 1.1351 ++ 1.1352 ++/* parameter is whether or not to go to the status line */ 1.1353 ++/* used for omitting the last | that covers up the status bar in the index */ 1.1354 ++int draw_sidebar(int); 1.1355 ++void scroll_sidebar(int, int); 1.1356 ++void set_curbuffy(char*); 1.1357 ++void set_buffystats(CONTEXT*); 1.1358 ++ 1.1359 ++#endif /* SIDEBAR_H */ 1.1360 + 1.1361 +============================================================================== 1.1362 + 1.1363 +Fix drawing of sidebar delimiter with the intended 1.1364 +attributes of the "status" bar --rse 20070906 1.1365 + 1.1366 +Index: sidebar.c 1.1367 +--- sidebar.c.orig 2007-11-04 15:05:17 +0100 1.1368 ++++ sidebar.c 2007-11-04 15:05:17 +0100 1.1369 +@@ -186,23 +186,14 @@ 1.1370 + return 0; 1.1371 + } 1.1372 + 1.1373 +- /* get attributes for divider */ 1.1374 +- SETCOLOR(MT_COLOR_STATUS); 1.1375 +-#ifndef USE_SLANG_CURSES 1.1376 +- attr_get(&attrs, &color_pair, 0); 1.1377 +-#else 1.1378 +- color_pair = attr_get(); 1.1379 +-#endif 1.1380 +- SETCOLOR(MT_COLOR_NORMAL); 1.1381 + 1.1382 + /* draw the divider */ 1.1383 + 1.1384 + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { 1.1385 ++ SETCOLOR(MT_COLOR_STATUS); 1.1386 + move(lines, SidebarWidth - delim_len); 1.1387 + addstr(NONULL(SidebarDelim)); 1.1388 +-#ifndef USE_SLANG_CURSES 1.1389 +- mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); 1.1390 +-#endif 1.1391 ++ SETCOLOR(MT_COLOR_NORMAL); 1.1392 + } 1.1393 + 1.1394 + if ( Incoming == 0 ) return 0;