mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-09 15:49:20 +00:00
* Added pageup/down to chunks seen and file list. Patch by Josef
Drexler, all future patches to lib/rtorrent will be under public domain. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@712 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -47,9 +47,10 @@
|
||||
|
||||
namespace display {
|
||||
|
||||
WindowDownloadChunksSeen::WindowDownloadChunksSeen(core::Download* d) :
|
||||
WindowDownloadChunksSeen::WindowDownloadChunksSeen(core::Download* d, unsigned int *focus) :
|
||||
Window(new Canvas, true),
|
||||
m_download(d) {
|
||||
m_download(d),
|
||||
m_focus(focus) {
|
||||
}
|
||||
|
||||
void
|
||||
@@ -62,9 +63,9 @@ WindowDownloadChunksSeen::redraw() {
|
||||
return;
|
||||
|
||||
m_canvas->print(2, 0, "Chunks seen: [C/A/D %i/%i/%.2f]",
|
||||
(int)m_download->download()->peers_complete(),
|
||||
(int)m_download->download()->peers_accounted(),
|
||||
std::floor(m_download->distributed_copies() * 100.0f) / 100.0f);
|
||||
(int)m_download->download()->peers_complete(),
|
||||
(int)m_download->download()->peers_accounted(),
|
||||
std::floor(m_download->distributed_copies() * 100.0f) / 100.0f);
|
||||
|
||||
const uint8_t* seen = m_download->download()->chunks_seen();
|
||||
|
||||
@@ -73,7 +74,9 @@ WindowDownloadChunksSeen::redraw() {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t* chunk = seen;
|
||||
*m_focus = std::min(*m_focus, max_focus());
|
||||
|
||||
const uint8_t* chunk = seen + *m_focus * chunks_per_row();
|
||||
const uint8_t* last = seen + m_download->download()->chunks_total();
|
||||
|
||||
const torrent::Bitfield* bitfield = m_download->download()->bitfield();
|
||||
@@ -85,23 +88,31 @@ WindowDownloadChunksSeen::redraw() {
|
||||
chtype attr;
|
||||
|
||||
if (bitfield->get(chunk - seen))
|
||||
attr = A_NORMAL;
|
||||
attr = A_NORMAL;
|
||||
// else if (foo->is_downloading(chunk - seen))
|
||||
// attr = A_UNDERLINE;
|
||||
// attr = A_UNDERLINE;
|
||||
else
|
||||
attr = A_BOLD;
|
||||
attr = A_BOLD;
|
||||
|
||||
m_canvas->print_char(attr | rak::value_to_hexchar<0>(std::min<uint8_t>(*chunk, 0xF)));
|
||||
chunk++;
|
||||
|
||||
if ((chunk - seen) % 10 == 0) {
|
||||
if (m_canvas->get_x() + 12 > m_canvas->get_width())
|
||||
break;
|
||||
if (m_canvas->get_x() + 12 > m_canvas->get_width())
|
||||
break;
|
||||
|
||||
m_canvas->print_char(' ');
|
||||
m_canvas->print_char(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
WindowDownloadChunksSeen::rows() const {
|
||||
if (m_canvas->get_width() < 18)
|
||||
return 0;
|
||||
|
||||
return (m_download->download()->chunks_total() + chunks_per_row() - 1) / chunks_per_row();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user