From ab3edbea189a7780239b3b5d4962c3d135db417f Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sun, 3 Jun 2012 16:04:03 +0000 Subject: [PATCH] Bugfix: Use ANSI/VT100 codes to update status line in a way that actually works --- main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 202b3ed..f709407 100644 --- a/main.cpp +++ b/main.cpp @@ -297,6 +297,7 @@ extern "C" void* ThreadDumper(void*) { } extern "C" void* ThreadStats(void*) { + bool first = true; do { char c[256]; time_t tim = time(NULL); @@ -304,7 +305,14 @@ extern "C" void* ThreadStats(void*) { strftime(c, 256, "[%y-%m-%d %H:%M:%S]", tmp); CAddrDbStats stats; db.GetStats(stats); - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); + if (first) + { + first = false; + printf("\n\n\n\x1b[3A"); + } + else + printf("\x1b[2K\x1b[u"); + printf("\x1b[s"); uint64_t requests = 0; uint64_t queries = 0; for (unsigned int i=0; i