Browse Source

Changed console readout, making it more compact

"SIZE:" is removed because it is obvious. SEEDING, SEED, SPD and UP
are now replaced with SEED, SD, DL and UL respectively.
Tatsuhiro Tsujikawa 13 năm trước cách đây
mục cha
commit
2235743de3
3 tập tin đã thay đổi với 66 bổ sung108 xóa
  1. 15 13
      doc/manual-src/en/aria2c.rst
  2. 50 94
      src/ConsoleStatCalc.cc
  3. 1 1
      src/SequentialPicker.h

+ 15 - 13
doc/manual-src/en/aria2c.rst

@@ -3548,38 +3548,40 @@ Console Readout
 While downloading files, aria2 prints the console readout to tell the
 progress of the downloads. The console readout is like this::
 
-    [#1 SIZE:400.0KiB/33.2MiB(1%) CN:1 SPD:115.7KiBs ETA:4m51s]
+    [#1 400.0KiB/33.2MiB(1%) CN:1 DL:115.7KiB ETA:4m51s]
 
 This section describes what these numbers and strings mean.
 
 ``#N``
   N means GID, which is an unique ID for each download.
 
-``SIZE``
-  Completed length and Total length in bytes. If
+``X/Y(Z%)``
+  Completed length, the total file length and its ratio. If
   :option:`--select-file` is used, this is the sum of selected file.
 
-``SEEDING``
+``SEED``
   Share ratio. The client is now seeding. After BitTorrent download
-  finished, ``SIZE`` is replaced with ``SEEDING``.
+  finished, size information is replaced with this.
 
 ``CN``
   The number of connections the client has established.
 
-``SEED``
-  The number of seeders the client has connected to.
+``SD``
+  The number of seeders the client is now connecting to.
 
-``SPD``
-  Download speed.
+``DL``
+  Download speed (bytes per second).
 
-``UP``
-  Upload speed and the number of uploaded bytes.
+``UL``
+  Upload speed (bytes per second) and the number of uploaded bytes.
 
 ``ETA``
   Expected time to finish.
 
-``TOTAL SPD``
-  The sum of download speed for all parallel downloads.
+When more than 1 download are going on, some of the information
+described above will be omitted in order to show several download
+information. And the overall download and upload speed are shown at
+the beginning of the line.
 
 When aria2 is allocating file space or validating checksum, it
 additionally prints the their progress:

+ 50 - 94
src/ConsoleStatCalc.cc

@@ -96,18 +96,34 @@ protected:
 } // namespace
 
 namespace {
-void printSeedRatio(std::ostream& o, const SharedHandle<RequestGroup>& rg,
-                    const TransferStat& stat)
+void printSizeProgress(std::ostream& o, const SharedHandle<RequestGroup>& rg,
+                       const TransferStat& stat,
+                       const SizeFormatter& sizeFormatter)
 {
-  if(rg->getCompletedLength() > 0) {
-    std::streamsize oldprec = o.precision();
-    o << std::fixed << std::setprecision(1)
-      << ((stat.allTimeUploadLength*10)/rg->getCompletedLength())/10.0
-      << std::setprecision(oldprec)
-      << std::resetiosflags(std::ios::fixed);
-  } else {
-    o << "--";
-  }
+#ifdef ENABLE_BITTORRENT
+  if(rg->getDownloadContext()->hasAttribute(CTX_ATTR_BT) &&
+     !bittorrent::getTorrentAttrs(rg->getDownloadContext())
+     ->metadata.empty() && rg->downloadFinished()) {
+    o << "SEED(";
+    if(rg->getCompletedLength() > 0) {
+      std::streamsize oldprec = o.precision();
+      o << std::fixed << std::setprecision(1)
+        << ((stat.allTimeUploadLength*10)/rg->getCompletedLength())/10.0
+        << std::setprecision(oldprec)
+        << std::resetiosflags(std::ios::fixed);
+    } else {
+      o << "--";
+    }
+    o << ")";
+  } else
+#endif // ENABLE_BITTORRENT
+    {
+      o << sizeFormatter(rg->getCompletedLength()) << "B/"
+        << sizeFormatter(rg->getTotalLength()) << "B";
+      if(rg->getTotalLength() > 0) {
+        o << "(" << 100*rg->getCompletedLength()/rg->getTotalLength() << "%)";
+      }
+    }
 }
 } // namespace
 
@@ -131,29 +147,11 @@ void printProgressCompact(std::ostream& o, const DownloadEngine* e,
       ++i, ++cnt) {
     TransferStat stat = (*i)->calculateStat();
     o << "[#" << (*i)->getGID() << " ";
-#ifdef ENABLE_BITTORRENT
-    if((*i)->getDownloadContext()->hasAttribute(CTX_ATTR_BT) &&
-       !bittorrent::getTorrentAttrs((*i)->getDownloadContext())
-       ->metadata.empty() && (*i)->downloadFinished()) {
-      o << "SEED(";
-      printSeedRatio(o, *i, stat);
-      o << ")";
-    } else
-#endif // ENABLE_BITTORRENT
-      {
-        o << sizeFormatter((*i)->getCompletedLength()) << "B"
-          << "/"
-          << sizeFormatter((*i)->getTotalLength()) << "B";
-        if((*i)->getTotalLength() > 0) {
-          o << "("
-            << 100*(*i)->getCompletedLength()/(*i)->getTotalLength()
-            << "%)";
-        }
-      }
+    printSizeProgress(o, *i, stat, sizeFormatter);
     o << "]";
   }
   if(cnt < groups.size()) {
-    o << "(" << groups.size()-cnt << "more)";
+    o << "(+" << groups.size()-cnt << ")";
   }
 }
 } // namespace
@@ -168,30 +166,8 @@ void printProgress
   if(rg->getTotalLength() > 0 && stat.downloadSpeed > 0) {
     eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.downloadSpeed;
   }
-
   o << "[#" << rg->getGID() << " ";
-
-#ifdef ENABLE_BITTORRENT
-  if(rg->getDownloadContext()->hasAttribute(CTX_ATTR_BT) &&
-     !bittorrent::getTorrentAttrs(rg->getDownloadContext())->metadata.empty() &&
-     rg->downloadFinished()) {
-    o << "SEEDING(ratio:";
-    printSeedRatio(o, rg, stat);
-    o << ")";
-  } else
-#endif // ENABLE_BITTORRENT
-    {
-      o << "SIZE:"
-        << sizeFormatter(rg->getCompletedLength())
-        << "B/"
-        << sizeFormatter(rg->getTotalLength())
-        << "B";
-      if(rg->getTotalLength() > 0) {
-        o << "("
-          << 100*rg->getCompletedLength()/rg->getTotalLength()
-          << "%)";
-      }
-    }
+  printSizeProgress(o, rg, stat, sizeFormatter);
   o << " CN:"
     << rg->getNumConnection();
 #ifdef ENABLE_BITTORRENT
@@ -199,18 +175,18 @@ void printProgress
   if(btObj) {
     std::vector<SharedHandle<Peer> > peers;
     btObj->peerStorage->getActivePeers(peers);
-    o << " SEED:"
+    o << " SD:"
       << countSeeder(peers.begin(), peers.end());
   }
 #endif // ENABLE_BITTORRENT
 
   if(!rg->downloadFinished()) {
-    o << " SPD:"
-      << sizeFormatter(stat.downloadSpeed) << "Bs";
+    o << " DL:"
+      << sizeFormatter(stat.downloadSpeed) << "B";
   }
   if(stat.sessionUploadLength > 0) {
-    o << " UP:"
-      << sizeFormatter(stat.uploadSpeed) << "Bs"
+    o << " UL:"
+      << sizeFormatter(stat.uploadSpeed) << "B"
       << "(" << sizeFormatter(stat.allTimeUploadLength) << "B)";
   }
   if(eta > 0) {
@@ -309,20 +285,16 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
   cp_ = global::wallclock();
   const SizeFormatter& sizeFormatter = *sizeFormatter_.get();
 
-#ifdef __MINGW32__
-  // Windows terminal cannot handle at the end of line (80 columns)
-  // properly.
+  // Some terminals (e.g., Windows terminal) prints next line when the
+  // character reached at the last column.
   unsigned short int cols = 79;
-#else // !__MINGW32__
-  unsigned short int cols = 80;
-#endif // !__MINGW32__
 
   if(isTTY_) {
 #ifndef __MINGW32__
 #ifdef HAVE_TERMIOS_H
     struct winsize size;
     if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
-      cols = size.ws_col;
+      cols = std::max(0, (int)size.ws_col-1);
     }
 #endif // HAVE_TERMIOS_H
 #endif // !__MINGW32__
@@ -346,31 +318,21 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
   }
   size_t numGroup = e->getRequestGroupMan()->countRequestGroup();
   if(numGroup == 1) {
-    SharedHandle<RequestGroup> firstRequestGroup =
-      e->getRequestGroupMan()->getRequestGroup(0);
-
-    printProgress(o, firstRequestGroup, e, sizeFormatter);
-
-    if(e->getRequestGroupMan()->countRequestGroup() > 1) {
-      o << "("
-        << e->getRequestGroupMan()->countRequestGroup()-1
-        << "more...)";
-    }
+    printProgress(o, e->getRequestGroupMan()->getRequestGroup(0), e,
+                  sizeFormatter);
   } else if(numGroup > 1) {
     // For more than 2 RequestGroups, use compact readout form
     printProgressCompact(o, e, sizeFormatter);
   }
 
   {
-    SharedHandle<FileAllocationEntry> entry =
+    const SharedHandle<FileAllocationEntry>& entry =
       e->getFileAllocationMan()->getPickedEntry();
     if(entry) {
-      o << " [FileAlloc:"
-        << "#" << entry->getRequestGroup()->getGID() << " "
-        << sizeFormatter(entry->getCurrentLength())
-        << "B/"
-        << sizeFormatter(entry->getTotalLength())
-        << "B(";
+      o << " [FileAlloc:#"
+        << entry->getRequestGroup()->getGID() << " "
+        << sizeFormatter(entry->getCurrentLength()) << "B/"
+        << sizeFormatter(entry->getTotalLength()) << "B(";
       if(entry->getTotalLength() > 0) {
         o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
       } else {
@@ -378,23 +340,19 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
       }
       o << "%)]";
       if(e->getFileAllocationMan()->hasNext()) {
-        o << "("
-          << e->getFileAllocationMan()->countEntryInQueue()
-          << "waiting...)";
+        o << "(+" << e->getFileAllocationMan()->countEntryInQueue() << ")";
       }
     }
   }
 #ifdef ENABLE_MESSAGE_DIGEST
   {
-    SharedHandle<CheckIntegrityEntry> entry =
+    const SharedHandle<CheckIntegrityEntry>& entry =
       e->getCheckIntegrityMan()->getPickedEntry();
     if(entry) {
       o << " [Checksum:#"
         << entry->getRequestGroup()->getGID() << " "
-        << sizeFormatter(entry->getCurrentLength())
-        << "B/"
-        << sizeFormatter(entry->getTotalLength())
-        << "B(";
+        << sizeFormatter(entry->getCurrentLength()) << "B/"
+        << sizeFormatter(entry->getTotalLength()) << "B(";
       if(entry->getTotalLength() > 0) {
         o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
       } else {
@@ -402,9 +360,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
       }
       o << "%)]";
       if(e->getCheckIntegrityMan()->hasNext()) {
-        o << "("
-          << e->getCheckIntegrityMan()->countEntryInQueue()
-          << "waiting...)";
+        o << "(+" << e->getCheckIntegrityMan()->countEntryInQueue() << ")";
       }
     }
   }

+ 1 - 1
src/SequentialPicker.h

@@ -54,7 +54,7 @@ public:
     return pickedEntry_;
   }
 
-  SharedHandle<T> getPickedEntry() const
+  const SharedHandle<T>& getPickedEntry() const
   {
     return pickedEntry_;
   }