make printing of file progress more compact in client_test

This commit is contained in:
Arvid Norberg 2015-02-08 21:59:52 +00:00
parent 84fe616ccb
commit 1e80629770
1 changed files with 22 additions and 3 deletions

View File

@ -2069,7 +2069,7 @@ int main(int argc, char* argv[])
std::sort(cs.pieces.begin(), cs.pieces.end(), boost::bind(&cached_piece_info::piece, _1) std::sort(cs.pieces.begin(), cs.pieces.end(), boost::bind(&cached_piece_info::piece, _1)
> boost::bind(&cached_piece_info::piece, _2)); > boost::bind(&cached_piece_info::piece, _2));
int p = 0; int p = 0; // this is horizontal position
for (std::vector<cached_piece_info>::iterator i = cs.pieces.begin(); for (std::vector<cached_piece_info>::iterator i = cs.pieces.begin();
i != cs.pieces.end(); ++i) i != cs.pieces.end(); ++i)
{ {
@ -2158,6 +2158,8 @@ int main(int argc, char* argv[])
std::vector<int> file_prio = h.file_priorities(); std::vector<int> file_prio = h.file_priorities();
std::vector<pool_file_status>::iterator f = file_status.begin(); std::vector<pool_file_status>::iterator f = file_status.begin();
boost::shared_ptr<const torrent_info> ti = h.torrent_file(); boost::shared_ptr<const torrent_info> ti = h.torrent_file();
int p = 0; // this is horizontal position
for (int i = 0; i < ti->num_files(); ++i) for (int i = 0; i < ti->num_files(); ++i)
{ {
if (pos + 1 >= terminal_height) break; if (pos + 1 >= terminal_height) break;
@ -2201,12 +2203,29 @@ int main(int argc, char* argv[])
++f; ++f;
} }
snprintf(str, sizeof(str), "%s %s prio: %d\x1b[K\n", const int file_progress_width = 65;
progress_bar(progress, 70, complete?col_green:col_yellow, '-', '#'
// do we need to line-break?
if (p + file_progress_width + 13 > terminal_width)
{
out += "\x1b[K\n";
pos += 1;
p = 0;
}
snprintf(str, sizeof(str), "%s %7s p: %d ",
progress_bar(progress, file_progress_width, complete ? col_green : col_yellow, '-', '#'
, title.c_str()).c_str() , title.c_str()).c_str()
, add_suffix(file_progress[i]).c_str() , add_suffix(file_progress[i]).c_str()
, file_prio[i]); , file_prio[i]);
p += file_progress_width + 13;
out += str; out += str;
}
if (p != 0)
{
out += "\x1b[K\n";
pos += 1; pos += 1;
} }
} }