Skip to content

Commit

Permalink
* mu-cmd-find.c, mu-cmd.c: make sure we pass 'make line33'
Browse files Browse the repository at this point in the history
  • Loading branch information
djcb committed Jun 19, 2011
1 parent f51fbeb commit 707a1ea
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 37 deletions.
54 changes: 35 additions & 19 deletions src/mu-cmd-find.c
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
44 changes: 26 additions & 18 deletions src/mu-cmd.c
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit 707a1ea

Please sign in to comment.