Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
michael@478 | 1 | The Mutt "sidebar" patch as taken over by Debian for Mutt 1.5.21 |
michael@478 | 2 | but with the patches for Makefile.in applied again. |
michael@478 | 3 | |
michael@478 | 4 | Index: Makefile.am |
michael@478 | 5 | --- Makefile.am.orig 2010-08-24 18:34:21.000000000 +0200 |
michael@478 | 6 | +++ Makefile.am 2011-01-17 19:33:57.000000000 +0100 |
michael@478 | 7 | @@ -33,7 +33,7 @@ |
michael@478 | 8 | score.c send.c sendlib.c signal.c sort.c \ |
michael@478 | 9 | status.c system.c thread.c charset.c history.c lib.c \ |
michael@478 | 10 | muttlib.c editmsg.c mbyte.c \ |
michael@478 | 11 | - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c |
michael@478 | 12 | + url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c |
michael@478 | 13 | |
michael@478 | 14 | nodist_mutt_SOURCES = $(BUILT_SOURCES) |
michael@478 | 15 | |
michael@478 | 16 | Index: Makefile.in |
michael@478 | 17 | --- Makefile.in.orig 2010-08-25 18:31:48.000000000 +0200 |
michael@478 | 18 | +++ Makefile.in 2011-01-17 19:33:57.000000000 +0100 |
michael@478 | 19 | @@ -85,7 +85,7 @@ |
michael@478 | 20 | system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \ |
michael@478 | 21 | history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \ |
michael@478 | 22 | editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \ |
michael@478 | 23 | - ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) |
michael@478 | 24 | + ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT) |
michael@478 | 25 | am__objects_1 = |
michael@478 | 26 | am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1) |
michael@478 | 27 | nodist_mutt_OBJECTS = $(am__objects_2) |
michael@478 | 28 | @@ -359,7 +359,7 @@ |
michael@478 | 29 | score.c send.c sendlib.c signal.c sort.c \ |
michael@478 | 30 | status.c system.c thread.c charset.c history.c lib.c \ |
michael@478 | 31 | muttlib.c editmsg.c mbyte.c \ |
michael@478 | 32 | - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c |
michael@478 | 33 | + url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c |
michael@478 | 34 | |
michael@478 | 35 | nodist_mutt_SOURCES = $(BUILT_SOURCES) |
michael@478 | 36 | mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \ |
michael@478 | 37 | @@ -391,7 +391,7 @@ |
michael@478 | 38 | README.SSL smime.h group.h \ |
michael@478 | 39 | muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \ |
michael@478 | 40 | ChangeLog mkchangelog.sh mutt_idna.h \ |
michael@478 | 41 | - snprintf.c regex.c crypt-gpgme.h hcachever.sh.in |
michael@478 | 42 | + snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in |
michael@478 | 43 | |
michael@478 | 44 | EXTRA_SCRIPTS = smime_keys |
michael@478 | 45 | mutt_dotlock_SOURCES = mutt_dotlock.c |
michael@478 | 46 | Index: OPS |
michael@478 | 47 | --- OPS.orig 2010-03-01 18:56:19.000000000 +0100 |
michael@478 | 48 | +++ OPS 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 49 | @@ -179,3 +179,8 @@ |
michael@478 | 50 | OP_MAIN_SHOW_LIMIT "show currently active limit pattern" |
michael@478 | 51 | OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" |
michael@478 | 52 | OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" |
michael@478 | 53 | +OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" |
michael@478 | 54 | +OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" |
michael@478 | 55 | +OP_SIDEBAR_NEXT "go down to next mailbox" |
michael@478 | 56 | +OP_SIDEBAR_PREV "go to previous mailbox" |
michael@478 | 57 | +OP_SIDEBAR_OPEN "open hilighted mailbox" |
michael@478 | 58 | Index: buffy.c |
michael@478 | 59 | --- buffy.c.orig 2010-09-13 19:19:55.000000000 +0200 |
michael@478 | 60 | +++ buffy.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 61 | @@ -312,6 +312,10 @@ |
michael@478 | 62 | return 0; |
michael@478 | 63 | } |
michael@478 | 64 | |
michael@478 | 65 | + mailbox->msgcount = 0; |
michael@478 | 66 | + mailbox->msg_unread = 0; |
michael@478 | 67 | + mailbox->msg_flagged = 0; |
michael@478 | 68 | + |
michael@478 | 69 | while ((de = readdir (dirp)) != NULL) |
michael@478 | 70 | { |
michael@478 | 71 | if (*de->d_name == '.') |
michael@478 | 72 | @@ -329,7 +333,9 @@ |
michael@478 | 73 | continue; |
michael@478 | 74 | } |
michael@478 | 75 | /* one new and undeleted message is enough */ |
michael@478 | 76 | - mailbox->new = 1; |
michael@478 | 77 | + mailbox->has_new = mailbox->new = 1; |
michael@478 | 78 | + mailbox->msgcount++; |
michael@478 | 79 | + mailbox->msg_unread++; |
michael@478 | 80 | rc = 1; |
michael@478 | 81 | break; |
michael@478 | 82 | } |
michael@478 | 83 | @@ -337,6 +343,32 @@ |
michael@478 | 84 | |
michael@478 | 85 | closedir (dirp); |
michael@478 | 86 | |
michael@478 | 87 | + /* |
michael@478 | 88 | + * count read messages (for folderlist (sidebar) we also need to count |
michael@478 | 89 | + * messages in cur so that we the total number of messages |
michael@478 | 90 | + */ |
michael@478 | 91 | + snprintf (path, sizeof (path), "%s/cur", mailbox->path); |
michael@478 | 92 | + if ((dirp = opendir (path)) == NULL) |
michael@478 | 93 | + { |
michael@478 | 94 | + mailbox->magic = 0; |
michael@478 | 95 | + } |
michael@478 | 96 | + while ((de = readdir (dirp)) != NULL) |
michael@478 | 97 | + { |
michael@478 | 98 | + char *p; |
michael@478 | 99 | + if (*de->d_name != '.') { |
michael@478 | 100 | + if ((p = strstr (de->d_name, ":2,"))) { |
michael@478 | 101 | + if (!strchr (p + 3, 'T')) { |
michael@478 | 102 | + mailbox->msgcount++; |
michael@478 | 103 | + if ( !strchr (p + 3, 'S')) |
michael@478 | 104 | + mailbox->msg_unread++; |
michael@478 | 105 | + if (strchr(p + 3, 'F')) |
michael@478 | 106 | + mailbox->msg_flagged++; |
michael@478 | 107 | + } |
michael@478 | 108 | + } else |
michael@478 | 109 | + mailbox->msgcount++; |
michael@478 | 110 | + } |
michael@478 | 111 | + } |
michael@478 | 112 | + |
michael@478 | 113 | return rc; |
michael@478 | 114 | } |
michael@478 | 115 | |
michael@478 | 116 | @@ -345,14 +377,33 @@ |
michael@478 | 117 | { |
michael@478 | 118 | int rc = 0; |
michael@478 | 119 | int statcheck; |
michael@478 | 120 | + CONTEXT *ctx; |
michael@478 | 121 | |
michael@478 | 122 | if (option (OPTCHECKMBOXSIZE)) |
michael@478 | 123 | statcheck = sb->st_size > mailbox->size; |
michael@478 | 124 | else |
michael@478 | 125 | statcheck = sb->st_mtime > sb->st_atime |
michael@478 | 126 | || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime); |
michael@478 | 127 | - if (statcheck) |
michael@478 | 128 | + if (statcheck || mailbox->msgcount == 0) |
michael@478 | 129 | { |
michael@478 | 130 | + BUFFY b = *mailbox; |
michael@478 | 131 | + int msgcount = 0; |
michael@478 | 132 | + int msg_unread = 0; |
michael@478 | 133 | + /* parse the mailbox, to see how much mail there is */ |
michael@478 | 134 | + ctx = mx_open_mailbox( mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); |
michael@478 | 135 | + if(ctx) |
michael@478 | 136 | + { |
michael@478 | 137 | + msgcount = ctx->msgcount; |
michael@478 | 138 | + msg_unread = ctx->unread; |
michael@478 | 139 | + mx_close_mailbox(ctx, 0); |
michael@478 | 140 | + } |
michael@478 | 141 | + *mailbox = b; |
michael@478 | 142 | + mailbox->msgcount = msgcount; |
michael@478 | 143 | + mailbox->msg_unread = msg_unread; |
michael@478 | 144 | + if(statcheck) |
michael@478 | 145 | + { |
michael@478 | 146 | + mailbox->has_new = mailbox->new = 1; |
michael@478 | 147 | + } |
michael@478 | 148 | if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited) |
michael@478 | 149 | { |
michael@478 | 150 | rc = 1; |
michael@478 | 151 | @@ -374,9 +425,11 @@ |
michael@478 | 152 | int mutt_buffy_check (int force) |
michael@478 | 153 | { |
michael@478 | 154 | BUFFY *tmp; |
michael@478 | 155 | + struct dirent *de, *dp; |
michael@478 | 156 | struct stat sb; |
michael@478 | 157 | struct stat contex_sb; |
michael@478 | 158 | time_t t; |
michael@478 | 159 | + CONTEXT *ctx; |
michael@478 | 160 | |
michael@478 | 161 | sb.st_size=0; |
michael@478 | 162 | contex_sb.st_dev=0; |
michael@478 | 163 | @@ -456,6 +509,20 @@ |
michael@478 | 164 | case M_MH: |
michael@478 | 165 | if ((tmp->new = mh_buffy (tmp->path)) > 0) |
michael@478 | 166 | BuffyCount++; |
michael@478 | 167 | + |
michael@478 | 168 | + if ((dp = opendir (tmp->path)) == NULL) |
michael@478 | 169 | + break; |
michael@478 | 170 | + tmp->msgcount = 0; |
michael@478 | 171 | + while ((de = readdir (dp))) |
michael@478 | 172 | + { |
michael@478 | 173 | + if (mh_valid_message (de->d_name)) |
michael@478 | 174 | + { |
michael@478 | 175 | + tmp->msgcount++; |
michael@478 | 176 | + tmp->has_new = tmp->new = 1; |
michael@478 | 177 | + } |
michael@478 | 178 | + } |
michael@478 | 179 | + closedir (dp); |
michael@478 | 180 | + |
michael@478 | 181 | break; |
michael@478 | 182 | } |
michael@478 | 183 | } |
michael@478 | 184 | Index: buffy.h |
michael@478 | 185 | --- buffy.h.orig 2010-09-13 19:19:55.000000000 +0200 |
michael@478 | 186 | +++ buffy.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 187 | @@ -25,7 +25,12 @@ |
michael@478 | 188 | char path[_POSIX_PATH_MAX]; |
michael@478 | 189 | off_t size; |
michael@478 | 190 | struct buffy_t *next; |
michael@478 | 191 | + struct buffy_t *prev; |
michael@478 | 192 | short new; /* mailbox has new mail */ |
michael@478 | 193 | + short has_new; /* set it new if new and not read */ |
michael@478 | 194 | + int msgcount; /* total number of messages */ |
michael@478 | 195 | + int msg_unread; /* number of unread messages */ |
michael@478 | 196 | + int msg_flagged; /* number of flagged messages */ |
michael@478 | 197 | short notified; /* user has been notified */ |
michael@478 | 198 | short magic; /* mailbox type */ |
michael@478 | 199 | short newly_created; /* mbox or mmdf just popped into existence */ |
michael@478 | 200 | Index: color.c |
michael@478 | 201 | --- color.c.orig 2009-05-15 19:18:23.000000000 +0200 |
michael@478 | 202 | +++ color.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 203 | @@ -93,6 +93,8 @@ |
michael@478 | 204 | { "bold", MT_COLOR_BOLD }, |
michael@478 | 205 | { "underline", MT_COLOR_UNDERLINE }, |
michael@478 | 206 | { "index", MT_COLOR_INDEX }, |
michael@478 | 207 | + { "sidebar_new", MT_COLOR_NEW }, |
michael@478 | 208 | + { "sidebar_flagged", MT_COLOR_FLAGGED }, |
michael@478 | 209 | { NULL, 0 } |
michael@478 | 210 | }; |
michael@478 | 211 | |
michael@478 | 212 | Index: compose.c |
michael@478 | 213 | --- compose.c.orig 2010-04-14 20:50:19.000000000 +0200 |
michael@478 | 214 | +++ compose.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 215 | @@ -72,7 +72,7 @@ |
michael@478 | 216 | |
michael@478 | 217 | #define HDR_XOFFSET 10 |
michael@478 | 218 | #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ |
michael@478 | 219 | -#define W (COLS - HDR_XOFFSET) |
michael@478 | 220 | +#define W (COLS - HDR_XOFFSET - SidebarWidth) |
michael@478 | 221 | |
michael@478 | 222 | static char *Prompts[] = |
michael@478 | 223 | { |
michael@478 | 224 | @@ -112,7 +112,7 @@ |
michael@478 | 225 | { |
michael@478 | 226 | int off = 0; |
michael@478 | 227 | |
michael@478 | 228 | - mvaddstr (HDR_CRYPT, 0, "Security: "); |
michael@478 | 229 | + mvaddstr (HDR_CRYPT, SidebarWidth, "Security: "); |
michael@478 | 230 | |
michael@478 | 231 | if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) |
michael@478 | 232 | { |
michael@478 | 233 | @@ -144,7 +144,7 @@ |
michael@478 | 234 | } |
michael@478 | 235 | |
michael@478 | 236 | clrtoeol (); |
michael@478 | 237 | - move (HDR_CRYPTINFO, 0); |
michael@478 | 238 | + move (HDR_CRYPTINFO, SidebarWidth); |
michael@478 | 239 | clrtoeol (); |
michael@478 | 240 | |
michael@478 | 241 | if ((WithCrypto & APPLICATION_PGP) |
michael@478 | 242 | @@ -161,7 +161,7 @@ |
michael@478 | 243 | && (msg->security & ENCRYPT) |
michael@478 | 244 | && SmimeCryptAlg |
michael@478 | 245 | && *SmimeCryptAlg) { |
michael@478 | 246 | - mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), |
michael@478 | 247 | + mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "), |
michael@478 | 248 | NONULL(SmimeCryptAlg)); |
michael@478 | 249 | off = 20; |
michael@478 | 250 | } |
michael@478 | 251 | @@ -175,7 +175,7 @@ |
michael@478 | 252 | int c; |
michael@478 | 253 | char *t; |
michael@478 | 254 | |
michael@478 | 255 | - mvaddstr (HDR_MIX, 0, " Mix: "); |
michael@478 | 256 | + mvaddstr (HDR_MIX, SidebarWidth, " Mix: "); |
michael@478 | 257 | |
michael@478 | 258 | if (!chain) |
michael@478 | 259 | { |
michael@478 | 260 | @@ -190,7 +190,7 @@ |
michael@478 | 261 | if (t && t[0] == '0' && t[1] == '\0') |
michael@478 | 262 | t = "<random>"; |
michael@478 | 263 | |
michael@478 | 264 | - if (c + mutt_strlen (t) + 2 >= COLS) |
michael@478 | 265 | + if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth) |
michael@478 | 266 | break; |
michael@478 | 267 | |
michael@478 | 268 | addstr (NONULL(t)); |
michael@478 | 269 | @@ -242,7 +242,7 @@ |
michael@478 | 270 | |
michael@478 | 271 | buf[0] = 0; |
michael@478 | 272 | rfc822_write_address (buf, sizeof (buf), addr, 1); |
michael@478 | 273 | - mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); |
michael@478 | 274 | + mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]); |
michael@478 | 275 | mutt_paddstr (W, buf); |
michael@478 | 276 | } |
michael@478 | 277 | |
michael@478 | 278 | @@ -252,10 +252,10 @@ |
michael@478 | 279 | draw_envelope_addr (HDR_TO, msg->env->to); |
michael@478 | 280 | draw_envelope_addr (HDR_CC, msg->env->cc); |
michael@478 | 281 | draw_envelope_addr (HDR_BCC, msg->env->bcc); |
michael@478 | 282 | - mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); |
michael@478 | 283 | + mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); |
michael@478 | 284 | mutt_paddstr (W, NONULL (msg->env->subject)); |
michael@478 | 285 | draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); |
michael@478 | 286 | - mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]); |
michael@478 | 287 | + mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]); |
michael@478 | 288 | mutt_paddstr (W, fcc); |
michael@478 | 289 | |
michael@478 | 290 | if (WithCrypto) |
michael@478 | 291 | @@ -266,7 +266,7 @@ |
michael@478 | 292 | #endif |
michael@478 | 293 | |
michael@478 | 294 | SETCOLOR (MT_COLOR_STATUS); |
michael@478 | 295 | - mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); |
michael@478 | 296 | + mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments")); |
michael@478 | 297 | BKGDSET (MT_COLOR_STATUS); |
michael@478 | 298 | clrtoeol (); |
michael@478 | 299 | |
michael@478 | 300 | @@ -304,7 +304,7 @@ |
michael@478 | 301 | /* redraw the expanded list so the user can see the result */ |
michael@478 | 302 | buf[0] = 0; |
michael@478 | 303 | rfc822_write_address (buf, sizeof (buf), *addr, 1); |
michael@478 | 304 | - move (line, HDR_XOFFSET); |
michael@478 | 305 | + move (line, HDR_XOFFSET+SidebarWidth); |
michael@478 | 306 | mutt_paddstr (W, buf); |
michael@478 | 307 | |
michael@478 | 308 | return 0; |
michael@478 | 309 | @@ -549,7 +549,7 @@ |
michael@478 | 310 | if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) |
michael@478 | 311 | { |
michael@478 | 312 | mutt_str_replace (&msg->env->subject, buf); |
michael@478 | 313 | - move (HDR_SUBJECT, HDR_XOFFSET); |
michael@478 | 314 | + move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth); |
michael@478 | 315 | clrtoeol (); |
michael@478 | 316 | if (msg->env->subject) |
michael@478 | 317 | mutt_paddstr (W, msg->env->subject); |
michael@478 | 318 | @@ -566,7 +566,7 @@ |
michael@478 | 319 | { |
michael@478 | 320 | strfcpy (fcc, buf, fcclen); |
michael@478 | 321 | mutt_pretty_mailbox (fcc, fcclen); |
michael@478 | 322 | - move (HDR_FCC, HDR_XOFFSET); |
michael@478 | 323 | + move (HDR_FCC, HDR_XOFFSET + SidebarWidth); |
michael@478 | 324 | mutt_paddstr (W, fcc); |
michael@478 | 325 | fccSet = 1; |
michael@478 | 326 | } |
michael@478 | 327 | Index: curs_main.c |
michael@478 | 328 | --- curs_main.c.orig 2010-09-13 19:19:55.000000000 +0200 |
michael@478 | 329 | +++ curs_main.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 330 | @@ -26,7 +26,9 @@ |
michael@478 | 331 | #include "mailbox.h" |
michael@478 | 332 | #include "mapping.h" |
michael@478 | 333 | #include "sort.h" |
michael@478 | 334 | +#include "buffy.h" |
michael@478 | 335 | #include "mx.h" |
michael@478 | 336 | +#include "sidebar.h" |
michael@478 | 337 | |
michael@478 | 338 | #ifdef USE_POP |
michael@478 | 339 | #include "pop.h" |
michael@478 | 340 | @@ -519,8 +521,12 @@ |
michael@478 | 341 | menu->redraw |= REDRAW_STATUS; |
michael@478 | 342 | if (do_buffy_notify) |
michael@478 | 343 | { |
michael@478 | 344 | - if (mutt_buffy_notify () && option (OPTBEEPNEW)) |
michael@478 | 345 | - beep (); |
michael@478 | 346 | + if (mutt_buffy_notify ()) |
michael@478 | 347 | + { |
michael@478 | 348 | + menu->redraw |= REDRAW_FULL; |
michael@478 | 349 | + if (option (OPTBEEPNEW)) |
michael@478 | 350 | + beep (); |
michael@478 | 351 | + } |
michael@478 | 352 | } |
michael@478 | 353 | else |
michael@478 | 354 | do_buffy_notify = 1; |
michael@478 | 355 | @@ -532,6 +538,7 @@ |
michael@478 | 356 | if (menu->redraw & REDRAW_FULL) |
michael@478 | 357 | { |
michael@478 | 358 | menu_redraw_full (menu); |
michael@478 | 359 | + draw_sidebar(menu->menu); |
michael@478 | 360 | mutt_show_error (); |
michael@478 | 361 | } |
michael@478 | 362 | |
michael@478 | 363 | @@ -554,10 +561,13 @@ |
michael@478 | 364 | |
michael@478 | 365 | if (menu->redraw & REDRAW_STATUS) |
michael@478 | 366 | { |
michael@478 | 367 | + DrawFullLine = 1; |
michael@478 | 368 | menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); |
michael@478 | 369 | + DrawFullLine = 0; |
michael@478 | 370 | CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2); |
michael@478 | 371 | SETCOLOR (MT_COLOR_STATUS); |
michael@478 | 372 | BKGDSET (MT_COLOR_STATUS); |
michael@478 | 373 | + set_buffystats(Context); |
michael@478 | 374 | mutt_paddstr (COLS, buf); |
michael@478 | 375 | SETCOLOR (MT_COLOR_NORMAL); |
michael@478 | 376 | BKGDSET (MT_COLOR_NORMAL); |
michael@478 | 377 | @@ -571,7 +581,7 @@ |
michael@478 | 378 | menu->oldcurrent = -1; |
michael@478 | 379 | |
michael@478 | 380 | if (option (OPTARROWCURSOR)) |
michael@478 | 381 | - move (menu->current - menu->top + menu->offset, 2); |
michael@478 | 382 | + move (menu->current - menu->top + menu->offset, SidebarWidth + 2); |
michael@478 | 383 | else if (option (OPTBRAILLEFRIENDLY)) |
michael@478 | 384 | move (menu->current - menu->top + menu->offset, 0); |
michael@478 | 385 | else |
michael@478 | 386 | @@ -1069,6 +1079,7 @@ |
michael@478 | 387 | menu->redraw = REDRAW_FULL; |
michael@478 | 388 | break; |
michael@478 | 389 | |
michael@478 | 390 | + case OP_SIDEBAR_OPEN: |
michael@478 | 391 | case OP_MAIN_CHANGE_FOLDER: |
michael@478 | 392 | case OP_MAIN_NEXT_UNREAD_MAILBOX: |
michael@478 | 393 | |
michael@478 | 394 | @@ -1100,7 +1111,11 @@ |
michael@478 | 395 | { |
michael@478 | 396 | mutt_buffy (buf, sizeof (buf)); |
michael@478 | 397 | |
michael@478 | 398 | - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) |
michael@478 | 399 | + if ( op == OP_SIDEBAR_OPEN ) { |
michael@478 | 400 | + if(!CurBuffy) |
michael@478 | 401 | + break; |
michael@478 | 402 | + strncpy( buf, CurBuffy->path, sizeof(buf) ); |
michael@478 | 403 | + } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) |
michael@478 | 404 | { |
michael@478 | 405 | if (menu->menu == MENU_PAGER) |
michael@478 | 406 | { |
michael@478 | 407 | @@ -1118,6 +1133,7 @@ |
michael@478 | 408 | } |
michael@478 | 409 | |
michael@478 | 410 | mutt_expand_path (buf, sizeof (buf)); |
michael@478 | 411 | + set_curbuffy(buf); |
michael@478 | 412 | if (mx_get_magic (buf) <= 0) |
michael@478 | 413 | { |
michael@478 | 414 | mutt_error (_("%s is not a mailbox."), buf); |
michael@478 | 415 | @@ -2208,6 +2224,12 @@ |
michael@478 | 416 | mutt_what_key(); |
michael@478 | 417 | break; |
michael@478 | 418 | |
michael@478 | 419 | + case OP_SIDEBAR_SCROLL_UP: |
michael@478 | 420 | + case OP_SIDEBAR_SCROLL_DOWN: |
michael@478 | 421 | + case OP_SIDEBAR_NEXT: |
michael@478 | 422 | + case OP_SIDEBAR_PREV: |
michael@478 | 423 | + scroll_sidebar(op, menu->menu); |
michael@478 | 424 | + break; |
michael@478 | 425 | default: |
michael@478 | 426 | if (menu->menu == MENU_MAIN) |
michael@478 | 427 | km_error_key (MENU_MAIN); |
michael@478 | 428 | Index: doc/Muttrc |
michael@478 | 429 | --- doc/Muttrc.orig 2010-09-15 19:07:19.000000000 +0200 |
michael@478 | 430 | +++ doc/Muttrc 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 431 | @@ -657,6 +657,26 @@ |
michael@478 | 432 | # $crypt_autosign, $crypt_replysign and $smime_is_default. |
michael@478 | 433 | # |
michael@478 | 434 | # |
michael@478 | 435 | +# set sidebar_visible=no |
michael@478 | 436 | +# |
michael@478 | 437 | +# Name: sidebar_visible |
michael@478 | 438 | +# Type: boolean |
michael@478 | 439 | +# Default: no |
michael@478 | 440 | +# |
michael@478 | 441 | +# |
michael@478 | 442 | +# This specifies whether or not to show sidebar (left-side list of folders). |
michael@478 | 443 | +# |
michael@478 | 444 | +# |
michael@478 | 445 | +# set sidebar_width=0 |
michael@478 | 446 | +# |
michael@478 | 447 | +# Name: sidebar_width |
michael@478 | 448 | +# Type: number |
michael@478 | 449 | +# Default: 0 |
michael@478 | 450 | +# |
michael@478 | 451 | +# |
michael@478 | 452 | +# The width of the sidebar. |
michael@478 | 453 | +# |
michael@478 | 454 | +# |
michael@478 | 455 | # set crypt_autosign=no |
michael@478 | 456 | # |
michael@478 | 457 | # Name: crypt_autosign |
michael@478 | 458 | Index: flags.c |
michael@478 | 459 | --- flags.c.orig 2009-01-04 00:27:10.000000000 +0100 |
michael@478 | 460 | +++ flags.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 461 | @@ -22,8 +22,10 @@ |
michael@478 | 462 | |
michael@478 | 463 | #include "mutt.h" |
michael@478 | 464 | #include "mutt_curses.h" |
michael@478 | 465 | +#include "mutt_menu.h" |
michael@478 | 466 | #include "sort.h" |
michael@478 | 467 | #include "mx.h" |
michael@478 | 468 | +#include "sidebar.h" |
michael@478 | 469 | |
michael@478 | 470 | void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) |
michael@478 | 471 | { |
michael@478 | 472 | @@ -263,6 +265,7 @@ |
michael@478 | 473 | */ |
michael@478 | 474 | if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) |
michael@478 | 475 | h->searched = 0; |
michael@478 | 476 | + draw_sidebar(0); |
michael@478 | 477 | } |
michael@478 | 478 | |
michael@478 | 479 | void mutt_tag_set_flag (int flag, int bf) |
michael@478 | 480 | Index: functions.h |
michael@478 | 481 | --- functions.h.orig 2010-08-24 18:34:21.000000000 +0200 |
michael@478 | 482 | +++ functions.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 483 | @@ -169,6 +169,11 @@ |
michael@478 | 484 | { "decrypt-save", OP_DECRYPT_SAVE, NULL }, |
michael@478 | 485 | |
michael@478 | 486 | |
michael@478 | 487 | + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, |
michael@478 | 488 | + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, |
michael@478 | 489 | + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, |
michael@478 | 490 | + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, |
michael@478 | 491 | + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, |
michael@478 | 492 | { NULL, 0, NULL } |
michael@478 | 493 | }; |
michael@478 | 494 | |
michael@478 | 495 | @@ -272,6 +277,11 @@ |
michael@478 | 496 | |
michael@478 | 497 | { "what-key", OP_WHAT_KEY, NULL }, |
michael@478 | 498 | |
michael@478 | 499 | + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, |
michael@478 | 500 | + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, |
michael@478 | 501 | + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, |
michael@478 | 502 | + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, |
michael@478 | 503 | + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, |
michael@478 | 504 | { NULL, 0, NULL } |
michael@478 | 505 | }; |
michael@478 | 506 | |
michael@478 | 507 | Index: globals.h |
michael@478 | 508 | --- globals.h.orig 2009-08-25 21:08:52.000000000 +0200 |
michael@478 | 509 | +++ globals.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 510 | @@ -117,6 +117,7 @@ |
michael@478 | 511 | WHERE char *SendCharset; |
michael@478 | 512 | WHERE char *Sendmail; |
michael@478 | 513 | WHERE char *Shell; |
michael@478 | 514 | +WHERE char *SidebarDelim; |
michael@478 | 515 | WHERE char *Signature; |
michael@478 | 516 | WHERE char *SimpleSearch; |
michael@478 | 517 | #if USE_SMTP |
michael@478 | 518 | @@ -207,6 +208,9 @@ |
michael@478 | 519 | WHERE short ScoreThresholdRead; |
michael@478 | 520 | WHERE short ScoreThresholdFlag; |
michael@478 | 521 | |
michael@478 | 522 | +WHERE struct buffy_t *CurBuffy INITVAL(0); |
michael@478 | 523 | +WHERE short DrawFullLine INITVAL(0); |
michael@478 | 524 | +WHERE short SidebarWidth; |
michael@478 | 525 | #ifdef USE_IMAP |
michael@478 | 526 | WHERE short ImapKeepalive; |
michael@478 | 527 | WHERE short ImapPipelineDepth; |
michael@478 | 528 | Index: imap/command.c |
michael@478 | 529 | --- imap/command.c.orig 2010-09-15 17:39:31.000000000 +0200 |
michael@478 | 530 | +++ imap/command.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 531 | @@ -1011,6 +1011,13 @@ |
michael@478 | 532 | opened */ |
michael@478 | 533 | status->uidnext = oldun; |
michael@478 | 534 | |
michael@478 | 535 | + /* Added to make the sidebar show the correct numbers */ |
michael@478 | 536 | + if (status->messages) |
michael@478 | 537 | + { |
michael@478 | 538 | + inc->msgcount = status->messages; |
michael@478 | 539 | + inc->msg_unread = status->unseen; |
michael@478 | 540 | + } |
michael@478 | 541 | + |
michael@478 | 542 | FREE (&value); |
michael@478 | 543 | return; |
michael@478 | 544 | } |
michael@478 | 545 | Index: imap/imap.c |
michael@478 | 546 | --- imap/imap.c.orig 2009-08-25 21:08:52.000000000 +0200 |
michael@478 | 547 | +++ imap/imap.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 548 | @@ -1521,7 +1521,7 @@ |
michael@478 | 549 | |
michael@478 | 550 | imap_munge_mbox_name (munged, sizeof (munged), name); |
michael@478 | 551 | snprintf (command, sizeof (command), |
michael@478 | 552 | - "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); |
michael@478 | 553 | + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); |
michael@478 | 554 | |
michael@478 | 555 | if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) |
michael@478 | 556 | { |
michael@478 | 557 | Index: init.h |
michael@478 | 558 | --- init.h.orig 2010-09-15 17:39:31.000000000 +0200 |
michael@478 | 559 | +++ init.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 560 | @@ -1953,6 +1953,22 @@ |
michael@478 | 561 | ** not used. |
michael@478 | 562 | ** (PGP only) |
michael@478 | 563 | */ |
michael@478 | 564 | + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, |
michael@478 | 565 | + /* |
michael@478 | 566 | + ** .pp |
michael@478 | 567 | + ** This specifies the delimiter between the sidebar (if visible) and |
michael@478 | 568 | + ** other screens. |
michael@478 | 569 | + */ |
michael@478 | 570 | + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, |
michael@478 | 571 | + /* |
michael@478 | 572 | + ** .pp |
michael@478 | 573 | + ** This specifies whether or not to show sidebar (left-side list of folders). |
michael@478 | 574 | + */ |
michael@478 | 575 | + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, |
michael@478 | 576 | + /* |
michael@478 | 577 | + ** .pp |
michael@478 | 578 | + ** The width of the sidebar. |
michael@478 | 579 | + */ |
michael@478 | 580 | { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, |
michael@478 | 581 | /* |
michael@478 | 582 | ** .pp |
michael@478 | 583 | Index: mailbox.h |
michael@478 | 584 | --- mailbox.h.orig 2009-04-30 19:33:48.000000000 +0200 |
michael@478 | 585 | +++ mailbox.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 586 | @@ -27,6 +27,7 @@ |
michael@478 | 587 | #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses |
michael@478 | 588 | * safe_fopen() for mbox-style folders. |
michael@478 | 589 | */ |
michael@478 | 590 | +#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ |
michael@478 | 591 | |
michael@478 | 592 | /* mx_open_new_message() */ |
michael@478 | 593 | #define M_ADD_FROM 1 /* add a From_ line */ |
michael@478 | 594 | Index: mbox.c |
michael@478 | 595 | --- mbox.c.orig 2010-09-13 19:19:55.000000000 +0200 |
michael@478 | 596 | +++ mbox.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 597 | @@ -100,6 +100,7 @@ |
michael@478 | 598 | mutt_perror (ctx->path); |
michael@478 | 599 | return (-1); |
michael@478 | 600 | } |
michael@478 | 601 | + ctx->atime = sb.st_atime; |
michael@478 | 602 | ctx->mtime = sb.st_mtime; |
michael@478 | 603 | ctx->size = sb.st_size; |
michael@478 | 604 | |
michael@478 | 605 | @@ -251,6 +252,7 @@ |
michael@478 | 606 | |
michael@478 | 607 | ctx->size = sb.st_size; |
michael@478 | 608 | ctx->mtime = sb.st_mtime; |
michael@478 | 609 | + ctx->atime = sb.st_atime; |
michael@478 | 610 | |
michael@478 | 611 | #ifdef NFS_ATTRIBUTE_HACK |
michael@478 | 612 | if (sb.st_mtime > sb.st_atime) |
michael@478 | 613 | Index: menu.c |
michael@478 | 614 | --- menu.c.orig 2010-08-25 18:31:40.000000000 +0200 |
michael@478 | 615 | +++ menu.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 616 | @@ -24,6 +24,7 @@ |
michael@478 | 617 | #include "mutt_curses.h" |
michael@478 | 618 | #include "mutt_menu.h" |
michael@478 | 619 | #include "mbyte.h" |
michael@478 | 620 | +#include "sidebar.h" |
michael@478 | 621 | |
michael@478 | 622 | #include <string.h> |
michael@478 | 623 | #include <stdlib.h> |
michael@478 | 624 | @@ -156,7 +157,7 @@ |
michael@478 | 625 | { |
michael@478 | 626 | char *scratch = safe_strdup (s); |
michael@478 | 627 | int shift = option (OPTARROWCURSOR) ? 3 : 0; |
michael@478 | 628 | - int cols = COLS - shift; |
michael@478 | 629 | + int cols = COLS - shift - SidebarWidth; |
michael@478 | 630 | |
michael@478 | 631 | mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); |
michael@478 | 632 | s[n - 1] = 0; |
michael@478 | 633 | @@ -207,6 +208,7 @@ |
michael@478 | 634 | char buf[LONG_STRING]; |
michael@478 | 635 | int i; |
michael@478 | 636 | |
michael@478 | 637 | + draw_sidebar(1); |
michael@478 | 638 | for (i = menu->top; i < menu->top + menu->pagelen; i++) |
michael@478 | 639 | { |
michael@478 | 640 | if (i < menu->max) |
michael@478 | 641 | @@ -217,7 +219,7 @@ |
michael@478 | 642 | if (option (OPTARROWCURSOR)) |
michael@478 | 643 | { |
michael@478 | 644 | attrset (menu->color (i)); |
michael@478 | 645 | - CLEARLINE (i - menu->top + menu->offset); |
michael@478 | 646 | + CLEARLINE_WIN (i - menu->top + menu->offset); |
michael@478 | 647 | |
michael@478 | 648 | if (i == menu->current) |
michael@478 | 649 | { |
michael@478 | 650 | @@ -246,14 +248,14 @@ |
michael@478 | 651 | BKGDSET (MT_COLOR_INDICATOR); |
michael@478 | 652 | } |
michael@478 | 653 | |
michael@478 | 654 | - CLEARLINE (i - menu->top + menu->offset); |
michael@478 | 655 | + CLEARLINE_WIN (i - menu->top + menu->offset); |
michael@478 | 656 | print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); |
michael@478 | 657 | SETCOLOR (MT_COLOR_NORMAL); |
michael@478 | 658 | BKGDSET (MT_COLOR_NORMAL); |
michael@478 | 659 | } |
michael@478 | 660 | } |
michael@478 | 661 | else |
michael@478 | 662 | - CLEARLINE (i - menu->top + menu->offset); |
michael@478 | 663 | + CLEARLINE_WIN (i - menu->top + menu->offset); |
michael@478 | 664 | } |
michael@478 | 665 | menu->redraw = 0; |
michael@478 | 666 | } |
michael@478 | 667 | @@ -268,7 +270,7 @@ |
michael@478 | 668 | return; |
michael@478 | 669 | } |
michael@478 | 670 | |
michael@478 | 671 | - move (menu->oldcurrent + menu->offset - menu->top, 0); |
michael@478 | 672 | + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); |
michael@478 | 673 | SETCOLOR (MT_COLOR_NORMAL); |
michael@478 | 674 | BKGDSET (MT_COLOR_NORMAL); |
michael@478 | 675 | |
michael@478 | 676 | @@ -283,13 +285,13 @@ |
michael@478 | 677 | clrtoeol (); |
michael@478 | 678 | menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); |
michael@478 | 679 | menu_pad_string (buf, sizeof (buf)); |
michael@478 | 680 | - move (menu->oldcurrent + menu->offset - menu->top, 3); |
michael@478 | 681 | + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); |
michael@478 | 682 | print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); |
michael@478 | 683 | SETCOLOR (MT_COLOR_NORMAL); |
michael@478 | 684 | } |
michael@478 | 685 | |
michael@478 | 686 | /* now draw it in the new location */ |
michael@478 | 687 | - move (menu->current + menu->offset - menu->top, 0); |
michael@478 | 688 | + move (menu->current + menu->offset - menu->top, SidebarWidth); |
michael@478 | 689 | attrset (menu->color (menu->current)); |
michael@478 | 690 | ADDCOLOR (MT_COLOR_INDICATOR); |
michael@478 | 691 | addstr ("->"); |
michael@478 | 692 | @@ -310,7 +312,7 @@ |
michael@478 | 693 | attrset (menu->color (menu->current)); |
michael@478 | 694 | ADDCOLOR (MT_COLOR_INDICATOR); |
michael@478 | 695 | BKGDSET (MT_COLOR_INDICATOR); |
michael@478 | 696 | - CLEARLINE (menu->current - menu->top + menu->offset); |
michael@478 | 697 | + CLEARLINE_WIN (menu->current - menu->top + menu->offset); |
michael@478 | 698 | print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); |
michael@478 | 699 | SETCOLOR (MT_COLOR_NORMAL); |
michael@478 | 700 | BKGDSET (MT_COLOR_NORMAL); |
michael@478 | 701 | @@ -322,7 +324,7 @@ |
michael@478 | 702 | { |
michael@478 | 703 | char buf[LONG_STRING]; |
michael@478 | 704 | |
michael@478 | 705 | - move (menu->current + menu->offset - menu->top, 0); |
michael@478 | 706 | + move (menu->current + menu->offset - menu->top, SidebarWidth); |
michael@478 | 707 | menu_make_entry (buf, sizeof (buf), menu, menu->current); |
michael@478 | 708 | menu_pad_string (buf, sizeof (buf)); |
michael@478 | 709 | |
michael@478 | 710 | @@ -875,7 +877,7 @@ |
michael@478 | 711 | |
michael@478 | 712 | |
michael@478 | 713 | if (option (OPTARROWCURSOR)) |
michael@478 | 714 | - move (menu->current - menu->top + menu->offset, 2); |
michael@478 | 715 | + move (menu->current - menu->top + menu->offset, SidebarWidth + 2); |
michael@478 | 716 | else if (option (OPTBRAILLEFRIENDLY)) |
michael@478 | 717 | move (menu->current - menu->top + menu->offset, 0); |
michael@478 | 718 | else |
michael@478 | 719 | Index: mutt.h |
michael@478 | 720 | --- mutt.h.orig 2010-09-13 19:19:55.000000000 +0200 |
michael@478 | 721 | +++ mutt.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 722 | @@ -419,6 +419,7 @@ |
michael@478 | 723 | OPTSAVEEMPTY, |
michael@478 | 724 | OPTSAVENAME, |
michael@478 | 725 | OPTSCORE, |
michael@478 | 726 | + OPTSIDEBAR, |
michael@478 | 727 | OPTSIGDASHES, |
michael@478 | 728 | OPTSIGONTOP, |
michael@478 | 729 | OPTSORTRE, |
michael@478 | 730 | @@ -859,6 +860,7 @@ |
michael@478 | 731 | { |
michael@478 | 732 | char *path; |
michael@478 | 733 | FILE *fp; |
michael@478 | 734 | + time_t atime; |
michael@478 | 735 | time_t mtime; |
michael@478 | 736 | off_t size; |
michael@478 | 737 | off_t vsize; |
michael@478 | 738 | @@ -893,6 +895,7 @@ |
michael@478 | 739 | unsigned int quiet : 1; /* inhibit status messages? */ |
michael@478 | 740 | unsigned int collapsed : 1; /* are all threads collapsed? */ |
michael@478 | 741 | unsigned int closing : 1; /* mailbox is being closed */ |
michael@478 | 742 | + unsigned int peekonly : 1; /* just taking a glance, revert atime */ |
michael@478 | 743 | |
michael@478 | 744 | /* driver hooks */ |
michael@478 | 745 | void *data; /* driver specific data */ |
michael@478 | 746 | Index: mutt_curses.h |
michael@478 | 747 | --- mutt_curses.h.orig 2008-03-19 21:07:57.000000000 +0100 |
michael@478 | 748 | +++ mutt_curses.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 749 | @@ -64,6 +64,7 @@ |
michael@478 | 750 | #undef lines |
michael@478 | 751 | #endif /* lines */ |
michael@478 | 752 | |
michael@478 | 753 | +#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() |
michael@478 | 754 | #define CLEARLINE(x) move(x,0), clrtoeol() |
michael@478 | 755 | #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) |
michael@478 | 756 | #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) |
michael@478 | 757 | @@ -126,6 +127,8 @@ |
michael@478 | 758 | MT_COLOR_BOLD, |
michael@478 | 759 | MT_COLOR_UNDERLINE, |
michael@478 | 760 | MT_COLOR_INDEX, |
michael@478 | 761 | + MT_COLOR_NEW, |
michael@478 | 762 | + MT_COLOR_FLAGGED, |
michael@478 | 763 | MT_COLOR_MAX |
michael@478 | 764 | }; |
michael@478 | 765 | |
michael@478 | 766 | Index: muttlib.c |
michael@478 | 767 | --- muttlib.c.orig 2010-08-25 18:31:40.000000000 +0200 |
michael@478 | 768 | +++ muttlib.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 769 | @@ -1286,6 +1286,8 @@ |
michael@478 | 770 | pl = pw = 1; |
michael@478 | 771 | |
michael@478 | 772 | /* see if there's room to add content, else ignore */ |
michael@478 | 773 | + if ( DrawFullLine ) |
michael@478 | 774 | + { |
michael@478 | 775 | if ((col < COLS && wlen < destlen) || soft) |
michael@478 | 776 | { |
michael@478 | 777 | int pad; |
michael@478 | 778 | @@ -1329,6 +1331,52 @@ |
michael@478 | 779 | col += wid; |
michael@478 | 780 | src += pl; |
michael@478 | 781 | } |
michael@478 | 782 | + } |
michael@478 | 783 | + else |
michael@478 | 784 | + { |
michael@478 | 785 | + if ((col < COLS-SidebarWidth && wlen < destlen) || soft) |
michael@478 | 786 | + { |
michael@478 | 787 | + int pad; |
michael@478 | 788 | + |
michael@478 | 789 | + /* get contents after padding */ |
michael@478 | 790 | + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); |
michael@478 | 791 | + len = mutt_strlen (buf); |
michael@478 | 792 | + wid = mutt_strwidth (buf); |
michael@478 | 793 | + |
michael@478 | 794 | + /* try to consume as many columns as we can, if we don't have |
michael@478 | 795 | + * memory for that, use as much memory as possible */ |
michael@478 | 796 | + pad = (COLS - SidebarWidth - col - wid) / pw; |
michael@478 | 797 | + if (pad > 0 && wlen + (pad * pl) + len > destlen) |
michael@478 | 798 | + pad = ((signed)(destlen - wlen - len)) / pl; |
michael@478 | 799 | + if (pad > 0) |
michael@478 | 800 | + { |
michael@478 | 801 | + while (pad--) |
michael@478 | 802 | + { |
michael@478 | 803 | + memcpy (wptr, src, pl); |
michael@478 | 804 | + wptr += pl; |
michael@478 | 805 | + wlen += pl; |
michael@478 | 806 | + col += pw; |
michael@478 | 807 | + } |
michael@478 | 808 | + } |
michael@478 | 809 | + else if (soft && pad < 0) |
michael@478 | 810 | + { |
michael@478 | 811 | + /* \0-terminate dest for length computation in mutt_wstr_trunc() */ |
michael@478 | 812 | + *wptr = 0; |
michael@478 | 813 | + /* make sure right part is at most as wide as display */ |
michael@478 | 814 | + len = mutt_wstr_trunc (buf, destlen, COLS, &wid); |
michael@478 | 815 | + /* truncate left so that right part fits completely in */ |
michael@478 | 816 | + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); |
michael@478 | 817 | + wptr = dest + wlen; |
michael@478 | 818 | + } |
michael@478 | 819 | + if (len + wlen > destlen) |
michael@478 | 820 | + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); |
michael@478 | 821 | + memcpy (wptr, buf, len); |
michael@478 | 822 | + wptr += len; |
michael@478 | 823 | + wlen += len; |
michael@478 | 824 | + col += wid; |
michael@478 | 825 | + src += pl; |
michael@478 | 826 | + } |
michael@478 | 827 | + } |
michael@478 | 828 | break; /* skip rest of input */ |
michael@478 | 829 | } |
michael@478 | 830 | else if (ch == '|') |
michael@478 | 831 | Index: mx.c |
michael@478 | 832 | --- mx.c.orig 2010-09-13 19:19:55.000000000 +0200 |
michael@478 | 833 | +++ mx.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 834 | @@ -580,6 +580,7 @@ |
michael@478 | 835 | * M_APPEND open mailbox for appending |
michael@478 | 836 | * M_READONLY open mailbox in read-only mode |
michael@478 | 837 | * M_QUIET only print error messages |
michael@478 | 838 | + * M_PEEK revert atime where applicable |
michael@478 | 839 | * ctx if non-null, context struct to use |
michael@478 | 840 | */ |
michael@478 | 841 | CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) |
michael@478 | 842 | @@ -602,6 +603,8 @@ |
michael@478 | 843 | ctx->quiet = 1; |
michael@478 | 844 | if (flags & M_READONLY) |
michael@478 | 845 | ctx->readonly = 1; |
michael@478 | 846 | + if (flags & M_PEEK) |
michael@478 | 847 | + ctx->peekonly = 1; |
michael@478 | 848 | |
michael@478 | 849 | if (flags & (M_APPEND|M_NEWFOLDER)) |
michael@478 | 850 | { |
michael@478 | 851 | @@ -701,9 +704,21 @@ |
michael@478 | 852 | void mx_fastclose_mailbox (CONTEXT *ctx) |
michael@478 | 853 | { |
michael@478 | 854 | int i; |
michael@478 | 855 | +#ifndef BUFFY_SIZE |
michael@478 | 856 | + struct utimbuf ut; |
michael@478 | 857 | +#endif |
michael@478 | 858 | |
michael@478 | 859 | if(!ctx) |
michael@478 | 860 | return; |
michael@478 | 861 | +#ifndef BUFFY_SIZE |
michael@478 | 862 | + /* fix up the times so buffy won't get confused */ |
michael@478 | 863 | + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) |
michael@478 | 864 | + { |
michael@478 | 865 | + ut.actime = ctx->atime; |
michael@478 | 866 | + ut.modtime = ctx->mtime; |
michael@478 | 867 | + utime (ctx->path, &ut); |
michael@478 | 868 | + } |
michael@478 | 869 | +#endif |
michael@478 | 870 | |
michael@478 | 871 | /* never announce that a mailbox we've just left has new mail. #3290 |
michael@478 | 872 | * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ |
michael@478 | 873 | Index: pager.c |
michael@478 | 874 | --- pager.c.orig 2010-08-25 18:31:40.000000000 +0200 |
michael@478 | 875 | +++ pager.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 876 | @@ -29,6 +29,7 @@ |
michael@478 | 877 | #include "pager.h" |
michael@478 | 878 | #include "attach.h" |
michael@478 | 879 | #include "mbyte.h" |
michael@478 | 880 | +#include "sidebar.h" |
michael@478 | 881 | |
michael@478 | 882 | #include "mutt_crypt.h" |
michael@478 | 883 | |
michael@478 | 884 | @@ -1099,6 +1100,7 @@ |
michael@478 | 885 | if (check_attachment_marker ((char *)buf) == 0) |
michael@478 | 886 | wrap_cols = COLS; |
michael@478 | 887 | |
michael@478 | 888 | + wrap_cols -= SidebarWidth; |
michael@478 | 889 | /* FIXME: this should come from lineInfo */ |
michael@478 | 890 | memset(&mbstate, 0, sizeof(mbstate)); |
michael@478 | 891 | |
michael@478 | 892 | @@ -1745,7 +1747,7 @@ |
michael@478 | 893 | if ((redraw & REDRAW_BODY) || topline != oldtopline) |
michael@478 | 894 | { |
michael@478 | 895 | do { |
michael@478 | 896 | - move (bodyoffset, 0); |
michael@478 | 897 | + move (bodyoffset, SidebarWidth); |
michael@478 | 898 | curline = oldtopline = topline; |
michael@478 | 899 | lines = 0; |
michael@478 | 900 | force_redraw = 0; |
michael@478 | 901 | @@ -1758,6 +1760,7 @@ |
michael@478 | 902 | &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) |
michael@478 | 903 | lines++; |
michael@478 | 904 | curline++; |
michael@478 | 905 | + move(lines + bodyoffset, SidebarWidth); |
michael@478 | 906 | } |
michael@478 | 907 | last_offset = lineInfo[curline].offset; |
michael@478 | 908 | } while (force_redraw); |
michael@478 | 909 | @@ -1771,6 +1774,7 @@ |
michael@478 | 910 | addch ('~'); |
michael@478 | 911 | addch ('\n'); |
michael@478 | 912 | lines++; |
michael@478 | 913 | + move(lines + bodyoffset, SidebarWidth); |
michael@478 | 914 | } |
michael@478 | 915 | /* We are going to update the pager status bar, so it isn't |
michael@478 | 916 | * necessary to reset to normal color now. */ |
michael@478 | 917 | @@ -1794,11 +1798,11 @@ |
michael@478 | 918 | /* print out the pager status bar */ |
michael@478 | 919 | SETCOLOR (MT_COLOR_STATUS); |
michael@478 | 920 | BKGDSET (MT_COLOR_STATUS); |
michael@478 | 921 | - CLEARLINE (statusoffset); |
michael@478 | 922 | + CLEARLINE_WIN (statusoffset); |
michael@478 | 923 | |
michael@478 | 924 | if (IsHeader (extra) || IsMsgAttach (extra)) |
michael@478 | 925 | { |
michael@478 | 926 | - size_t l1 = COLS * MB_LEN_MAX; |
michael@478 | 927 | + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; |
michael@478 | 928 | size_t l2 = sizeof (buffer); |
michael@478 | 929 | hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; |
michael@478 | 930 | mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); |
michael@478 | 931 | @@ -1808,7 +1812,7 @@ |
michael@478 | 932 | { |
michael@478 | 933 | char bn[STRING]; |
michael@478 | 934 | snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); |
michael@478 | 935 | - mutt_paddstr (COLS, bn); |
michael@478 | 936 | + mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner); |
michael@478 | 937 | } |
michael@478 | 938 | BKGDSET (MT_COLOR_NORMAL); |
michael@478 | 939 | SETCOLOR (MT_COLOR_NORMAL); |
michael@478 | 940 | @@ -1819,18 +1823,23 @@ |
michael@478 | 941 | /* redraw the pager_index indicator, because the |
michael@478 | 942 | * flags for this message might have changed. */ |
michael@478 | 943 | menu_redraw_current (index); |
michael@478 | 944 | + draw_sidebar(MENU_PAGER); |
michael@478 | 945 | |
michael@478 | 946 | /* print out the index status bar */ |
michael@478 | 947 | menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); |
michael@478 | 948 | |
michael@478 | 949 | - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); |
michael@478 | 950 | + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); |
michael@478 | 951 | SETCOLOR (MT_COLOR_STATUS); |
michael@478 | 952 | BKGDSET (MT_COLOR_STATUS); |
michael@478 | 953 | - mutt_paddstr (COLS, buffer); |
michael@478 | 954 | + mutt_paddstr (COLS-SidebarWidth, buffer); |
michael@478 | 955 | SETCOLOR (MT_COLOR_NORMAL); |
michael@478 | 956 | BKGDSET (MT_COLOR_NORMAL); |
michael@478 | 957 | } |
michael@478 | 958 | |
michael@478 | 959 | + /* if we're not using the index, update every time */ |
michael@478 | 960 | + if ( index == 0 ) |
michael@478 | 961 | + draw_sidebar(MENU_PAGER); |
michael@478 | 962 | + |
michael@478 | 963 | redraw = 0; |
michael@478 | 964 | |
michael@478 | 965 | if (option(OPTBRAILLEFRIENDLY)) { |
michael@478 | 966 | @@ -2756,6 +2765,13 @@ |
michael@478 | 967 | mutt_what_key (); |
michael@478 | 968 | break; |
michael@478 | 969 | |
michael@478 | 970 | + case OP_SIDEBAR_SCROLL_UP: |
michael@478 | 971 | + case OP_SIDEBAR_SCROLL_DOWN: |
michael@478 | 972 | + case OP_SIDEBAR_NEXT: |
michael@478 | 973 | + case OP_SIDEBAR_PREV: |
michael@478 | 974 | + scroll_sidebar(ch, MENU_PAGER); |
michael@478 | 975 | + break; |
michael@478 | 976 | + |
michael@478 | 977 | default: |
michael@478 | 978 | ch = -1; |
michael@478 | 979 | break; |
michael@478 | 980 | Index: sidebar.c |
michael@478 | 981 | --- sidebar.c.orig 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 982 | +++ sidebar.c 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 983 | @@ -0,0 +1,333 @@ |
michael@478 | 984 | +/* |
michael@478 | 985 | + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> |
michael@478 | 986 | + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> |
michael@478 | 987 | + * |
michael@478 | 988 | + * This program is free software; you can redistribute it and/or modify |
michael@478 | 989 | + * it under the terms of the GNU General Public License as published by |
michael@478 | 990 | + * the Free Software Foundation; either version 2 of the License, or |
michael@478 | 991 | + * (at your option) any later version. |
michael@478 | 992 | + * |
michael@478 | 993 | + * This program is distributed in the hope that it will be useful, |
michael@478 | 994 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
michael@478 | 995 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
michael@478 | 996 | + * GNU General Public License for more details. |
michael@478 | 997 | + * |
michael@478 | 998 | + * You should have received a copy of the GNU General Public License |
michael@478 | 999 | + * along with this program; if not, write to the Free Software |
michael@478 | 1000 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. |
michael@478 | 1001 | + */ |
michael@478 | 1002 | + |
michael@478 | 1003 | + |
michael@478 | 1004 | +#if HAVE_CONFIG_H |
michael@478 | 1005 | +# include "config.h" |
michael@478 | 1006 | +#endif |
michael@478 | 1007 | + |
michael@478 | 1008 | +#include "mutt.h" |
michael@478 | 1009 | +#include "mutt_menu.h" |
michael@478 | 1010 | +#include "mutt_curses.h" |
michael@478 | 1011 | +#include "sidebar.h" |
michael@478 | 1012 | +#include "buffy.h" |
michael@478 | 1013 | +#include <libgen.h> |
michael@478 | 1014 | +#include "keymap.h" |
michael@478 | 1015 | +#include <stdbool.h> |
michael@478 | 1016 | + |
michael@478 | 1017 | +/*BUFFY *CurBuffy = 0;*/ |
michael@478 | 1018 | +static BUFFY *TopBuffy = 0; |
michael@478 | 1019 | +static BUFFY *BottomBuffy = 0; |
michael@478 | 1020 | +static int known_lines = 0; |
michael@478 | 1021 | + |
michael@478 | 1022 | +static int quick_log10(int n) |
michael@478 | 1023 | +{ |
michael@478 | 1024 | + char string[32]; |
michael@478 | 1025 | + sprintf(string, "%d", n); |
michael@478 | 1026 | + return strlen(string); |
michael@478 | 1027 | +} |
michael@478 | 1028 | + |
michael@478 | 1029 | +void calc_boundaries (int menu) |
michael@478 | 1030 | +{ |
michael@478 | 1031 | + BUFFY *tmp = Incoming; |
michael@478 | 1032 | + |
michael@478 | 1033 | + if ( known_lines != LINES ) { |
michael@478 | 1034 | + TopBuffy = BottomBuffy = 0; |
michael@478 | 1035 | + known_lines = LINES; |
michael@478 | 1036 | + } |
michael@478 | 1037 | + for ( ; tmp->next != 0; tmp = tmp->next ) |
michael@478 | 1038 | + tmp->next->prev = tmp; |
michael@478 | 1039 | + |
michael@478 | 1040 | + if ( TopBuffy == 0 && BottomBuffy == 0 ) |
michael@478 | 1041 | + TopBuffy = Incoming; |
michael@478 | 1042 | + if ( BottomBuffy == 0 ) { |
michael@478 | 1043 | + int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); |
michael@478 | 1044 | + BottomBuffy = TopBuffy; |
michael@478 | 1045 | + while ( --count && BottomBuffy->next ) |
michael@478 | 1046 | + BottomBuffy = BottomBuffy->next; |
michael@478 | 1047 | + } |
michael@478 | 1048 | + else if ( TopBuffy == CurBuffy->next ) { |
michael@478 | 1049 | + int count = LINES - 2 - (menu != MENU_PAGER); |
michael@478 | 1050 | + BottomBuffy = CurBuffy; |
michael@478 | 1051 | + tmp = BottomBuffy; |
michael@478 | 1052 | + while ( --count && tmp->prev) |
michael@478 | 1053 | + tmp = tmp->prev; |
michael@478 | 1054 | + TopBuffy = tmp; |
michael@478 | 1055 | + } |
michael@478 | 1056 | + else if ( BottomBuffy == CurBuffy->prev ) { |
michael@478 | 1057 | + int count = LINES - 2 - (menu != MENU_PAGER); |
michael@478 | 1058 | + TopBuffy = CurBuffy; |
michael@478 | 1059 | + tmp = TopBuffy; |
michael@478 | 1060 | + while ( --count && tmp->next ) |
michael@478 | 1061 | + tmp = tmp->next; |
michael@478 | 1062 | + BottomBuffy = tmp; |
michael@478 | 1063 | + } |
michael@478 | 1064 | +} |
michael@478 | 1065 | + |
michael@478 | 1066 | +char *make_sidebar_entry(char *box, int size, int new, int flagged) |
michael@478 | 1067 | +{ |
michael@478 | 1068 | + static char *entry = 0; |
michael@478 | 1069 | + char *c; |
michael@478 | 1070 | + int i = 0; |
michael@478 | 1071 | + int delim_len = strlen(SidebarDelim); |
michael@478 | 1072 | + |
michael@478 | 1073 | + c = realloc(entry, SidebarWidth - delim_len + 2); |
michael@478 | 1074 | + if ( c ) entry = c; |
michael@478 | 1075 | + entry[SidebarWidth - delim_len + 1] = 0; |
michael@478 | 1076 | + for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); |
michael@478 | 1077 | + i = strlen(box); |
michael@478 | 1078 | + strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); |
michael@478 | 1079 | + |
michael@478 | 1080 | + if (size == -1) |
michael@478 | 1081 | + sprintf(entry + SidebarWidth - delim_len - 3, "?"); |
michael@478 | 1082 | + else if ( new ) { |
michael@478 | 1083 | + if (flagged > 0) { |
michael@478 | 1084 | + sprintf( |
michael@478 | 1085 | + entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), |
michael@478 | 1086 | + "% d(%d)[%d]", size, new, flagged); |
michael@478 | 1087 | + } else { |
michael@478 | 1088 | + sprintf( |
michael@478 | 1089 | + entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), |
michael@478 | 1090 | + "% d(%d)", size, new); |
michael@478 | 1091 | + } |
michael@478 | 1092 | + } else if (flagged > 0) { |
michael@478 | 1093 | + sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); |
michael@478 | 1094 | + } else { |
michael@478 | 1095 | + sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); |
michael@478 | 1096 | + } |
michael@478 | 1097 | + return entry; |
michael@478 | 1098 | +} |
michael@478 | 1099 | + |
michael@478 | 1100 | +void set_curbuffy(char buf[LONG_STRING]) |
michael@478 | 1101 | +{ |
michael@478 | 1102 | + BUFFY* tmp = CurBuffy = Incoming; |
michael@478 | 1103 | + |
michael@478 | 1104 | + if (!Incoming) |
michael@478 | 1105 | + return; |
michael@478 | 1106 | + |
michael@478 | 1107 | + while(1) { |
michael@478 | 1108 | + if(!strcmp(tmp->path, buf)) { |
michael@478 | 1109 | + CurBuffy = tmp; |
michael@478 | 1110 | + break; |
michael@478 | 1111 | + } |
michael@478 | 1112 | + |
michael@478 | 1113 | + if(tmp->next) |
michael@478 | 1114 | + tmp = tmp->next; |
michael@478 | 1115 | + else |
michael@478 | 1116 | + break; |
michael@478 | 1117 | + } |
michael@478 | 1118 | +} |
michael@478 | 1119 | + |
michael@478 | 1120 | +int draw_sidebar(int menu) { |
michael@478 | 1121 | + |
michael@478 | 1122 | + int lines = option(OPTHELP) ? 1 : 0; |
michael@478 | 1123 | + BUFFY *tmp; |
michael@478 | 1124 | +#ifndef USE_SLANG_CURSES |
michael@478 | 1125 | + attr_t attrs; |
michael@478 | 1126 | +#endif |
michael@478 | 1127 | + short delim_len = strlen(SidebarDelim); |
michael@478 | 1128 | + short color_pair; |
michael@478 | 1129 | + |
michael@478 | 1130 | + static bool initialized = false; |
michael@478 | 1131 | + static int prev_show_value; |
michael@478 | 1132 | + static short saveSidebarWidth; |
michael@478 | 1133 | + |
michael@478 | 1134 | + /* initialize first time */ |
michael@478 | 1135 | + if(!initialized) { |
michael@478 | 1136 | + prev_show_value = option(OPTSIDEBAR); |
michael@478 | 1137 | + saveSidebarWidth = SidebarWidth; |
michael@478 | 1138 | + if(!option(OPTSIDEBAR)) SidebarWidth = 0; |
michael@478 | 1139 | + initialized = true; |
michael@478 | 1140 | + } |
michael@478 | 1141 | + |
michael@478 | 1142 | + /* save or restore the value SidebarWidth */ |
michael@478 | 1143 | + if(prev_show_value != option(OPTSIDEBAR)) { |
michael@478 | 1144 | + if(prev_show_value && !option(OPTSIDEBAR)) { |
michael@478 | 1145 | + saveSidebarWidth = SidebarWidth; |
michael@478 | 1146 | + SidebarWidth = 0; |
michael@478 | 1147 | + } else if(!prev_show_value && option(OPTSIDEBAR)) { |
michael@478 | 1148 | + SidebarWidth = saveSidebarWidth; |
michael@478 | 1149 | + } |
michael@478 | 1150 | + prev_show_value = option(OPTSIDEBAR); |
michael@478 | 1151 | + } |
michael@478 | 1152 | + |
michael@478 | 1153 | + |
michael@478 | 1154 | +// if ( SidebarWidth == 0 ) return 0; |
michael@478 | 1155 | + if (SidebarWidth > 0 && option (OPTSIDEBAR) |
michael@478 | 1156 | + && delim_len >= SidebarWidth) { |
michael@478 | 1157 | + unset_option (OPTSIDEBAR); |
michael@478 | 1158 | + /* saveSidebarWidth = SidebarWidth; */ |
michael@478 | 1159 | + if (saveSidebarWidth > delim_len) { |
michael@478 | 1160 | + SidebarWidth = saveSidebarWidth; |
michael@478 | 1161 | + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); |
michael@478 | 1162 | + sleep (2); |
michael@478 | 1163 | + } else { |
michael@478 | 1164 | + SidebarWidth = 0; |
michael@478 | 1165 | + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); |
michael@478 | 1166 | + sleep (4); /* the advise to set a sane value should be seen long enough */ |
michael@478 | 1167 | + } |
michael@478 | 1168 | + saveSidebarWidth = 0; |
michael@478 | 1169 | + return (0); |
michael@478 | 1170 | + } |
michael@478 | 1171 | + |
michael@478 | 1172 | + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { |
michael@478 | 1173 | + if (SidebarWidth > 0) { |
michael@478 | 1174 | + saveSidebarWidth = SidebarWidth; |
michael@478 | 1175 | + SidebarWidth = 0; |
michael@478 | 1176 | + } |
michael@478 | 1177 | + unset_option(OPTSIDEBAR); |
michael@478 | 1178 | + return 0; |
michael@478 | 1179 | + } |
michael@478 | 1180 | + |
michael@478 | 1181 | + /* get attributes for divider */ |
michael@478 | 1182 | + SETCOLOR(MT_COLOR_STATUS); |
michael@478 | 1183 | +#ifndef USE_SLANG_CURSES |
michael@478 | 1184 | + attr_get(&attrs, &color_pair, 0); |
michael@478 | 1185 | +#else |
michael@478 | 1186 | + color_pair = attr_get(); |
michael@478 | 1187 | +#endif |
michael@478 | 1188 | + SETCOLOR(MT_COLOR_NORMAL); |
michael@478 | 1189 | + |
michael@478 | 1190 | + /* draw the divider */ |
michael@478 | 1191 | + |
michael@478 | 1192 | + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { |
michael@478 | 1193 | + move(lines, SidebarWidth - delim_len); |
michael@478 | 1194 | + addstr(NONULL(SidebarDelim)); |
michael@478 | 1195 | +#ifndef USE_SLANG_CURSES |
michael@478 | 1196 | + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); |
michael@478 | 1197 | +#endif |
michael@478 | 1198 | + } |
michael@478 | 1199 | + |
michael@478 | 1200 | + if ( Incoming == 0 ) return 0; |
michael@478 | 1201 | + lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ |
michael@478 | 1202 | + |
michael@478 | 1203 | + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) |
michael@478 | 1204 | + calc_boundaries(menu); |
michael@478 | 1205 | + if ( CurBuffy == 0 ) CurBuffy = Incoming; |
michael@478 | 1206 | + |
michael@478 | 1207 | + tmp = TopBuffy; |
michael@478 | 1208 | + |
michael@478 | 1209 | + SETCOLOR(MT_COLOR_NORMAL); |
michael@478 | 1210 | + |
michael@478 | 1211 | + for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { |
michael@478 | 1212 | + if ( tmp == CurBuffy ) |
michael@478 | 1213 | + SETCOLOR(MT_COLOR_INDICATOR); |
michael@478 | 1214 | + else if ( tmp->msg_unread > 0 ) |
michael@478 | 1215 | + SETCOLOR(MT_COLOR_NEW); |
michael@478 | 1216 | + else if ( tmp->msg_flagged > 0 ) |
michael@478 | 1217 | + SETCOLOR(MT_COLOR_FLAGGED); |
michael@478 | 1218 | + else |
michael@478 | 1219 | + SETCOLOR(MT_COLOR_NORMAL); |
michael@478 | 1220 | + |
michael@478 | 1221 | + move( lines, 0 ); |
michael@478 | 1222 | + if ( Context && !strcmp( tmp->path, Context->path ) ) { |
michael@478 | 1223 | + tmp->msg_unread = Context->unread; |
michael@478 | 1224 | + tmp->msgcount = Context->msgcount; |
michael@478 | 1225 | + tmp->msg_flagged = Context->flagged; |
michael@478 | 1226 | + } |
michael@478 | 1227 | + // check whether Maildir is a prefix of the current folder's path |
michael@478 | 1228 | + short maildir_is_prefix = 0; |
michael@478 | 1229 | + if ( (strlen(tmp->path) > strlen(Maildir)) && |
michael@478 | 1230 | + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) |
michael@478 | 1231 | + maildir_is_prefix = 1; |
michael@478 | 1232 | + // calculate depth of current folder and generate its display name with indented spaces |
michael@478 | 1233 | + int sidebar_folder_depth = 0; |
michael@478 | 1234 | + char *sidebar_folder_name; |
michael@478 | 1235 | + sidebar_folder_name = basename(tmp->path); |
michael@478 | 1236 | + if ( maildir_is_prefix ) { |
michael@478 | 1237 | + char *tmp_folder_name; |
michael@478 | 1238 | + int i; |
michael@478 | 1239 | + tmp_folder_name = tmp->path + strlen(Maildir); |
michael@478 | 1240 | + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { |
michael@478 | 1241 | + if (tmp_folder_name[i] == '/') sidebar_folder_depth++; |
michael@478 | 1242 | + } |
michael@478 | 1243 | + if (sidebar_folder_depth > 0) { |
michael@478 | 1244 | + sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); |
michael@478 | 1245 | + for (i=0; i < sidebar_folder_depth; i++) |
michael@478 | 1246 | + sidebar_folder_name[i]=' '; |
michael@478 | 1247 | + sidebar_folder_name[i]=0; |
michael@478 | 1248 | + strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); |
michael@478 | 1249 | + } |
michael@478 | 1250 | + } |
michael@478 | 1251 | + printw( "%.*s", SidebarWidth - delim_len + 1, |
michael@478 | 1252 | + make_sidebar_entry(sidebar_folder_name, tmp->msgcount, |
michael@478 | 1253 | + tmp->msg_unread, tmp->msg_flagged)); |
michael@478 | 1254 | + if (sidebar_folder_depth > 0) |
michael@478 | 1255 | + free(sidebar_folder_name); |
michael@478 | 1256 | + lines++; |
michael@478 | 1257 | + } |
michael@478 | 1258 | + SETCOLOR(MT_COLOR_NORMAL); |
michael@478 | 1259 | + for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { |
michael@478 | 1260 | + int i = 0; |
michael@478 | 1261 | + move( lines, 0 ); |
michael@478 | 1262 | + for ( ; i < SidebarWidth - delim_len; i++ ) |
michael@478 | 1263 | + addch(' '); |
michael@478 | 1264 | + } |
michael@478 | 1265 | + return 0; |
michael@478 | 1266 | +} |
michael@478 | 1267 | + |
michael@478 | 1268 | + |
michael@478 | 1269 | +void set_buffystats(CONTEXT* Context) |
michael@478 | 1270 | +{ |
michael@478 | 1271 | + BUFFY *tmp = Incoming; |
michael@478 | 1272 | + while(tmp) { |
michael@478 | 1273 | + if(Context && !strcmp(tmp->path, Context->path)) { |
michael@478 | 1274 | + tmp->msg_unread = Context->unread; |
michael@478 | 1275 | + tmp->msgcount = Context->msgcount; |
michael@478 | 1276 | + break; |
michael@478 | 1277 | + } |
michael@478 | 1278 | + tmp = tmp->next; |
michael@478 | 1279 | + } |
michael@478 | 1280 | +} |
michael@478 | 1281 | + |
michael@478 | 1282 | +void scroll_sidebar(int op, int menu) |
michael@478 | 1283 | +{ |
michael@478 | 1284 | + if(!SidebarWidth) return; |
michael@478 | 1285 | + if(!CurBuffy) return; |
michael@478 | 1286 | + |
michael@478 | 1287 | + switch (op) { |
michael@478 | 1288 | + case OP_SIDEBAR_NEXT: |
michael@478 | 1289 | + if ( CurBuffy->next == NULL ) return; |
michael@478 | 1290 | + CurBuffy = CurBuffy->next; |
michael@478 | 1291 | + break; |
michael@478 | 1292 | + case OP_SIDEBAR_PREV: |
michael@478 | 1293 | + if ( CurBuffy->prev == NULL ) return; |
michael@478 | 1294 | + CurBuffy = CurBuffy->prev; |
michael@478 | 1295 | + break; |
michael@478 | 1296 | + case OP_SIDEBAR_SCROLL_UP: |
michael@478 | 1297 | + CurBuffy = TopBuffy; |
michael@478 | 1298 | + if ( CurBuffy != Incoming ) { |
michael@478 | 1299 | + calc_boundaries(menu); |
michael@478 | 1300 | + CurBuffy = CurBuffy->prev; |
michael@478 | 1301 | + } |
michael@478 | 1302 | + break; |
michael@478 | 1303 | + case OP_SIDEBAR_SCROLL_DOWN: |
michael@478 | 1304 | + CurBuffy = BottomBuffy; |
michael@478 | 1305 | + if ( CurBuffy->next ) { |
michael@478 | 1306 | + calc_boundaries(menu); |
michael@478 | 1307 | + CurBuffy = CurBuffy->next; |
michael@478 | 1308 | + } |
michael@478 | 1309 | + break; |
michael@478 | 1310 | + default: |
michael@478 | 1311 | + return; |
michael@478 | 1312 | + } |
michael@478 | 1313 | + calc_boundaries(menu); |
michael@478 | 1314 | + draw_sidebar(menu); |
michael@478 | 1315 | +} |
michael@478 | 1316 | + |
michael@478 | 1317 | Index: sidebar.h |
michael@478 | 1318 | --- sidebar.h.orig 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 1319 | +++ sidebar.h 2011-01-17 19:33:15.000000000 +0100 |
michael@478 | 1320 | @@ -0,0 +1,36 @@ |
michael@478 | 1321 | +/* |
michael@478 | 1322 | + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> |
michael@478 | 1323 | + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> |
michael@478 | 1324 | + * |
michael@478 | 1325 | + * This program is free software; you can redistribute it and/or modify |
michael@478 | 1326 | + * it under the terms of the GNU General Public License as published by |
michael@478 | 1327 | + * the Free Software Foundation; either version 2 of the License, or |
michael@478 | 1328 | + * (at your option) any later version. |
michael@478 | 1329 | + * |
michael@478 | 1330 | + * This program is distributed in the hope that it will be useful, |
michael@478 | 1331 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
michael@478 | 1332 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
michael@478 | 1333 | + * GNU General Public License for more details. |
michael@478 | 1334 | + * |
michael@478 | 1335 | + * You should have received a copy of the GNU General Public License |
michael@478 | 1336 | + * along with this program; if not, write to the Free Software |
michael@478 | 1337 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. |
michael@478 | 1338 | + */ |
michael@478 | 1339 | + |
michael@478 | 1340 | +#ifndef SIDEBAR_H |
michael@478 | 1341 | +#define SIDEBAR_H |
michael@478 | 1342 | + |
michael@478 | 1343 | +struct MBOX_LIST { |
michael@478 | 1344 | + char *path; |
michael@478 | 1345 | + int msgcount; |
michael@478 | 1346 | + int new; |
michael@478 | 1347 | +} MBLIST; |
michael@478 | 1348 | + |
michael@478 | 1349 | +/* parameter is whether or not to go to the status line */ |
michael@478 | 1350 | +/* used for omitting the last | that covers up the status bar in the index */ |
michael@478 | 1351 | +int draw_sidebar(int); |
michael@478 | 1352 | +void scroll_sidebar(int, int); |
michael@478 | 1353 | +void set_curbuffy(char*); |
michael@478 | 1354 | +void set_buffystats(CONTEXT*); |
michael@478 | 1355 | + |
michael@478 | 1356 | +#endif /* SIDEBAR_H */ |
michael@478 | 1357 | |
michael@478 | 1358 | ============================================================================== |
michael@478 | 1359 | |
michael@478 | 1360 | Fix drawing of sidebar delimiter with the intended |
michael@478 | 1361 | attributes of the "status" bar --rse 20070906 |
michael@478 | 1362 | |
michael@478 | 1363 | Index: sidebar.c |
michael@478 | 1364 | --- sidebar.c.orig 2007-11-04 15:05:17 +0100 |
michael@478 | 1365 | +++ sidebar.c 2007-11-04 15:05:17 +0100 |
michael@478 | 1366 | @@ -186,23 +186,14 @@ |
michael@478 | 1367 | return 0; |
michael@478 | 1368 | } |
michael@478 | 1369 | |
michael@478 | 1370 | - /* get attributes for divider */ |
michael@478 | 1371 | - SETCOLOR(MT_COLOR_STATUS); |
michael@478 | 1372 | -#ifndef USE_SLANG_CURSES |
michael@478 | 1373 | - attr_get(&attrs, &color_pair, 0); |
michael@478 | 1374 | -#else |
michael@478 | 1375 | - color_pair = attr_get(); |
michael@478 | 1376 | -#endif |
michael@478 | 1377 | - SETCOLOR(MT_COLOR_NORMAL); |
michael@478 | 1378 | |
michael@478 | 1379 | /* draw the divider */ |
michael@478 | 1380 | |
michael@478 | 1381 | for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { |
michael@478 | 1382 | + SETCOLOR(MT_COLOR_STATUS); |
michael@478 | 1383 | move(lines, SidebarWidth - delim_len); |
michael@478 | 1384 | addstr(NONULL(SidebarDelim)); |
michael@478 | 1385 | -#ifndef USE_SLANG_CURSES |
michael@478 | 1386 | - mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); |
michael@478 | 1387 | -#endif |
michael@478 | 1388 | + SETCOLOR(MT_COLOR_NORMAL); |
michael@478 | 1389 | } |
michael@478 | 1390 | |
michael@478 | 1391 | if ( Incoming == 0 ) return 0; |