in client_test, print the number of pieces downloaded in the torrent list, and improve printing of padfiles in file list

This commit is contained in:
arvidn 2018-08-05 14:40:57 +02:00 committed by Arvid Norberg
parent 3416da41d9
commit eae4307da2
2 changed files with 17 additions and 19 deletions

View File

@ -1856,19 +1856,8 @@ COLUMN OPTIONS
int const idx = static_cast<int>(i);
if (pos + 1 >= terminal_height) break;
bool pad_file = ti->files().pad_file_at(i);
if (pad_file)
{
if (show_pad_files)
{
std::snprintf(str, sizeof(str), "\x1b[34m%-70s %s\x1b[0m\x1b[K\n"
, ti->files().file_name(i).to_string().c_str()
, add_suffix(ti->files().file_size(i)).c_str());
out += str;
pos += 1;
}
continue;
}
bool const pad_file = ti->files().pad_file_at(i);
if (pad_file && !show_pad_files) continue;
int const progress = ti->files().file_size(i) > 0
? int(file_progress[idx] * 1000 / ti->files().file_size(i)) : 1000;
@ -1895,7 +1884,7 @@ COLUMN OPTIONS
++f;
}
const int file_progress_width = 65;
const int file_progress_width = pad_file ? 10 : 65;
// do we need to line-break?
if (p + file_progress_width + 13 > terminal_width)
@ -1906,8 +1895,10 @@ COLUMN OPTIONS
}
std::snprintf(str, sizeof(str), "%s %7s p: %d ",
progress_bar(progress, file_progress_width, complete ? col_green : col_yellow, '-', '#'
, title.c_str()).c_str()
progress_bar(progress, file_progress_width
, pad_file ? col_blue
: complete ? col_green : col_yellow
, '-', '#', title.c_str()).c_str()
, add_suffix(file_progress[idx]).c_str()
, static_cast<std::uint8_t>(file_prio[idx]));

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/add_torrent_params.hpp"
#include "libtorrent/torrent_handle.hpp"
#include "libtorrent/torrent_status.hpp"
#include "libtorrent/torrent_info.hpp"
const int header_size = 2;
using lt::queue_position_t;
@ -347,8 +348,8 @@ void torrent_view::print_headers()
// print title bar for torrent list
std::snprintf(str, sizeof(str)
, " %-3s %-50s %-35s %-17s %-17s %-11s %-6s %-6s %-4s\x1b[K"
, "#", "Name", "Progress", "Download", "Upload", "Peers (D:S)"
, " %-3s %-50s %-35s %-14s %-17s %-17s %-11s %-6s %-6s %-4s\x1b[K"
, "#", "Name", "Progress", "Pieces", "Download", "Upload", "Peers (D:S)"
, "Down", "Up", "Flags");
if (m_width + 1 < int(sizeof(str)))
@ -386,13 +387,19 @@ void torrent_view::print_torrent(lt::torrent_status const& s, bool selected)
else if (s.current_tracker.empty())
progress_bar_color = col_green;
pos += std::snprintf(str + pos, sizeof(str) - pos, "%s%-3s %-50s %s%s %s (%s) "
auto ti = s.torrent_file.lock();
int const total_pieces = ti ? ti->num_pieces() : 0;
color_code piece_color = total_pieces == s.num_pieces ? col_green : col_yellow;
pos += std::snprintf(str + pos, sizeof(str) - pos, "%s%-3s %-50s %s%s %s/%s %s (%s) "
"%s (%s) %5d:%-5d %s %s %c"
, selection
, queue_pos
, name.c_str()
, progress_bar(s.progress_ppm / 1000, 35, progress_bar_color, '-', '#', torrent_state(s)).c_str()
, selection
, color(to_string(s.num_pieces, 6), piece_color).c_str()
, color(to_string(total_pieces, 6), piece_color).c_str()
, color(add_suffix(s.download_rate, "/s"), col_green).c_str()
, color(add_suffix(s.total_download), col_green).c_str()
, color(add_suffix(s.upload_rate, "/s"), col_red).c_str()