* 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:
rakshasa
2006-06-04 23:37:39 +00:00
parent 46dd41e956
commit d0f6719e50
7 changed files with 151 additions and 18 deletions
+3 -1
View File
@@ -62,7 +62,7 @@ public:
bool is_dynamic() { return m_dynamic; }
bool is_dirty() { return m_taskUpdate.is_queued(); }
int get_min_height() { return m_minHeight; }
int get_min_height() const { return m_minHeight; }
bool get_active() { return m_active; }
void set_active(bool a);
@@ -70,6 +70,8 @@ public:
void refresh() { m_canvas->refresh(); }
void resize(int x, int y, int w, int h);
int get_height() const { return m_canvas->get_height(); }
void mark_dirty() { m_slotSchedule(this, cachedTime + 1); }
virtual void redraw() = 0;
+23 -12
View File
@@ -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();
}
}
+8 -1
View File
@@ -49,12 +49,19 @@ namespace display {
class WindowDownloadChunksSeen : public Window {
public:
WindowDownloadChunksSeen(core::Download* d);
WindowDownloadChunksSeen(core::Download* d, unsigned int* focus);
virtual void redraw();
unsigned int rows() const;
unsigned int chunks_per_row() const { return (m_canvas->get_width() - 6) / 11 * 10; }
unsigned int max_focus() const { return std::max<int>(rows() - get_height() + 1, 0); }
private:
core::Download* m_download;
unsigned int* m_focus;
};
}