mirror of https://github.com/aria2/aria2
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.pull/1/head
parent
e3e7a420de
commit
561dafc942
|
@ -230,7 +230,8 @@ void printProgressSummary
|
||||||
|
|
||||||
ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval, bool humanReadable):
|
ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval, bool humanReadable):
|
||||||
summaryInterval_(summaryInterval),
|
summaryInterval_(summaryInterval),
|
||||||
readoutVisibility_(true)
|
readoutVisibility_(true),
|
||||||
|
truncate_(true)
|
||||||
{
|
{
|
||||||
if(humanReadable) {
|
if(humanReadable) {
|
||||||
sizeFormatter_.reset(new AbbrevSizeFormatter());
|
sizeFormatter_.reset(new AbbrevSizeFormatter());
|
||||||
|
@ -362,7 +363,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
std::string readout = o.str();
|
std::string readout = o.str();
|
||||||
if(isTTY) {
|
if(isTTY) {
|
||||||
std::string::iterator last = readout.begin();
|
std::string::iterator last = readout.begin();
|
||||||
if(readout.size() > cols) {
|
if(truncate_ && readout.size() > cols) {
|
||||||
std::advance(last, cols);
|
std::advance(last, cols);
|
||||||
} else {
|
} else {
|
||||||
last = readout.end();
|
last = readout.end();
|
||||||
|
|
|
@ -64,6 +64,7 @@ private:
|
||||||
|
|
||||||
SharedHandle<SizeFormatter> sizeFormatter_;
|
SharedHandle<SizeFormatter> sizeFormatter_;
|
||||||
bool readoutVisibility_;
|
bool readoutVisibility_;
|
||||||
|
bool truncate_;
|
||||||
public:
|
public:
|
||||||
ConsoleStatCalc(time_t summaryInterval, bool humanReadable = true);
|
ConsoleStatCalc(time_t summaryInterval, bool humanReadable = true);
|
||||||
|
|
||||||
|
@ -75,6 +76,11 @@ public:
|
||||||
{
|
{
|
||||||
readoutVisibility_ = visibility;
|
readoutVisibility_ = visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTruncate(bool truncate)
|
||||||
|
{
|
||||||
|
truncate_ = truncate;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<ConsoleStatCalc> ConsoleStatCalcHandle;
|
typedef SharedHandle<ConsoleStatCalc> ConsoleStatCalcHandle;
|
||||||
|
|
|
@ -587,6 +587,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_ADVANCED);
|
op->addTag(TAG_ADVANCED);
|
||||||
handlers.push_back(op);
|
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
|
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
||||||
(PREF_RPC_LISTEN_ALL,
|
(PREF_RPC_LISTEN_ALL,
|
||||||
|
|
|
@ -98,6 +98,7 @@ SharedHandle<StatCalc> getStatCalc(const SharedHandle<Option>& op)
|
||||||
(new ConsoleStatCalc(op->getAsInt(PREF_SUMMARY_INTERVAL),
|
(new ConsoleStatCalc(op->getAsInt(PREF_SUMMARY_INTERVAL),
|
||||||
op->getAsBool(PREF_HUMAN_READABLE)));
|
op->getAsBool(PREF_HUMAN_READABLE)));
|
||||||
impl->setReadoutVisibility(op->getAsBool(PREF_SHOW_CONSOLE_READOUT));
|
impl->setReadoutVisibility(op->getAsBool(PREF_SHOW_CONSOLE_READOUT));
|
||||||
|
impl->setTruncate(op->getAsBool(PREF_TRUNCATE_CONSOLE_READOUT));
|
||||||
statCalc = impl;
|
statCalc = impl;
|
||||||
}
|
}
|
||||||
return statCalc;
|
return statCalc;
|
||||||
|
|
|
@ -224,6 +224,8 @@ const std::string PREF_ASYNC_DNS_SERVER("async-dns-server");
|
||||||
const std::string PREF_SHOW_CONSOLE_READOUT("show-console-readout");
|
const std::string PREF_SHOW_CONSOLE_READOUT("show-console-readout");
|
||||||
// value: default | inorder
|
// value: default | inorder
|
||||||
const std::string PREF_STREAM_PIECE_SELECTOR("stream-piece-selector");
|
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
|
* FTP related preferences
|
||||||
|
|
|
@ -227,6 +227,8 @@ extern const std::string PREF_ASYNC_DNS_SERVER;
|
||||||
extern const std::string PREF_SHOW_CONSOLE_READOUT;
|
extern const std::string PREF_SHOW_CONSOLE_READOUT;
|
||||||
// value: default | inorder
|
// value: default | inorder
|
||||||
extern const std::string PREF_STREAM_PIECE_SELECTOR;
|
extern const std::string PREF_STREAM_PIECE_SELECTOR;
|
||||||
|
// value: true | false
|
||||||
|
extern const std::string PREF_TRUNCATE_CONSOLE_READOUT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* FTP related preferences
|
||||||
|
|
|
@ -809,3 +809,6 @@
|
||||||
" --min-split-size option, so it will be necessary\n" \
|
" --min-split-size option, so it will be necessary\n" \
|
||||||
" to specify a reasonable value to\n" \
|
" to specify a reasonable value to\n" \
|
||||||
" --min-split-size option.")
|
" --min-split-size option.")
|
||||||
|
#define TEXT_TRUNCATE_CONSOLE_READOUT \
|
||||||
|
_(" --truncate-console-readout[=true|false] Truncate console readout to fit in\n"\
|
||||||
|
" a single line.")
|
||||||
|
|
Loading…
Reference in New Issue