From 84ccb31a6d3a5b5a520f519fa11415425e5b395a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 6 Oct 2012 14:04:24 +0000 Subject: [PATCH] merged client_test from libtorrent_aio --- examples/client_test.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 574fdfe0d..10b3d83f6 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1870,6 +1870,8 @@ int main(int argc, char* argv[]) } #endif + int max_lines = terminal_height - 15; + // loop through the alert queue to see if anything has happened. std::deque alerts; ses.pop_alerts(&alerts); @@ -1928,7 +1930,7 @@ int main(int argc, char* argv[]) for (std::vector::iterator i = feeds.begin() , end(feeds.end()); i != end; ++i) { - if (lines_printed >= terminal_height - 15) + if (lines_printed >= max_lines) { out += "...\n"; break; @@ -1948,10 +1950,21 @@ int main(int argc, char* argv[]) } } + // handle scrolling down when moving the cursor + // below the fold + int start_offset = 0; + if (active_torrent >= max_lines - lines_printed) + start_offset = active_torrent - max_lines + lines_printed + 1; + for (std::vector::iterator i = filtered_handles.begin(); i != filtered_handles.end(); ++torrent_index) { - if (lines_printed >= terminal_height - 15) + if (torrent_index < start_offset) + { + ++i; + continue; + } + if (lines_printed >= max_lines) { out += "...\n"; break;