/*
* Incoming Mail Checker
*
- * (c) 2005 Martin Mares <mj@ucw.cz>
+ * (c) 2005--2007 Martin Mares <mj@ucw.cz>
*/
#include <stdio.h>
int highlight;
int beep;
int snippets;
+ int show_flagged;
};
struct option_node {
int seen;
time_t last_time;
int last_size, last_pos;
- int total, new;
+ int total, new, flagged;
int last_total, last_new;
int last_beep_new;
int force_refresh;
+ int snippet_is_new;
char snippet[256];
};
o->beep = -1;
o->highlight = -1;
o->snippets = -1;
+ o->show_flagged = -1;
}
static void
MERGE(highlight);
MERGE(beep);
MERGE(snippets);
+ MERGE(show_flagged);
}
}
}
b->total = b->new = 0;
b->last_total = b->last_new = 0;
+ b->snippet_is_new = 0;
}
else
{
;
int new = 1;
+ int flagged = 0;
sender[0] = 0;
subject[0] = 0;
for (;;)
break;
if (!strncasecmp(buf, "Status:", 7))
new = 0;
+ else if (!strncasecmp(buf, "X-Status:", 9) && strchr(buf+9, 'F'))
+ flagged = 1;
else if (!strncasecmp(buf, "From:", 5))
strcpy(sender, buf+5);
else if (!strncasecmp(buf, "Subject:", 8))
b->total++;
if (new)
+ b->new++;
+ if (flagged)
+ b->flagged++;
+ if (new || (flagged && !b->snippet_is_new))
{
- b->new++;
+ b->snippet_is_new = new;
prepare_snippet(b, sender, subject);
}
M_IDLE,
M_SCAN,
M_NEW,
+ M_FLAG,
M_BAD,
M_MAX
};
printw(" ");
if (b->new)
attrset(attrs[cc][hi][M_NEW]);
+ else if (b->flagged)
+ attrset(attrs[cc][hi][M_FLAG]);
printw("%-20s ", b->name);
if (b->scanning < 0)
;
{
attrset(attrs[cc][hi][M_IDLE]);
printw("%6d ", b->total);
+ int snip = 0;
if (b->new)
{
attrset(attrs[cc][hi][M_NEW]);
printw("%2d hrs ", age/3600);
else
printw(" ");
- if (b->o.snippets && b->snippet[0])
- {
- int xx, yy;
- getyx(stdscr, yy, xx);
- int remains = COLS-1-xx;
- if (remains > 2)
- printw("%-.*s", remains, b->snippet);
- }
+ snip = 1;
+ }
+ else if (b->flagged)
+ {
+ attrset(attrs[cc][hi][M_FLAG]);
+ printw("%6d ", b->flagged);
+ attrset(attrs[cc][hi][M_IDLE]);
+ printw(" ");
+ snip = b->o.show_flagged;
+ }
+ if (snip && b->o.snippets && b->snippet[0])
+ {
+ int xx, yy;
+ getyx(stdscr, yy, xx);
+ int remains = COLS-1-xx;
+ if (remains > 2)
+ printw("%-.*s", remains, b->snippet);
}
}
}
curs_set(0);
static const int attrs_mono[2][M_MAX] = {
- [0] = { [M_IDLE] = 0, [M_SCAN] = A_BOLD, [M_NEW] = A_BOLD, [M_BAD] = A_DIM },
- [1] = { [M_IDLE] = 0, [M_SCAN] = A_BOLD, [M_NEW] = A_REVERSE | A_BOLD, [M_BAD] = A_DIM },
+ [0] = { [M_IDLE] = 0, [M_SCAN] = A_BOLD, [M_NEW] = A_BOLD, [M_FLAG] = 0, [M_BAD] = A_DIM },
+ [1] = { [M_IDLE] = 0, [M_SCAN] = A_BOLD, [M_NEW] = A_REVERSE | A_BOLD, [M_FLAG] = A_REVERSE, [M_BAD] = A_DIM },
};
for (int i=0; i<2; i++)
for (int j=0; j<M_MAX; j++)
init_pair(3, COLOR_WHITE, COLOR_BLUE);
init_pair(4, COLOR_YELLOW, COLOR_BLUE);
init_pair(5, COLOR_RED, COLOR_BLUE);
+ init_pair(6, COLOR_GREEN, COLOR_BLACK);
+ init_pair(7, COLOR_GREEN, COLOR_BLUE);
static const int attrs_color[2][2][M_MAX] = {
- [0][0] = { [M_IDLE] = 0, [M_SCAN] = COLOR_PAIR(1), [M_NEW] = COLOR_PAIR(1), [M_BAD] = COLOR_PAIR(2) },
- [0][1] = { [M_IDLE] = A_BOLD, [M_SCAN] = COLOR_PAIR(1), [M_NEW] = COLOR_PAIR(1) | A_BOLD, [M_BAD] = COLOR_PAIR(2) | A_BOLD },
- [1][0] = { [M_IDLE] = COLOR_PAIR(3), [M_SCAN] = COLOR_PAIR(4), [M_NEW] = COLOR_PAIR(4), [M_BAD] = COLOR_PAIR(5) },
- [1][1] = { [M_IDLE] = COLOR_PAIR(3) | A_BOLD, [M_SCAN] = COLOR_PAIR(4), [M_NEW] = COLOR_PAIR(4) | A_BOLD, [M_BAD] = COLOR_PAIR(5) | A_BOLD },
+ [0][0] = { [M_IDLE] = 0, [M_SCAN] = COLOR_PAIR(1), [M_NEW] = COLOR_PAIR(1), [M_FLAG] = COLOR_PAIR(6), [M_BAD] = COLOR_PAIR(2) },
+ [0][1] = { [M_IDLE] = A_BOLD, [M_SCAN] = COLOR_PAIR(1), [M_NEW] = COLOR_PAIR(1) | A_BOLD, [M_FLAG] = COLOR_PAIR(6) | A_BOLD, [M_BAD] = COLOR_PAIR(2) | A_BOLD },
+ [1][0] = { [M_IDLE] = COLOR_PAIR(3), [M_SCAN] = COLOR_PAIR(4), [M_NEW] = COLOR_PAIR(4), [M_FLAG] = COLOR_PAIR(7), [M_BAD] = COLOR_PAIR(5) },
+ [1][1] = { [M_IDLE] = COLOR_PAIR(3) | A_BOLD, [M_SCAN] = COLOR_PAIR(4), [M_NEW] = COLOR_PAIR(4) | A_BOLD, [M_FLAG] = COLOR_PAIR(7) | A_BOLD, [M_BAD] = COLOR_PAIR(5) | A_BOLD },
};
memcpy(attrs, attrs_color, sizeof(attrs));
}
0-9\t\t\tSet mailbox priority (0=default)\n\
b\t\t\tBeep when a message arrives\n\
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\
s\t\t\tShow message snippets\n\
t\t\t\tHighlight the entry\n\
case 'e':
o->hide_if_empty = value;
break;
+ case 'f':
+ o->show_flagged = value;
+ break;
case 'h':
o->hide = value;
break;