فهرست منبع

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.
Tatsuhiro Tsujikawa 14 سال پیش
والد
کامیت
561dafc942
7فایلهای تغییر یافته به همراه26 افزوده شده و 2 حذف شده
  1. 3 2
      src/ConsoleStatCalc.cc
  2. 6 0
      src/ConsoleStatCalc.h
  3. 9 0
      src/OptionHandlerFactory.cc
  4. 1 0
      src/main.cc
  5. 2 0
      src/prefs.cc
  6. 2 0
      src/prefs.h
  7. 3 0
      src/usage_text.h

+ 3 - 2
src/ConsoleStatCalc.cc

@@ -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();

+ 6 - 0
src/ConsoleStatCalc.h

@@ -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;

+ 9 - 0
src/OptionHandlerFactory.cc

@@ -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,

+ 1 - 0
src/main.cc

@@ -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;

+ 2 - 0
src/prefs.cc

@@ -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

+ 2 - 0
src/prefs.h

@@ -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

+ 3 - 0
src/usage_text.h

@@ -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.")