improve client_test rendering for checking and queued for checking torrents

This commit is contained in:
Arvid Norberg 2010-01-17 21:10:28 +00:00
parent 018da0e29f
commit 0ab8dba84b
1 changed files with 57 additions and 45 deletions

View File

@ -311,8 +311,8 @@ std::string const& progress_bar(int progress, int width, char const* code = "33"
int progress_chars = (progress * width + 500) / 1000;
bar = esc(code);
std::fill_n(std::back_inserter(bar), progress_chars, '#');
bar += esc("0");
std::fill_n(std::back_inserter(bar), width - progress_chars, '-');
bar += esc("0");
return bar;
}
@ -1299,6 +1299,8 @@ int main(int argc, char* argv[])
if (s.num_incomplete >= 0) downloaders = s.num_incomplete;
else downloaders = s.list_peers - s.list_seeds;
if (s.state != torrent_status::queued_for_checking && s.state != torrent_status::checking_files)
{
snprintf(str, sizeof(str), "%-13s down: (%s%s%s) up: %s%s%s (%s%s%s) swarm: %4d:%4d"
" bw queue: (%d|%d) all-time (Rx: %s%s%s Tx: %s%s%s) seed rank: %x%s\n"
, (paused && !auto_managed)?"paused":(paused && auto_managed)?"queued":state_str[s.state]
@ -1314,8 +1316,7 @@ int main(int argc, char* argv[])
if (torrent_index != active_torrent && s.state == torrent_status::seeding) continue;
char const* progress_bar_color = "33"; // yellow
if (s.state == torrent_status::checking_files
|| s.state == torrent_status::downloading_metadata)
if (s.state == torrent_status::downloading_metadata)
{
progress_bar_color = "35"; // magenta
}
@ -1334,14 +1335,24 @@ int main(int argc, char* argv[])
, s.progress_ppm / 10000.f
, progress_bar(s.progress_ppm / 1000, terminal_width - 42, progress_bar_color).c_str());
out += str;
}
else
{
snprintf(str, sizeof(str), "%-13s %s\n"
, state_str[s.state]
, progress_bar(s.progress_ppm / 1000, terminal_width - 42 - 20, "35").c_str());
out += str;
}
if (print_piece_bar && s.progress_ppm < 1000000)
if (print_piece_bar && s.progress_ppm < 1000000 && s.progress > 0)
{
out += " ";
out += piece_bar(s.pieces, terminal_width - 7);
out += "\n";
}
if (s.state != torrent_status::queued_for_checking && s.state != torrent_status::checking_files)
{
boost::posix_time::time_duration t = s.next_announce;
snprintf(str, sizeof(str)
, " peers: %s%d%s (%s%d%s) seeds: %s%d%s distributed copies: %s%4.2f%s "
@ -1356,6 +1367,7 @@ int main(int argc, char* argv[])
, esc("37"), t.hours(), t.minutes(), t.seconds(), esc("0")
, esc("36"), s.current_tracker.c_str(), esc("0"));
out += str;
}
if (torrent_index != active_torrent) continue;
active_handle = h;