Added --truncate-console-readout option.

This option truncates console readout to fit in a single line.  This
is default. Give false value to this option to tell aria2 not to
truncate console readout.
This commit is contained in:
Tatsuhiro Tsujikawa 2011-06-15 20:27:14 +09:00
parent e3e7a420de
commit 561dafc942
7 changed files with 26 additions and 2 deletions

View File

@ -230,7 +230,8 @@ void printProgressSummary
ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval, bool humanReadable):
summaryInterval_(summaryInterval),
readoutVisibility_(true)
readoutVisibility_(true),
truncate_(true)
{
if(humanReadable) {
sizeFormatter_.reset(new AbbrevSizeFormatter());
@ -362,7 +363,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
std::string readout = o.str();
if(isTTY) {
std::string::iterator last = readout.begin();
if(readout.size() > cols) {
if(truncate_ && readout.size() > cols) {
std::advance(last, cols);
} else {
last = readout.end();

View File

@ -64,6 +64,7 @@ private:
SharedHandle<SizeFormatter> sizeFormatter_;
bool readoutVisibility_;
bool truncate_;
public:
ConsoleStatCalc(time_t summaryInterval, bool humanReadable = true);
@ -75,6 +76,11 @@ public:
{
readoutVisibility_ = visibility;
}
void setTruncate(bool truncate)
{
truncate_ = truncate;
}
};
typedef SharedHandle<ConsoleStatCalc> ConsoleStatCalcHandle;

View File

@ -587,6 +587,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_TRUNCATE_CONSOLE_READOUT,
TEXT_TRUNCATE_CONSOLE_READOUT,
A2_V_TRUE,
OptionHandler::OPT_ARG));
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_RPC_LISTEN_ALL,

View File

@ -98,6 +98,7 @@ SharedHandle<StatCalc> getStatCalc(const SharedHandle<Option>& op)
(new ConsoleStatCalc(op->getAsInt(PREF_SUMMARY_INTERVAL),
op->getAsBool(PREF_HUMAN_READABLE)));
impl->setReadoutVisibility(op->getAsBool(PREF_SHOW_CONSOLE_READOUT));
impl->setTruncate(op->getAsBool(PREF_TRUNCATE_CONSOLE_READOUT));
statCalc = impl;
}
return statCalc;

View File

@ -224,6 +224,8 @@ const std::string PREF_ASYNC_DNS_SERVER("async-dns-server");
const std::string PREF_SHOW_CONSOLE_READOUT("show-console-readout");
// value: default | inorder
const std::string PREF_STREAM_PIECE_SELECTOR("stream-piece-selector");
// value: true | false
const std::string PREF_TRUNCATE_CONSOLE_READOUT("truncate-console-readout");
/**
* FTP related preferences

View File

@ -227,6 +227,8 @@ extern const std::string PREF_ASYNC_DNS_SERVER;
extern const std::string PREF_SHOW_CONSOLE_READOUT;
// value: default | inorder
extern const std::string PREF_STREAM_PIECE_SELECTOR;
// value: true | false
extern const std::string PREF_TRUNCATE_CONSOLE_READOUT;
/**
* FTP related preferences

View File

@ -809,3 +809,6 @@
" --min-split-size option, so it will be necessary\n" \
" to specify a reasonable value to\n" \
" --min-split-size option.")
#define TEXT_TRUNCATE_CONSOLE_READOUT \
_(" --truncate-console-readout[=true|false] Truncate console readout to fit in\n"\
" a single line.")