From 6e905c4fcf48b2929fc0f722116c32498cedd67c Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sun, 9 Jun 2013 20:11:34 +0300 Subject: [PATCH] status: Reuse the status line, do not use newlines Print all status messages to the same (status) line. Overwrite the previous messages. Other: * Add a time prefix to the printed messages * Tweak status messages Signed-off-by: Toni Gundogdu --- src/status.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/src/status.c b/src/status.c index e46623a..4139d07 100644 --- a/src/status.c +++ b/src/status.c @@ -1,5 +1,5 @@ /* quvi - * Copyright (C) 2012 Toni Gundogdu + * Copyright (C) 2012,2013 Toni Gundogdu * * This file is part of quvi . * @@ -24,31 +24,74 @@ #include #include "lutil.h" +#include "sig.h" static const lutil_cb_printerr perr = lutil_print_stderr_unless_quiet; +static void _saymsg(const gchar *m, const gboolean with_time) +{ + gsize l, i; + gchar *s; + + if (with_time == TRUE) + { + GDateTime *n; + gchar *t; + + n = g_date_time_new_now_local(); + t = g_date_time_format(n, "%T"); + g_date_time_unref(n); + + if (t == NULL) + return; + + s = g_strdup_printf("[%s] %s", t, m); + g_free(t); + } + else + s = g_strdup(m); + + l = sigwinch_term_spaceleft(strlen(s)); + perr("%s", s); + g_free(s); + + for (i=0; i: ")); + _say(_("fetch ...")); else - perr(_("done\n")); + _done(); } static void _resolve(const quvi_word type) { if (type != QUVI_CALLBACK_STATUS_DONE) - perr(_("resolve : ")); + _say(_("resolve ...")); else - perr(_("done\n")); + _done(); } static void _query_metainfo(const quvi_word type) { if (type != QUVI_CALLBACK_STATUS_DONE) - perr(_("metainfo : ")); + _say(_("metainfo ...")); else - perr(_("done\n")); + _done(); } QuviError cb_status(glong param, gpointer p) -- 2.11.4.GIT