improve client_test rendering for checking and queued for checking torrents
This commit is contained in:
@@ -311,8 +311,8 @@ std::string const& progress_bar(int progress, int width, char const* code = "33"
|
|||||||
int progress_chars = (progress * width + 500) / 1000;
|
int progress_chars = (progress * width + 500) / 1000;
|
||||||
bar = esc(code);
|
bar = esc(code);
|
||||||
std::fill_n(std::back_inserter(bar), progress_chars, '#');
|
std::fill_n(std::back_inserter(bar), progress_chars, '#');
|
||||||
bar += esc("0");
|
|
||||||
std::fill_n(std::back_inserter(bar), width - progress_chars, '-');
|
std::fill_n(std::back_inserter(bar), width - progress_chars, '-');
|
||||||
|
bar += esc("0");
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1299,6 +1299,8 @@ int main(int argc, char* argv[])
|
|||||||
if (s.num_incomplete >= 0) downloaders = s.num_incomplete;
|
if (s.num_incomplete >= 0) downloaders = s.num_incomplete;
|
||||||
else downloaders = s.list_peers - s.list_seeds;
|
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"
|
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"
|
" 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]
|
, (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;
|
if (torrent_index != active_torrent && s.state == torrent_status::seeding) continue;
|
||||||
char const* progress_bar_color = "33"; // yellow
|
char const* progress_bar_color = "33"; // yellow
|
||||||
if (s.state == torrent_status::checking_files
|
if (s.state == torrent_status::downloading_metadata)
|
||||||
|| s.state == torrent_status::downloading_metadata)
|
|
||||||
{
|
{
|
||||||
progress_bar_color = "35"; // magenta
|
progress_bar_color = "35"; // magenta
|
||||||
}
|
}
|
||||||
@@ -1334,14 +1335,24 @@ int main(int argc, char* argv[])
|
|||||||
, s.progress_ppm / 10000.f
|
, s.progress_ppm / 10000.f
|
||||||
, progress_bar(s.progress_ppm / 1000, terminal_width - 42, progress_bar_color).c_str());
|
, progress_bar(s.progress_ppm / 1000, terminal_width - 42, progress_bar_color).c_str());
|
||||||
out += 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 += " ";
|
||||||
out += piece_bar(s.pieces, terminal_width - 7);
|
out += piece_bar(s.pieces, terminal_width - 7);
|
||||||
out += "\n";
|
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;
|
boost::posix_time::time_duration t = s.next_announce;
|
||||||
snprintf(str, sizeof(str)
|
snprintf(str, sizeof(str)
|
||||||
, " peers: %s%d%s (%s%d%s) seeds: %s%d%s distributed copies: %s%4.2f%s "
|
, " 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("37"), t.hours(), t.minutes(), t.seconds(), esc("0")
|
||||||
, esc("36"), s.current_tracker.c_str(), esc("0"));
|
, esc("36"), s.current_tracker.c_str(), esc("0"));
|
||||||
out += str;
|
out += str;
|
||||||
|
}
|
||||||
|
|
||||||
if (torrent_index != active_torrent) continue;
|
if (torrent_index != active_torrent) continue;
|
||||||
active_handle = h;
|
active_handle = h;
|
||||||
|
Reference in New Issue
Block a user