#include "util.h"
#include "clists.h"
+#include "charset.h"
static int check_interval = 30;
static int force_refresh;
int beep;
int snippets;
int show_flagged;
+ int sender_personal;
+ int sender_mbox;
};
struct option_node {
};
static clist options, patterns;
-static struct options global_options;
+static struct options global_options = {
+ .sender_personal = 1
+};
struct mbox {
cnode n;
time_t last_time;
int last_size, last_pos;
int total, new, flagged;
- int last_total, last_new;
+ int last_total, last_new, last_flagged;
int last_beep_new;
int force_refresh;
int snippet_is_new;
o->highlight = -1;
o->snippets = -1;
o->show_flagged = -1;
+ o->sender_personal = -1;
+ o->sender_mbox = -1;
}
static void
MERGE(beep);
MERGE(snippets);
MERGE(show_flagged);
+ MERGE(sender_personal);
+ MERGE(sender_mbox);
}
}
return 1;
}
-static void
-add_snippet(char **ppos, char *term, unsigned char *add)
-{
- char *pos = *ppos;
- int space = 1;
- while (*add && pos < term)
- {
- if (*add <= ' ')
- {
- if (!space)
- *pos++ = ' ';
- space = 1;
- }
- else if (*add >= 0x7f)
- {
- *pos++ = '?';
- space = 0;
- }
- else
- {
- *pos++ = *add;
- space = 0;
- }
- add++;
- }
- *ppos = pos;
- *pos = 0;
-}
-
static void
prepare_snippet(struct mbox *b, char *sender, char *subject)
{
char *pos = b->snippet;
char *term = b->snippet + sizeof(b->snippet) - 1;
- if (sender[0])
+ if (sender[0] && (b->o.sender_mbox || b->o.sender_personal))
{
- add_snippet(&pos, term, sender);
+ add_addr_snippet(&pos, term, sender, b->o.sender_mbox, b->o.sender_personal);
add_snippet(&pos, term, ": ");
}
if (subject[0])
- add_snippet(&pos, term, subject);
+ add_subject_snippet(&pos, term, subject);
else
add_snippet(&pos, term, "No subject");
}
if (!st->st_size)
{
- b->total = b->new = 0;
+ b->total = b->new = b->flagged = 0;
b->last_pos = 0;
return;
}
if (mb_fd < 0)
{
debug("[open failed: %m] ");
- b->total = b->new = -1;
+ b->total = b->new = b->flagged = -1;
return;
}
mb_reset(0);
if (!mb_check(from+1, 5))
{
debug("[inconsistent] ");
- b->total = b->new = -1;
+ b->total = b->new = b->flagged = -1;
goto done;
}
- b->total = b->new = 0;
- b->last_total = b->last_new = 0;
+ b->total = b->new = b->flagged = 0;
+ b->last_total = b->last_new = b->last_flagged = 0;
b->snippet_is_new = 0;
}
else
{
b->total = b->last_total;
b->new = b->last_new;
+ b->flagged = b->last_flagged;
}
for(;;)
b->last_pos--; // last_pos should be the previous \n character
b->last_total = b->total;
b->last_new = b->new;
+ b->last_flagged = b->flagged;
while ((c = mb_get()) >= 0 && c != '\n')
;
b->force_refresh = 1;
if (stat(b->path, &st) < 0)
{
- b->total = b->new = -1;
+ b->total = b->new = b->flagged = -1;
debug("%m\n");
}
else if (!b->last_time || st.st_mtime != b->last_time || st.st_size != b->last_size || b->force_refresh)
scan_mbox(b, &st);
b->last_time = st.st_mtime;
b->last_size = st.st_size;
- debug("%d %d (stopped at %d of %d)\n", b->total, b->new, b->last_pos, b->last_size);
+ debug("%d %d %d (stopped at %d of %d)\n", b->total, b->new, b->flagged, b->last_pos, b->last_size);
b->scanning = 0;
redraw_line(b->index);
printw("%6d ", b->flagged);
attrset(attrs[cc][hi][M_IDLE]);
printw(" ");
+ attrset(attrs[cc][0][M_FLAG]); /* We avoid the highlight intentionally */
snip = b->o.show_flagged;
}
if (snip && b->o.snippets && b->snippet[0])
e\t\t\tHide from display if empty\n\
f\t\t\tShow flagged messages if there are no new ones\n\
h\t\t\tHide from display\n\
+m\t\t\tShow mailbox name of the sender\n\
+p\t\t\tShow personal info (full name) of the sender\n\
s\t\t\tShow message snippets\n\
t\t\t\tHighlight the entry\n\
\n\
case 'h':
o->hide = value;
break;
+ case 'm':
+ o->sender_mbox = value;
+ break;
+ case 'p':
+ o->sender_personal = value;
+ break;
case 's':
o->snippets = value;
break;
while (optind < argc)
add_pattern(argv[optind++]);
+ charset_init();
term_init();
scan_and_redraw();
next_active(0, 1);