Fixed displaying the progress to the terminal.
authorMartin Vidner <mvidner@suse.cz>
Wed, 13 Sep 2006 15:42:58 +0000 (15:42 +0000)
committerMartin Vidner <mvidner@suse.cz>
Wed, 13 Sep 2006 15:42:58 +0000 (15:42 +0000)
Added a missing return value.

tools/zmart/AliveCursor.h
tools/zmart/zmart-keyring-callbacks.h
tools/zmart/zmart-rpm-callbacks.h
tools/zmart/zmart-source-callbacks.h

index 990e18d..b6837ab 100644 (file)
@@ -2,6 +2,9 @@
 #ifndef ALIVE_CURSOR_H
 #define ALIVE_CURSOR_H
 
+// VT 100
+#define CLEARLN "\x1B[2K\r"
+
 class AliveCursor
 {
   public:
index 0aeaf33..01df13b 100644 (file)
@@ -19,6 +19,7 @@
 #include <zypp/KeyRing.h>
 #include <zypp/Digest.h>
 
+#include "AliveCursor.h"
 #include "zmart-misc.h"
 
 ///////////////////////////////////////////////////////////////////
@@ -32,7 +33,7 @@ namespace zypp {
     {
       virtual bool askUserToAcceptUnsignedFile( const std::string &file )
       {
-        cout << "\x1B 2K\r" << file << " is unsigned, continue? [y/n]: ";
+        cout << CLEARLN << file << " is unsigned, continue? [y/n]: " << flush;
         return readBoolAnswer();
       }
       
@@ -41,18 +42,18 @@ namespace zypp {
         if ( geteuid() != 0 )
           return false;
         
-        cout << "\x1B 2K\r" << "Import key " << key.id() << " in trusted keyring? [y/n]: ";
+        cout << CLEARLN << "Import key " << key.id() << " in trusted keyring? [y/n]: " << flush;
         return readBoolAnswer();
       } 
       
       virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id )
       {
-        cout << "\x1B 2K\r" << file << " is signed with an unknown key id: " << id << ", continue? [y/n]: ";
+        cout << CLEARLN << file << " is signed with an unknown key id: " << id << ", continue? [y/n]: " << flush;
         return readBoolAnswer();
       }
       virtual bool askUserToTrustKey( const PublicKey &key )
       {
-        cout  << "\x1B 2K\r" << "Do you want to trust key id " << key.id() << " " << key.name() << " fingerprint:" << key.fingerprint() << " ? [y/n]: " ;
+        cout  << CLEARLN << "Do you want to trust key id " << key.id() << " " << key.name() << " fingerprint:" << key.fingerprint() << " ? [y/n]: "  << flush;
         return readBoolAnswer();
       }
       virtual bool askUserToAcceptVerificationFailed( const std::string &file,const PublicKey &key )
index f437d1f..37bdf80 100644 (file)
@@ -120,7 +120,7 @@ struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReport<zy
   
   void display_step( zypp::Resolvable::constPtr resolvable, int value )
   {
-    cout << "\x1B 2K\r" << _cursor << " Installing " <<  resolvable << " [" << value << " %]  ";
+    cout << CLEARLN << _cursor << " Installing " <<  resolvable << " [" << value << " %]  " << flush;
     ++_cursor;
   }
   
index d25cf0a..a347d25 100644 (file)
@@ -85,7 +85,7 @@ struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReport<z
    
   void display_step( const std::string &what, int value )
   {
-    cout << "\x1B 2K\r" << _cursor << " " <<  what << " [" << value << " %]  ";
+    cout << CLEARLN << _cursor << " " <<  what << " [" << value << " %]  " << flush;
     ++_cursor;
   }
   
@@ -102,6 +102,7 @@ struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReport<z
   virtual bool progressDeltaDownload( int value )
   {
     display_step( "Downloading delta " + _delta.asString(), value );
+    return true;
   }
   
   virtual void problemDeltaDownload( const std::string &description )
@@ -192,7 +193,7 @@ struct SourceReportReceiver  : public zypp::callback::ReceiveReport<zypp::source
   
   void display_step( int value )
   {
-    cout << "\x1B 2K\r" << _cursor << " " <<  _task << " [" << value << " %]  ";
+    cout << CLEARLN << _cursor << " " <<  _task << " [" << value << " %]  " << flush;
     ++_cursor;
   }