From e7c032338901274425b8d87a527d6aee57711745 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 24 Dec 2006 21:13:02 +0000 Subject: david - tweaked so numbers are at least accurate now... percentages actually work, but targets built as a result of a requires chain no longer count towards/ nor display the total count. also added a color view for fun --- src/main.cpp | 7 +++++++ src/viewerfactory.cpp | 2 ++ src/viewerplainpct.cpp | 45 +++++++++++++++++++++++++-------------------- src/viewerplainpct.h | 9 +++++---- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b7cf6e7..ebde3aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,6 +33,8 @@ public: "Switch to percent view."); addParam('P', mkproc(Param::procViewPlain), "Switch to plain view."); + addParam("color", mkproc(Param::procColorPercent), + "Switch to colored percent view."); addParam('m', mkproc(Param::procViewMake), "Switch to 'make' style view."); addParam("cache", &sCache, @@ -77,6 +79,11 @@ public: sView = "make"; } + int procColorPercent( int argc, char *argv[] ) + { + sView = "colorpct"; + } + std::string sCache; std::string sFile; std::string sView; diff --git a/src/viewerfactory.cpp b/src/viewerfactory.cpp index 52ec5d4..7826a6a 100644 --- a/src/viewerfactory.cpp +++ b/src/viewerfactory.cpp @@ -4,6 +4,7 @@ extern struct PluginInfo plain; extern struct PluginInfo percent; extern struct PluginInfo make; extern struct PluginInfo plainpct; +extern struct PluginInfo colorpct; ViewerFactory::ViewerFactory() { @@ -11,6 +12,7 @@ ViewerFactory::ViewerFactory() registerBuiltinPlugin( &percent ); registerBuiltinPlugin( &make ); registerBuiltinPlugin( &plainpct ); + registerBuiltinPlugin( &colorpct ); } ViewerFactory::~ViewerFactory() diff --git a/src/viewerplainpct.cpp b/src/viewerplainpct.cpp index dcf90ec..9988ca7 100644 --- a/src/viewerplainpct.cpp +++ b/src/viewerplainpct.cpp @@ -33,7 +33,8 @@ void ViewerPlainPct::endCommand() if( sCmd.front().bCmdClean == false ) printf("\n"); sCmd.pop_front(); - iCC++; + if(sCmd.empty()) + iCC++; } void ViewerPlainPct::indent() @@ -53,58 +54,62 @@ void ViewerPlainPct::printHead() bRunClean = false; sCmd.front().bCmdClean = false; indent(); - printf("--- [%d/%d] %s ---\n", iCC, iTC, sCmd.front().sTarget.c_str() ); + if(sCmd.size() > 1) + printf("--- %s ---\n", sCmd.front().sTarget.c_str() ); + else + printf("--- [%d/%d] %s ---\n", iCC, iTC, sCmd.front().sTarget.c_str() ); } } +void ViewerPlainPct::printPerform(const char *sRule, const char *sTarget) +{ + int iPct = (int)round( + ((double)sCmd.front().iCP/(double)sCmd.front().iTP)*100.0 + ); + if(sCmd.size() > 1) + printf( "[%3d%%] %8s: %s\n", iPct, sRule, sTarget ); + else + printf( "[%3d%%] %8s: %s\n", iPct, sRule, sTarget ); +} + void ViewerPlainPct::beginRequiresCheck( bool bCached, const std::string &sName ) { printHead(); indent(); - printf("[%3d%%] deps: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), sName.c_str() ); + printPerform("deps", sName.c_str()); } void ViewerPlainPct::endRequiresCheck() { - iCP++; - //bDidReq = true; + sCmd.front().iCP++; } void ViewerPlainPct::skipRequiresCheck( bool bCached, const std::string &sName ) { - iCP++; -/* printHead(); - indent(); - printf("[%3d%%] ! deps: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), sName.c_str() );*/ + sCmd.front().iCP++; } void ViewerPlainPct::beginPerform( Perform *pPerform ) { printHead(); indent(); - printf("[%3d%%] %8s: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), pPerform->getRule().c_str(), pPerform->getTarget().c_str() ); + printPerform(pPerform->getRule().c_str(), pPerform->getTarget().c_str()); } void ViewerPlainPct::endPerform() { - //if(!bDidReq) - iCP++; - //bDidReq = false; + sCmd.front().iCP++; } void ViewerPlainPct::skipPerform( Perform *pPerform ) { - iCP++; -/* printHead(); - indent(); - printf("[%3d%%] ! %8s: %s\n", (int)round(((double)iCP/(double)iTP)*100.0), pPerform->getRule().c_str(), pPerform->getTarget().c_str() );*/ + sCmd.front().iCP++; } void ViewerPlainPct::beginPerforms( int nCount ) { - iTP = nCount*2; - iCP = 1; - //bDidReq = false; + sCmd.front().iTP = nCount*2; + sCmd.front().iCP = 1; } void ViewerPlainPct::beginAction( const std::string &sName, int nCommands ) diff --git a/src/viewerplainpct.h b/src/viewerplainpct.h index aa9a228..63bc00d 100644 --- a/src/viewerplainpct.h +++ b/src/viewerplainpct.h @@ -1,5 +1,5 @@ -#ifndef VIEWER_PLAIN_H -#define VIEWER_PLAIN_H +#ifndef VIEWER_PLAIN_PCT_H +#define VIEWER_PLAIN_PCT_H #include #include @@ -27,12 +27,12 @@ public: virtual void endAction(); + void printPerform(const char *sRule, const char *sTarget); void printHead(); void indent(); private: - //bool bDidReq; - int iTP, iCP, iTC, iCC; + int iTC, iCC; bool bRunClean; typedef struct @@ -40,6 +40,7 @@ private: int nLevel; bool bCmdClean; std::string sTarget; + int iTP, iCP; } Cmd; typedef std::list CmdStack; CmdStack sCmd; -- cgit v1.2.3