* mu-find: enable threaded output

This commit is contained in:
Dirk-Jan C. Binnema 2011-06-19 21:04:03 +03:00
parent 9a5888f7c8
commit d28319bc27
1 changed files with 12 additions and 11 deletions

View File

@ -60,8 +60,8 @@ static gboolean output_sexp (MuMsgIter *iter, size_t *count);
static gboolean output_json (MuMsgIter *iter, size_t *count); static gboolean output_json (MuMsgIter *iter, size_t *count);
static gboolean output_xml (MuMsgIter *iter, size_t *count); static gboolean output_xml (MuMsgIter *iter, size_t *count);
static gboolean output_plain (MuMsgIter *iter, const char *fields, static gboolean output_plain (MuMsgIter *iter, const char *fields,
gboolean summary,gboolean color, gboolean summary,gboolean threads,
size_t *count); gboolean color, size_t *count);
static OutputFormat static OutputFormat
get_output_format (const char *formatstr) get_output_format (const char *formatstr)
@ -146,10 +146,10 @@ run_query_format (MuMsgIter *iter, MuConfig *opts,
case FORMAT_LINKS: case FORMAT_LINKS:
return output_links (iter, opts->linksdir, opts->clearlinks, return output_links (iter, opts->linksdir, opts->clearlinks,
count); count);
case FORMAT_PLAIN: case FORMAT_PLAIN:
return output_plain (iter, opts->fields, opts->summary, return output_plain (iter, opts->fields, opts->summary,
opts->color, count); opts->threads, opts->color, count);
case FORMAT_XML: case FORMAT_XML:
return output_xml (iter, count); return output_xml (iter, count);
case FORMAT_JSON: case FORMAT_JSON:
@ -180,7 +180,7 @@ run_query (MuQuery *xapian, const gchar *query, MuConfig *opts,
} }
err = NULL; err = NULL;
iter = mu_query_run (xapian, query, sortid, iter = mu_query_run (xapian, query, opts->threads, sortid,
opts->descending ? FALSE : TRUE, opts->descending ? FALSE : TRUE,
&err); &err);
if (!iter) { if (!iter) {
@ -561,20 +561,20 @@ indent (MuMsgIter *iter)
if (!threadpath) if (!threadpath)
return; return;
fputs (threadpath, stdout); /* fputs (threadpath, stdout); */
/* count the colons... */ /* count the colons... */
for (i = 0; *threadpath; ++threadpath) for (i = 0; *threadpath; ++threadpath)
i += (*threadpath == ':') ? 1 : 0; i += (*threadpath == ':') ? 1 : 0;
/* indent */ /* indent */
while (i --> -1) while (i --> 0)
fputs (" ", stdout); fputs (" ", stdout);
} }
static gboolean static gboolean
output_plain (MuMsgIter *iter, const char *fields, gboolean summary, output_plain (MuMsgIter *iter, const char *fields, gboolean summary,
gboolean color, size_t *count) gboolean threads, gboolean color, size_t *count)
{ {
MuMsgIter *myiter; MuMsgIter *myiter;
size_t mycount; size_t mycount;
@ -588,7 +588,8 @@ output_plain (MuMsgIter *iter, const char *fields, gboolean summary,
const char* myfields; const char* myfields;
int len; int len;
indent (myiter); if (threads)
indent (myiter);
for (myfields = fields, len = 0; *myfields; ++myfields) { for (myfields = fields, len = 0; *myfields; ++myfields) {
MuMsgFieldId mfid; MuMsgFieldId mfid;
@ -805,7 +806,7 @@ mu_cmd_find (MuConfig *opts)
return MU_EXITCODE_ERROR; return MU_EXITCODE_ERROR;
format = get_output_format (opts->formatstr); format = get_output_format (opts->formatstr);
xapian = get_query_obj (); xapian = get_query_obj();
query = get_query (opts); query = get_query (opts);
if (!xapian ||!query) if (!xapian ||!query)