mirror of https://github.com/djcb/mu.git
* mu-cmd-find.c, mu-cmd.c: make sure we pass 'make line33'
This commit is contained in:
parent
f51fbebe9a
commit
707a1ea1c2
|
@ -572,6 +572,39 @@ indent (MuMsgIter *iter)
|
|||
fputs (" ", stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static size_t
|
||||
output_plain_fields (MuMsgIter *iter, const char *fields, gboolean color,
|
||||
gboolean threads)
|
||||
{
|
||||
const char* myfields;
|
||||
size_t len;
|
||||
|
||||
if (threads)
|
||||
indent (iter);
|
||||
|
||||
for (myfields = fields, len = 0; *myfields; ++myfields) {
|
||||
|
||||
MuMsgFieldId mfid;
|
||||
mfid = mu_msg_field_id_from_shortcut (*myfields, FALSE);
|
||||
|
||||
if (mfid == MU_MSG_FIELD_ID_NONE ||
|
||||
(!mu_msg_field_xapian_value (mfid) &&
|
||||
!mu_msg_field_xapian_contact (mfid)))
|
||||
len += printf ("%c", *myfields);
|
||||
|
||||
else {
|
||||
ansi_color_maybe (mfid, color);
|
||||
len += mu_util_fputs_encoded
|
||||
(display_field (iter, mfid), stdout);
|
||||
ansi_reset_maybe (mfid, color);
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
output_plain (MuMsgIter *iter, const char *fields, gboolean summary,
|
||||
gboolean threads, gboolean color, size_t *count)
|
||||
|
@ -585,26 +618,9 @@ output_plain (MuMsgIter *iter, const char *fields, gboolean summary,
|
|||
for (myiter = iter, mycount = 0; !mu_msg_iter_is_done (myiter);
|
||||
mu_msg_iter_next (myiter), ++mycount) {
|
||||
|
||||
const char* myfields;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if (threads)
|
||||
indent (myiter);
|
||||
|
||||
for (myfields = fields, len = 0; *myfields; ++myfields) {
|
||||
MuMsgFieldId mfid;
|
||||
mfid = mu_msg_field_id_from_shortcut (*myfields, FALSE);
|
||||
if (mfid == MU_MSG_FIELD_ID_NONE ||
|
||||
(!mu_msg_field_xapian_value (mfid) &&
|
||||
!mu_msg_field_xapian_contact (mfid)))
|
||||
len += printf ("%c", *myfields);
|
||||
else {
|
||||
ansi_color_maybe (mfid, color);
|
||||
len += mu_util_fputs_encoded
|
||||
(display_field (myiter, mfid), stdout);
|
||||
ansi_reset_maybe (mfid, color);
|
||||
}
|
||||
}
|
||||
len = output_plain_fields (iter, fields, color, threads);
|
||||
|
||||
g_print (len > 0 ? "\n" : "");
|
||||
if (summary)
|
||||
|
|
44
src/mu-cmd.c
44
src/mu-cmd.c
|
@ -88,17 +88,37 @@ print_field (const char* field, const char *val, gboolean color)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
body_or_summary (MuMsg *msg, gboolean summary, gboolean color)
|
||||
{
|
||||
const char* field;
|
||||
const int SUMMARY_LEN = 5;
|
||||
|
||||
field = mu_msg_get_body_text (msg);
|
||||
if (!field)
|
||||
return; /* no body -- nothing more to do */
|
||||
|
||||
if (summary) {
|
||||
gchar *summ;
|
||||
summ = mu_str_summarize (field, SUMMARY_LEN);
|
||||
print_field ("Summary", summ, color);
|
||||
g_free (summ);
|
||||
} else {
|
||||
color_maybe (MU_COLOR_YELLOW);
|
||||
mu_util_print_encoded ("\n%s\n", field);
|
||||
color_maybe (MU_COLOR_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* we ignore fields for now */
|
||||
static gboolean
|
||||
view_msg (MuMsg *msg, const gchar *fields, gboolean summary,
|
||||
gboolean color)
|
||||
{
|
||||
const char *field;
|
||||
gchar *attachs;
|
||||
time_t date;
|
||||
const GSList *lst;
|
||||
const int SUMMARY_LEN = 5;
|
||||
|
||||
|
||||
print_field ("From", mu_msg_get_from (msg), color);
|
||||
print_field ("To", mu_msg_get_to (msg), color);
|
||||
|
@ -121,21 +141,9 @@ view_msg (MuMsg *msg, const gchar *fields, gboolean summary,
|
|||
print_field ("Attachments", attachs, color);
|
||||
g_free (attachs);
|
||||
}
|
||||
|
||||
if (!(field = mu_msg_get_body_text (msg)))
|
||||
return TRUE; /* no body -- nothing more to do */
|
||||
|
||||
if (summary) {
|
||||
gchar *summ;
|
||||
summ = mu_str_summarize (field, SUMMARY_LEN);
|
||||
print_field ("Summary", summ, color);
|
||||
g_free (summ);
|
||||
} else {
|
||||
color_maybe (MU_COLOR_YELLOW);
|
||||
mu_util_print_encoded ("\n%s\n", field);
|
||||
color_maybe (MU_COLOR_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
body_or_summary (msg, summary, color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue