* mu-cmd-index.c: don't use repeated-\b, use \r in progress reporting (thanks

to Daniel Beer)

     - this should fix progress reporting when running mu index under 'screen'
This commit is contained in:
djcb
2012-06-21 20:29:12 +03:00
parent 7d43337f76
commit 68169cc033

View File

@ -128,27 +128,6 @@ index_msg_silent_cb (MuIndexStats* stats, void *user_data)
} }
static void
backspace (unsigned u)
{
static gboolean init = FALSE;
static char backspace[80];
if (G_UNLIKELY(!init)) {
/* fill with backspaces */
int i;
for (i = 0; i != sizeof(backspace); ++i)
backspace[i] = '\b';
init = TRUE;
}
backspace[MIN(u,sizeof(backspace))] = '\0';
fputs (backspace, stdout);
backspace[u] = '\b';
}
static void static void
print_stats (MuIndexStats* stats, gboolean clear, gboolean color) print_stats (MuIndexStats* stats, gboolean clear, gboolean color)
@ -156,13 +135,13 @@ print_stats (MuIndexStats* stats, gboolean clear, gboolean color)
const char *kars="-\\|/"; const char *kars="-\\|/";
char output[120]; char output[120];
static unsigned i = 0, len = 0; static unsigned i = 0;
if (clear) if (clear)
backspace (len); fputs ("\r", stdout);
if (color) if (color)
len = (unsigned)snprintf snprintf
(output, sizeof(output), (output, sizeof(output),
MU_COLOR_YELLOW "%c " MU_COLOR_DEFAULT MU_COLOR_YELLOW "%c " MU_COLOR_DEFAULT
"processing mail; " "processing mail; "
@ -174,7 +153,7 @@ print_stats (MuIndexStats* stats, gboolean clear, gboolean color)
(unsigned)stats->_updated, (unsigned)stats->_updated,
(unsigned)stats->_cleaned_up); (unsigned)stats->_cleaned_up);
else else
len = (unsigned)snprintf snprintf
(output, sizeof(output), (output, sizeof(output),
"%c processing mail; processed: %u; " "%c processing mail; processed: %u; "
"updated/new: %u, cleaned-up: %u", "updated/new: %u, cleaned-up: %u",
@ -240,7 +219,6 @@ database_version_check_and_update (MuStore *store, MuConfig *opts,
static void static void
show_time (unsigned t, unsigned processed, gboolean color) show_time (unsigned t, unsigned processed, gboolean color)
{ {
if (color) { if (color) {
if (t) if (t)
g_print ("elapsed: " g_print ("elapsed: "