rtorrent display 1 line per torrent

I like to have rtorrent display everything on 1 line instead of 3. Here are some tips how to get this done. I found these to work the same way in both 0.8.2 and 0.8.5

There are two files involved: src/display/window_download_list.cc and src/display/utils.cc

In the first file we change where it calculates the amount of lines to use:

Range range = rak::advance_bidirectional(m_view->begin_visible(),
m_view->focus() != m_view->end_visible() ? m_view->focus() : m_view->begin_visible(),
m_view->end_visible(),
m_canvas->height() / 3);

Simply remove “/ 3″

Next is the part where it calls some functions in utils.cc. Just remove the four lines of the second and third so you just call print_download_title

Now we change the function print_download_title in utils.cc.
Comment out the only line it has:

// return print_buffer(first, last, " %s", d->download()->name().c_str());

Take a look at the other functions to get an idea of what you want to add and how to do that.

Every addition to the line is of the form: first = print_buffer(first, last, printf_format, printf_variables);
At the end ‘first’ is returned.

Here is the entire function I used.

char*
print_download_title(char* first, char* last, core::Download* d) {
// Status
if (!d->download()->is_open())
first = print_buffer(first, last, "stop:");
else if (!d->download()->is_active())
first = print_buffer(first, last, "open:");
else if (!d->is_done())
first = print_buffer(first, last, "load:");
else
first = print_buffer(first, last, "done:");


// Title
first = print_buffer(first, last, "%-52.52s", d->download()->name().c_str());


if (d->is_active()) {
// Size
first = print_buffer(first, last, " %6.0fm", (double)d->download()->file_list()->size_bytes() / (double)(1 << 20));


//Rate
first = print_buffer(first, last, " |%4.0f/%-4.0f| ",
(double)d->download()->up_rate()->rate() / (1 << 10),

(double)d->download()->down_rate()->rate() / (1 << 10));


// Percentage if downloading / Ratio if finished
if (d->download()->is_active()) {
if ( !d->is_done()) {
first = print_download_percentage_done(first,last,d);
} else {
first = print_buffer(first, last, "r:%-3.2f", (double)rpc::call_command_value("d.get_ratio", rpc::make_target(d)) / 1000.0);
}
}
}


// Check whether it is hashing
if (d->is_hash_checking()) {
first = print_buffer(first, last, " hashing...");
}


// Print any tracker messages
if (!d->message().empty()) {
first = print_buffer(first, last, " %s", d->message().c_str());
}


// Fail safe
if (first > last) {
throw torrent::internal_error("print_download_title(...) wrote past end of the buffer.");
}


return first;
}

This entry was posted in Programming. Bookmark the permalink.

2 Responses to rtorrent display 1 line per torrent

  1. procyon says:

    Added some text that got gobbled up as a tag

    Original:

    // Rate
    first = print_buffer(first, last, " |%4.0f/%-4.0f| ",
    (double)d->download()->up_rate()->rate() / (1 down_rate()->rate() / (1 << 10));

    Fix:

    //rate
    first = print_buffer(first, last, " |%4.0f/%-4.0f| ",
    (double)d->download()->up_rate()->rate() / (1 << 10),
    (double)d->download()->down_rate()->rate() / (1 << 10));

Comments are closed.