mirror of https://github.com/djcb/mu.git
* make the output of mu cfind/extract/view locale-encoded except for cfind
with --format=bbdb
This commit is contained in:
parent
de539ea3f8
commit
ccbf76b793
|
@ -111,7 +111,8 @@ each_contact_mutt_alias (const char *email, const char *name)
|
|||
|
||||
nick = mu_str_guess_nick (name);
|
||||
|
||||
g_print ("alias %s %s <%s>\n", nick, name, email);
|
||||
mu_util_print_encoded ("alias %s %s <%s>\n",
|
||||
nick, name, email);
|
||||
|
||||
g_free (nick);
|
||||
}
|
||||
|
@ -124,8 +125,8 @@ each_contact_wl (const char *email, const char *name)
|
|||
if (name) {
|
||||
gchar *nick;
|
||||
nick = mu_str_guess_nick (name);
|
||||
g_print ("%s \"%s\" \"%s\"\n", email, nick, name);
|
||||
|
||||
mu_util_print_encoded ("%s \"%s\" \"%s\"\n",
|
||||
email, nick, name);
|
||||
g_free (nick);
|
||||
}
|
||||
}
|
||||
|
@ -135,23 +136,24 @@ static void
|
|||
each_contact_org_contact (const char *email, const char *name)
|
||||
{
|
||||
if (name)
|
||||
g_print ("* %s\n:PROPERTIES:\n:EMAIL: %s\n:END:\n\n",
|
||||
mu_util_print_encoded (
|
||||
"* %s\n:PROPERTIES:\n:EMAIL: %s\n:END:\n\n",
|
||||
name, email);
|
||||
}
|
||||
|
||||
static void
|
||||
print_plain (const char *email, const char *name, gboolean color)
|
||||
{
|
||||
if (name)
|
||||
g_print ("%s%s%s ",
|
||||
color ? MU_COLOR_MAGENTA : "",
|
||||
name,
|
||||
color ? MU_COLOR_DEFAULT : "");
|
||||
if (name) {
|
||||
if (color) fputs (MU_COLOR_MAGENTA, stdout);
|
||||
mu_util_fputs_encoded (name, stdout);
|
||||
fputs (" ", stdout);
|
||||
}
|
||||
|
||||
g_print ("%s%s%s\n",
|
||||
color ? MU_COLOR_GREEN : "",
|
||||
email,
|
||||
color ? MU_COLOR_DEFAULT : "");
|
||||
if (color) fputs (MU_COLOR_GREEN, stdout);
|
||||
mu_util_fputs_encoded (email, stdout);
|
||||
if (color) fputs (MU_COLOR_DEFAULT, stdout);
|
||||
fputs ("\n", stdout);
|
||||
}
|
||||
|
||||
struct _ECData {
|
||||
|
@ -167,13 +169,13 @@ each_contact (const char *email, const char *name, time_t tstamp, ECData *ecdata
|
|||
switch (ecdata->format) {
|
||||
case FORMAT_MUTT_ALIAS: each_contact_mutt_alias (email, name); break;
|
||||
case FORMAT_MUTT_AB:
|
||||
g_print ("%s\t%s\t\n", email, name ? name : ""); break;
|
||||
mu_util_print_encoded ("%s\t%s\t\n",
|
||||
email, name ? name : ""); break;
|
||||
case FORMAT_WL: each_contact_wl (email, name); break;
|
||||
case FORMAT_ORG_CONTACT: each_contact_org_contact (email, name); break;
|
||||
case FORMAT_BBDB: each_contact_bbdb (email, name, tstamp); break;
|
||||
|
||||
case FORMAT_CSV:
|
||||
g_print ("%s,%s\n", name ? name : "", email);
|
||||
mu_util_print_encoded ("%s,%s\n", name ? name : "", email);
|
||||
break;
|
||||
default:
|
||||
print_plain (email, name, ecdata->color);
|
||||
|
|
|
@ -298,28 +298,31 @@ save_parts (const char *path, const char *filename, MuConfig *opts)
|
|||
|
||||
|
||||
|
||||
#define color_maybe(C,COND) ((COND)?(C):"")
|
||||
#define color_maybe(C) do{ if (color) fputs ((C),stdout);}while(0)
|
||||
|
||||
static void
|
||||
each_part_show (MuMsg *msg, MuMsgPart *part, gboolean color)
|
||||
{
|
||||
g_print (" %u %s%s %s%s/%s%s [%s%s%s]\n",
|
||||
part->index,
|
||||
/* filename */
|
||||
color_maybe (MU_COLOR_GREEN, color),
|
||||
part->file_name ? part->file_name : "<none>",
|
||||
/* index */
|
||||
g_print (" %u ", part->index);
|
||||
|
||||
/* content type */
|
||||
color_maybe (MU_COLOR_BLUE, color),
|
||||
part->type ? part->type : "",
|
||||
part->subtype ? part->subtype : "",
|
||||
color_maybe (MU_COLOR_DEFAULT, color),
|
||||
/* filename */
|
||||
color_maybe (MU_COLOR_GREEN);
|
||||
mu_util_fputs_encoded (part->file_name ? part->file_name : "<none>",
|
||||
stdout);
|
||||
/* content-type */
|
||||
color_maybe (MU_COLOR_BLUE);
|
||||
mu_util_print_encoded (
|
||||
" %s/%s ",
|
||||
part->type ? part->type : "<none>",
|
||||
part->subtype ? part->subtype : "<none>");
|
||||
|
||||
/* disposition */
|
||||
color_maybe (MU_COLOR_MAGENTA, color),
|
||||
part->disposition ? part->disposition : "<none>",
|
||||
color_maybe (MU_COLOR_DEFAULT, color)
|
||||
);
|
||||
color_maybe (MU_COLOR_MAGENTA);
|
||||
mu_util_print_encoded (
|
||||
"[%s]", part->disposition ? part->disposition : "<none>");
|
||||
color_maybe (MU_COLOR_DEFAULT);
|
||||
fputs ("\n", stdout);
|
||||
}
|
||||
|
||||
|
||||
|
|
27
src/mu-cmd.c
27
src/mu-cmd.c
|
@ -64,6 +64,7 @@ get_attach_str (MuMsg *msg)
|
|||
return attach;
|
||||
}
|
||||
|
||||
#define color_maybe(C) do{ if (color) fputs ((C),stdout);}while(0)
|
||||
|
||||
static void
|
||||
print_field (const char* field, const char *val, gboolean color)
|
||||
|
@ -71,13 +72,18 @@ print_field (const char* field, const char *val, gboolean color)
|
|||
if (!val)
|
||||
return;
|
||||
|
||||
g_print ("%s%s%s: %s%s%s\n",
|
||||
color ? MU_COLOR_MAGENTA : "",
|
||||
field,
|
||||
color ? MU_COLOR_DEFAULT : "",
|
||||
color ? MU_COLOR_GREEN : "",
|
||||
val ? val : "",
|
||||
color ? MU_COLOR_DEFAULT : "");
|
||||
color_maybe (MU_COLOR_MAGENTA);
|
||||
mu_util_fputs_encoded (field, stdout);
|
||||
color_maybe (MU_COLOR_DEFAULT);
|
||||
fputs (": ", stdout);
|
||||
|
||||
if (val) {
|
||||
color_maybe (MU_COLOR_GREEN);
|
||||
mu_util_fputs_encoded (val, stdout);
|
||||
}
|
||||
|
||||
color_maybe (MU_COLOR_DEFAULT);
|
||||
fputs ("\n", stdout);
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,8 +120,11 @@ view_msg (MuMsg *msg, const gchar *fields, gboolean summary,
|
|||
summ = mu_str_summarize (field, SUMMARY_LEN);
|
||||
print_field ("Summary", summ, color);
|
||||
g_free (summ);
|
||||
} else
|
||||
g_print ("\n%s\n", field);
|
||||
} else {
|
||||
color_maybe (MU_COLOR_YELLOW);
|
||||
mu_util_print_encoded ("\n%s\n", field);
|
||||
color_maybe (MU_COLOR_DEFAULT);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue