示例#1
0
static void
output_plain_fields (MuMsg *msg, const char *fields,
		     gboolean color, gboolean threads)
{
	const char*	myfields;
	int		nonempty;

	g_return_if_fail (fields);

	for (myfields = fields, nonempty = 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)))
		  nonempty += printf ("%c", *myfields);

		else {
			ansi_color_maybe (mfid, color);
			nonempty += mu_util_fputs_encoded
			  (display_field (msg, mfid), stdout);
			ansi_reset_maybe (mfid, color);
		}
	}

	if (nonempty)
		fputs ("\n", stdout);
}
示例#2
0
static void
each_part_show (MuMsg *msg, MuMsgPart *part, gboolean color)
{
	/* index */
	g_print ("  %u ", part->index);

	/* filename */
	color_maybe (MU_COLOR_GREEN); {
		gchar *fname;
		fname = mu_msg_part_get_filename (part, FALSE);
		mu_util_fputs_encoded (fname ? fname : "<none>", stdout);
		g_free (fname);
	}
	/* 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);
	mu_util_print_encoded ("[%s]",	disp_str(part->part_type));

	/* size */
	if (part->size > 0) {
		color_maybe (MU_COLOR_CYAN);
		g_print (" (%s)", mu_str_size_s (part->size));
	}

	color_maybe (MU_COLOR_DEFAULT);
	fputs ("\n", stdout);
}
示例#3
0
static void
each_part_show (MuMsg *msg, MuMsgPart *part, gboolean color)
{
	/* index */
	g_print ("  %u ", part->index);

	/* 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);
	mu_util_print_encoded (
		"[%s]",	part->disposition ? part->disposition : "<none>");


	/* size */
	if (part->size > 0) {
		color_maybe (MU_COLOR_CYAN);
		g_print (" (%s)", mu_str_size_s (part->size));
	}

	color_maybe (MU_COLOR_DEFAULT);
	fputs ("\n", stdout);
}
示例#4
0
文件: mu-cmd-cfind.c 项目: Dabg/mu
static void
print_plain (const char *email, const char *name, gboolean color)
{
	if (name) {
		if (color) fputs (MU_COLOR_MAGENTA, stdout);
		mu_util_fputs_encoded (name, stdout);
		fputs (" ", stdout);
	}

	if (color)
		fputs (MU_COLOR_GREEN, stdout);

	mu_util_fputs_encoded (email, stdout);

	if (color)
		fputs (MU_COLOR_DEFAULT, stdout);

	fputs ("\n", stdout);
}
示例#5
0
文件: mu-cmd.c 项目: antono/mu
static void
print_field (const char* field, const char *val, gboolean color)
{
	if (!val)
		return;

	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);
}
示例#6
0
文件: mu-util.c 项目: chrisklaiber/mu
static gboolean
print_args (FILE *stream, const char *frm, va_list args)
{
	gchar *str;
	gboolean rv;

	str = g_strdup_vprintf (frm, args);

	rv = mu_util_fputs_encoded (str, stream);

	g_free (str);

	return rv;
}
示例#7
0
文件: mu-cmd-find.c 项目: vext01/mu
static void
output_plain_fields (MuMsg *msg, const char *fields,
		     gboolean color, gboolean threads)
{
	const char*	myfields;
	int		nonempty, backslash = 0;
	MuMsgFieldId	mfid;

	g_return_if_fail (fields);
	
	for (myfields = fields, nonempty = 0; *myfields; ++myfields) {

		if (backslash) {
			/* Just saw a backslash, interpret special char */
			switch (*myfields) {
			case 'n':
				printf("\n");
				break;
			case 't':
				printf("\t");
				break;
			default:
				printf("\\%c", *myfields);
				break;
			};
			backslash = 0;
		} else if (*myfields == '\\') {
			/* Looks like we are about to see a special char */
			backslash = 1;
			continue;
		} else {
			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)))
			  nonempty += printf ("%c", *myfields);

			else {
				ansi_color_maybe (mfid, color);
				nonempty += mu_util_fputs_encoded
				  (display_field (msg, mfid), stdout);
				ansi_reset_maybe (mfid, color);
			}
		}
	}

	if (nonempty)
		fputs ("\n", stdout);
}
示例#8
0
static void
print_summary (MuMsg *msg, MuConfig *opts)
{
	const char* body;
	char *summ;
	MuMsgOptions msgopts;

	msgopts = mu_config_get_msg_options (opts);
	body = mu_msg_get_body_text(msg, msgopts);

	if (body)
		summ = mu_str_summarize (body, (unsigned)opts->summary_len);
	else
		summ = NULL;

	g_print ("Summary: ");
	mu_util_fputs_encoded (summ ? summ : "<none>", stdout);
	g_print ("\n");

	g_free (summ);
}