added option to set the screen refresh rate of client_test
This commit is contained in:
@@ -72,13 +72,16 @@ using boost::bind;
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
|
||||||
bool sleep_and_input(char* c)
|
bool sleep_and_input(char* c, int sleep)
|
||||||
{
|
{
|
||||||
Sleep(500);
|
for (int i = 0; i < sleep * 2; ++i)
|
||||||
if (_kbhit())
|
|
||||||
{
|
{
|
||||||
*c = _getch();
|
if (_kbhit())
|
||||||
return true;
|
{
|
||||||
|
*c = _getch();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Sleep(500);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -122,7 +125,7 @@ struct set_keypress
|
|||||||
termios stored_settings;
|
termios stored_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool sleep_and_input(char* c)
|
bool sleep_and_input(char* c, int sleep)
|
||||||
{
|
{
|
||||||
// sets the terminal to single-character mode
|
// sets the terminal to single-character mode
|
||||||
// and resets when destructed
|
// and resets when destructed
|
||||||
@@ -131,7 +134,7 @@ bool sleep_and_input(char* c)
|
|||||||
fd_set set;
|
fd_set set;
|
||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
FD_SET(0, &set);
|
FD_SET(0, &set);
|
||||||
timeval tv = {0, 500000};
|
timeval tv = {sleep, 0};
|
||||||
if (select(1, &set, 0, 0, &tv) > 0)
|
if (select(1, &set, 0, 0, &tv) > 0)
|
||||||
{
|
{
|
||||||
*c = getc(stdin);
|
*c = getc(stdin);
|
||||||
@@ -746,6 +749,8 @@ int main(int argc, char* argv[])
|
|||||||
" -x <file> loads an emule IP-filter file\n"
|
" -x <file> loads an emule IP-filter file\n"
|
||||||
" -c <limit> sets the max number of connections\n"
|
" -c <limit> sets the max number of connections\n"
|
||||||
" -C <limit> sets the max cache size. Specified in 16kB blocks\n"
|
" -C <limit> sets the max cache size. Specified in 16kB blocks\n"
|
||||||
|
" -F <seconds> sets the UI refresh rate. This is the number of\n"
|
||||||
|
" seconds between screen refreshes.\n"
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"TORRENT is a path to a .torrent file\n"
|
"TORRENT is a path to a .torrent file\n"
|
||||||
"MAGNETURL is a magnet: url\n")
|
"MAGNETURL is a magnet: url\n")
|
||||||
@@ -762,6 +767,8 @@ int main(int argc, char* argv[])
|
|||||||
settings.announce_to_all_trackers = true;
|
settings.announce_to_all_trackers = true;
|
||||||
settings.optimize_hashing_for_speed = false;
|
settings.optimize_hashing_for_speed = false;
|
||||||
|
|
||||||
|
int refresh_delay = 1;
|
||||||
|
|
||||||
std::deque<std::string> events;
|
std::deque<std::string> events;
|
||||||
|
|
||||||
ptime next_dir_scan = time_now();
|
ptime next_dir_scan = time_now();
|
||||||
@@ -910,6 +917,7 @@ int main(int argc, char* argv[])
|
|||||||
case 'b': bind_to_interface = arg; break;
|
case 'b': bind_to_interface = arg; break;
|
||||||
case 'w': settings.urlseed_wait_retry = atoi(arg); break;
|
case 'w': settings.urlseed_wait_retry = atoi(arg); break;
|
||||||
case 't': poll_interval = atoi(arg); break;
|
case 't': poll_interval = atoi(arg); break;
|
||||||
|
case 'F': refresh_delay = atoi(arg); break;
|
||||||
case 'x':
|
case 'x':
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -958,7 +966,7 @@ int main(int argc, char* argv[])
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
while (sleep_and_input(&c))
|
while (sleep_and_input(&c, refresh_delay))
|
||||||
{
|
{
|
||||||
if (c == 27)
|
if (c == 27)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user